Skip to content

Commit

Permalink
update CI I guess
Browse files Browse the repository at this point in the history
Signed-off-by: Alexandre Lamarre <[email protected]>
  • Loading branch information
alexandreLamarre committed May 14, 2024
1 parent aaa21f3 commit f4d3dfe
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 35 deletions.
100 changes: 65 additions & 35 deletions .github/workflows/e2e-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,69 +42,99 @@ permissions:
contents: write

jobs:
build-rancher-manager:
runs-on: ubuntu-latest
steps:
- name: Checkout rancher repository
uses: actions/checkout@v4
with:
repository: rancher/rancher
ref: v2.8.3
- name: setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Build rancher
run: go build -o ./bin/rancher ./main.go && chmod +x ./bin/rancher
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: rancher-manager-build-artifact
path: ./bin/rancher
e2e-helm-project-operator:
needs : [
build-rancher-manager
]
runs-on: ubuntu-latest
strategy:
matrix:
k3s_version:
# k3d version list k3s | sed 's/+/-/' | sort -h
- ${{ github.event.inputs.k3s_version || 'v1.27.7-k3s2' }}
steps:
-
uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Install mikefarah/yq
- name : Fetch build artifacts
uses: actions/download-artifact@v4
with:
name: rancher-manager-build-artifact
path: ./bin/rancher
- name : Debug artifacts
run : ls -l ./bin
- name: Install mikefarah/yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
-
name: setup Go
- name: setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'
-
name: Perform CI
- name: Perform CI
run: |
REPO=${REPO} TAG=${TAG} ./scripts/build;
REPO=${REPO} TAG=${TAG} ./scripts/package;
-
name: Provision k3d Cluster
uses: AbsaOSS/k3d-action@v2
# k3d will automatically create a network named k3d-test-cluster-1 with the range 172.18.0.0/16
with:
cluster-name: "e2e-ci-helm-project-operator"
args: >-
--agents 1
--network "nw01"
--image docker.io/rancher/k3s:${{matrix.k3s_version}}
-
name: Import Images Into k3d
run: |
k3d image import ${REPO}/helm-project-operator:${TAG} -c e2e-ci-helm-project-operator;
-
name: Setup kubectl context
run: |
kubectl config use-context k3d-e2e-ci-helm-project-operator;
- name : Install k3d
run : ./.github/workflows/e2e/scripts/install-k3d.sh
- name : Setup k3d cluster
run : CLUSTER_NAME=e2e-ci-hpo ./.github/workflows/e2e/scripts/setup-k3d-cluster.sh
- name : Bootstrap cluster
run : CATTLE_DEV_MODE=30 CATTLE_BOOTSTRAP_PASSWORD=admin ./bin/rancher --trace=false --add-local=true --no-cacerts
# name: Provision k3d Cluster
# uses: AbsaOSS/k3d-action@v2
# # k3d will automatically create a network named k3d-test-cluster-1 with the range 172.18.0.0/16
# with:
# cluster-name: "e2e-ci-helm-project-operator"
# args: >-
# --agents 1
# --network "nw01"
# --image docker.io/rancher/k3s:${{matrix.k3s_version}}
# -
# name: Import Images Into k3d
# run: |
# k3d image import ${REPO}/helm-project-operator:${TAG} -c e2e-ci-helm-project-operator;
# -
# name: Setup kubectl context
# run: |
# kubectl config use-context k3d-e2e-ci-helm-project-operator;
-
name: Set Up Tmate Debug Session
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_tmate == 'true' }}
uses: mxschmitt/action-tmate@v3
timeout-minutes: 15
with:
limit-access-to-actor: true
limit-access-to-actor: true

# -
# name: Install rancher manager
# run: ./.github/workflows/e2e/scripts/install-rancher.sh;
# -
# name: Validate rancher manager
# run: ./.github/workflows/e2e/scripts/validate-rancher.sh;
-
name: Install Helm Project Operator
run: ./.github/workflows/e2e/scripts/install-helm-project-operator.sh;
-
name: Check if Helm Project Operator is up
run: ./.github/workflows/e2e/scripts/validate-helm-project-operator.sh;
-
name: Install rancher manager
run: ./.github/workflows/e2e/scripts/install-rancher.sh;
-
name: Validate rancher manager
run: ./.github/workflows/e2e/scripts/validate-rancher.sh;

-
name: Check if Project Registration Namespace is auto-created on namespace detection
run: ./.github/workflows/e2e/scripts/create-project-namespace.sh;
Expand Down
17 changes: 17 additions & 0 deletions .github/workflows/e2e/scripts/install-k3d.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -e
set -x

K3D_URL=https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
DEFAULT_K3D_VERSION=v5.4.6

install_k3d(){
local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}}
echo -e "Downloading k3d@${k3dVersion} see: ${K3D_URL}"
curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash
}

install_k3d

k3d version
70 changes: 70 additions & 0 deletions .github/workflows/e2e/scripts/setup-cluster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

set -e

source ./scripts/version

if [ -z "$CLUSTER_NAME" ]; then
echo "CLUSTER_NAME must be specified when setting up a cluster"
exit 1
fi

if [ -z "$K3S_VERSION" ]; then
echo "K3S_VERSION must be specified when setting up a cluster, use $(k3d version list k3s) to find valid versions"
exit 1
fi

# waits until all nodes are ready
wait_for_nodes(){
timeout=120
start_time=$(date +%s)
echo "wait until all agents are ready"
while :
do
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ $elapsed_time -ge $timeout ]; then
echo "Timeout reached, exiting..."
exit 1
fi

readyNodes=1
statusList=$(kubectl get nodes --no-headers | awk '{ print $2}')
# shellcheck disable=SC2162
while read status
do
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ $elapsed_time -ge $timeout ]; then
echo "Timeout reached, exiting..."
exit 1
fi
if [ "$status" == "NotReady" ] || [ "$status" == "" ]
then
readyNodes=0
break
fi
done <<< "$(echo -e "$statusList")"
# all nodes are ready; exit
if [[ $readyNodes == 1 ]]
then
break
fi
sleep 1
done
}

k3d cluster delete $CLUSTER_NAME || true
k3d cluster create $CLUSTER_NAME --image "docker.io/rancher/k3s:${K3S_VERSION}"

wait_for_nodes

echo "$CLUSTER_NAME ready"

kubectl cluster-info --context k3d-${CLUSTER_NAME}
kubectl config use-context k3d-${CLUSTER_NAME}
kubectl get nodes -o wide

IMAGE=${REPO}/backup-restore-operator:${TAG}

k3d image import ${IMAGE} -c $CLUSTER_NAME
1 change: 1 addition & 0 deletions scripts/version
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ REPO=${REPO:-rancher}
if echo $TAG | grep -q dirty; then
TAG=dev
fi
IMAGE=${REPO}/helm-project-operator:${TAG}

0 comments on commit f4d3dfe

Please sign in to comment.