Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit d20dfcb

Browse files
update CI I guess
Signed-off-by: Alexandre Lamarre <[email protected]>
1 parent ba1202b commit d20dfcb

File tree

4 files changed

+153
-35
lines changed

4 files changed

+153
-35
lines changed

.github/workflows/e2e-ci.yaml

Lines changed: 65 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -42,69 +42,99 @@ permissions:
4242
contents: write
4343

4444
jobs:
45+
build-rancher-manager:
46+
runs-on: ubuntu-latest
47+
steps:
48+
- name: Checkout rancher repository
49+
uses: actions/checkout@v4
50+
with:
51+
repository: rancher/rancher
52+
ref: v2.8.3
53+
- name: setup Go
54+
uses: actions/setup-go@v5
55+
with:
56+
go-version: '1.22'
57+
- name: Build rancher
58+
run: go build -o ./bin/rancher ./main.go && chmod +x ./bin/rancher
59+
- name: Upload artifact
60+
uses: actions/upload-artifact@v4
61+
with:
62+
name: rancher-manager-build-artifact
63+
path: ./bin/rancher
4564
e2e-helm-project-operator:
65+
needs : [
66+
build-rancher-manager
67+
]
4668
runs-on: ubuntu-latest
4769
strategy:
4870
matrix:
4971
k3s_version:
50-
# k3d version list k3s | sed 's/+/-/' | sort -h
5172
- ${{ github.event.inputs.k3s_version || 'v1.27.7-k3s2' }}
5273
steps:
53-
-
54-
uses: actions/checkout@v3
74+
- uses: actions/checkout@v4
5575
with:
5676
fetch-depth: 0
57-
-
58-
name: Install mikefarah/yq
77+
- name : Fetch build artifacts
78+
uses: actions/download-artifact@v4
79+
with:
80+
name: rancher-manager-build-artifact
81+
path: ./bin/rancher
82+
- name : Debug artifacts
83+
run : ls -l ./bin
84+
- name: Install mikefarah/yq
5985
run: |
6086
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
61-
-
62-
name: setup Go
87+
- name: setup Go
6388
uses: actions/setup-go@v5
6489
with:
6590
go-version: '1.22'
66-
-
67-
name: Perform CI
91+
- name: Perform CI
6892
run: |
69-
REPO=${REPO} TAG=${TAG} ./scripts/build;
7093
REPO=${REPO} TAG=${TAG} ./scripts/package;
71-
-
72-
name: Provision k3d Cluster
73-
uses: AbsaOSS/k3d-action@v2
74-
# k3d will automatically create a network named k3d-test-cluster-1 with the range 172.18.0.0/16
75-
with:
76-
cluster-name: "e2e-ci-helm-project-operator"
77-
args: >-
78-
--agents 1
79-
--network "nw01"
80-
--image docker.io/rancher/k3s:${{matrix.k3s_version}}
81-
-
82-
name: Import Images Into k3d
83-
run: |
84-
k3d image import ${REPO}/helm-project-operator:${TAG} -c e2e-ci-helm-project-operator;
85-
-
86-
name: Setup kubectl context
87-
run: |
88-
kubectl config use-context k3d-e2e-ci-helm-project-operator;
94+
- name : Install k3d
95+
run : ./.github/workflows/e2e/scripts/install-k3d.sh
96+
- name : Setup k3d cluster
97+
run : CLUSTER_NAME=e2e-ci-hpo ./.github/workflows/e2e/scripts/setup-k3d-cluster.sh
98+
- name : Bootstrap cluster
99+
run : CATTLE_DEV_MODE=30 CATTLE_BOOTSTRAP_PASSWORD=admin ./bin/rancher --trace=false --add-local=true --no-cacerts
100+
# name: Provision k3d Cluster
101+
# uses: AbsaOSS/k3d-action@v2
102+
# # k3d will automatically create a network named k3d-test-cluster-1 with the range 172.18.0.0/16
103+
# with:
104+
# cluster-name: "e2e-ci-helm-project-operator"
105+
# args: >-
106+
# --agents 1
107+
# --network "nw01"
108+
# --image docker.io/rancher/k3s:${{matrix.k3s_version}}
109+
# -
110+
# name: Import Images Into k3d
111+
# run: |
112+
# k3d image import ${REPO}/helm-project-operator:${TAG} -c e2e-ci-helm-project-operator;
113+
# -
114+
# name: Setup kubectl context
115+
# run: |
116+
# kubectl config use-context k3d-e2e-ci-helm-project-operator;
89117
-
90118
name: Set Up Tmate Debug Session
91119
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_tmate == 'true' }}
92120
uses: mxschmitt/action-tmate@v3
93121
timeout-minutes: 15
94122
with:
95-
limit-access-to-actor: true
123+
limit-access-to-actor: true
124+
125+
# -
126+
# name: Install rancher manager
127+
# run: ./.github/workflows/e2e/scripts/install-rancher.sh;
128+
# -
129+
# name: Validate rancher manager
130+
# run: ./.github/workflows/e2e/scripts/validate-rancher.sh;
96131
-
97132
name: Install Helm Project Operator
98133
run: ./.github/workflows/e2e/scripts/install-helm-project-operator.sh;
99134
-
100135
name: Check if Helm Project Operator is up
101136
run: ./.github/workflows/e2e/scripts/validate-helm-project-operator.sh;
102-
-
103-
name: Install rancher manager
104-
run: ./.github/workflows/e2e/scripts/install-rancher.sh;
105-
-
106-
name: Validate rancher manager
107-
run: ./.github/workflows/e2e/scripts/validate-rancher.sh;
137+
108138
-
109139
name: Check if Project Registration Namespace is auto-created on namespace detection
110140
run: ./.github/workflows/e2e/scripts/create-project-namespace.sh;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
set -e
4+
set -x
5+
6+
K3D_URL=https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
7+
DEFAULT_K3D_VERSION=v5.4.6
8+
9+
install_k3d(){
10+
local k3dVersion=${K3D_VERSION:-${DEFAULT_K3D_VERSION}}
11+
echo -e "Downloading k3d@${k3dVersion} see: ${K3D_URL}"
12+
curl --silent --fail ${K3D_URL} | TAG=${k3dVersion} bash
13+
}
14+
15+
install_k3d
16+
17+
k3d version
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
source ./scripts/version
6+
7+
if [ -z "$CLUSTER_NAME" ]; then
8+
echo "CLUSTER_NAME must be specified when setting up a cluster"
9+
exit 1
10+
fi
11+
12+
if [ -z "$K3S_VERSION" ]; then
13+
echo "K3S_VERSION must be specified when setting up a cluster, use $(k3d version list k3s) to find valid versions"
14+
exit 1
15+
fi
16+
17+
# waits until all nodes are ready
18+
wait_for_nodes(){
19+
timeout=120
20+
start_time=$(date +%s)
21+
echo "wait until all agents are ready"
22+
while :
23+
do
24+
current_time=$(date +%s)
25+
elapsed_time=$((current_time - start_time))
26+
if [ $elapsed_time -ge $timeout ]; then
27+
echo "Timeout reached, exiting..."
28+
exit 1
29+
fi
30+
31+
readyNodes=1
32+
statusList=$(kubectl get nodes --no-headers | awk '{ print $2}')
33+
# shellcheck disable=SC2162
34+
while read status
35+
do
36+
current_time=$(date +%s)
37+
elapsed_time=$((current_time - start_time))
38+
if [ $elapsed_time -ge $timeout ]; then
39+
echo "Timeout reached, exiting..."
40+
exit 1
41+
fi
42+
if [ "$status" == "NotReady" ] || [ "$status" == "" ]
43+
then
44+
readyNodes=0
45+
break
46+
fi
47+
done <<< "$(echo -e "$statusList")"
48+
# all nodes are ready; exit
49+
if [[ $readyNodes == 1 ]]
50+
then
51+
break
52+
fi
53+
sleep 1
54+
done
55+
}
56+
57+
k3d cluster delete $CLUSTER_NAME || true
58+
k3d cluster create $CLUSTER_NAME --image "docker.io/rancher/k3s:${K3S_VERSION}"
59+
60+
wait_for_nodes
61+
62+
echo "$CLUSTER_NAME ready"
63+
64+
kubectl cluster-info --context k3d-${CLUSTER_NAME}
65+
kubectl config use-context k3d-${CLUSTER_NAME}
66+
kubectl get nodes -o wide
67+
68+
IMAGE=${REPO}/backup-restore-operator:${TAG}
69+
70+
k3d image import ${IMAGE} -c $CLUSTER_NAME

scripts/version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ REPO=${REPO:-rancher}
2525
if echo $TAG | grep -q dirty; then
2626
TAG=dev
2727
fi
28+
IMAGE=${REPO}/helm-project-operator:${TAG}

0 commit comments

Comments
 (0)