Skip to content

Commit 792a149

Browse files
committed
Add hpo e2e workflow
1 parent 5bb2de1 commit 792a149

File tree

7 files changed

+269
-0
lines changed

7 files changed

+269
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source $(dirname $0)/../entry
5+
6+
cd $(dirname $0)/../../../../..
7+
8+
USE_RANCHER=${USE_RANCHER:-"false"}
9+
if [ "$USE_RANCHER" = "true" ]; then
10+
kubectl apply -f ./examples/helm-project-operator/ci/project.yaml
11+
fi
12+
13+
kubectl apply -f ./examples/helm-project-operator/ci/namespace.yaml
14+
15+
sleep "${DEFAULT_SLEEP_TIMEOUT_SECONDS}"
16+
if ! kubectl get namespace cattle-project-p-example; then
17+
echo "ERROR: Expected cattle-project-p-example namespace to exist after ${DEFAULT_SLEEP_TIMEOUT_SECONDS} seconds, not found"
18+
exit 1
19+
fi
20+
21+
echo "PASS: Project Registration Namespace was created"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source $(dirname $0)/../entry
5+
6+
cd $(dirname $0)/../../../../..
7+
8+
kubectl apply -f ./examples/helm-project-operator/ci/project-helm-chart.yaml
9+
sleep ${DEFAULT_SLEEP_TIMEOUT_SECONDS};
10+
11+
if ! kubectl get -n cattle-helm-system job/helm-install-project-operator-example-chart-dummy; then
12+
echo "ERROR: Helm Install Job for Example Chart was never created after ${KUBECTL_WAIT_TIMEOUT} seconds"
13+
echo "PROJECT HELM CHARTS:"
14+
kubectl get projecthelmchart -n cattle-project-p-example -o yaml
15+
echo "HELM CHARTS:"
16+
kubectl get helmcharts -n cattle-helm-system -o yaml
17+
echo "HELM RELEASES:"
18+
kubectl get helmreleases -n cattle-helm-system -o yaml
19+
echo "HELM PROJECT OPERATOR:"
20+
kubectl logs deployment/helm-project-operator -n cattle-helm-system
21+
exit 1
22+
fi
23+
24+
if ! kubectl wait --for=condition=complete --timeout="${KUBECTL_WAIT_TIMEOUT}" -n cattle-helm-system job/helm-install-project-operator-example-chart-dummy; then
25+
echo "ERROR: Helm Install Job for Example Chart never completed after ${KUBECTL_WAIT_TIMEOUT} seconds"
26+
kubectl logs job/helm-install-project-operator-example-chart-dummy -n cattle-helm-system
27+
exit 1
28+
fi
29+
kubectl logs job/helm-install-project-operator-example-chart-dummy -n cattle-helm-system
30+
31+
echo "PASS: Adding ProjectHelmChart successfully installed Example Chart"
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source $(dirname $0)/../entry
5+
6+
cd $(dirname $0)/../../../../..
7+
8+
kubectl delete -f ./examples/helm-project-operator/ci/project-helm-chart.yaml
9+
if kubectl get -n cattle-helm-system job/helm-delete-project-operator-example-chart-dummy --ignore-not-found; then
10+
if ! kubectl wait --for=condition=complete --timeout="${KUBECTL_WAIT_TIMEOUT}" -n cattle-helm-system job/helm-delete-project-operator-example-chart-dummy; then
11+
echo "ERROR: Helm Uninstall Job for Example Chart never completed after ${KUBECTL_WAIT_TIMEOUT}"
12+
kubectl logs job/helm-delete-project-operator-example-chart-dummy -n cattle-helm-system
13+
exit 1
14+
fi
15+
fi
16+
17+
echo "PASS: Removing ProjectHelmChart successfully uninstalled Example Chart"
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source $(dirname $0)/../entry
5+
6+
cd $(dirname $0)/../../../../..
7+
8+
latest_chart=./charts/helm-project-operator
9+
10+
case "${KUBERNETES_DISTRIBUTION_TYPE}" in
11+
"k3s")
12+
cluster_args=""
13+
kubernetes_version=$(kubectl version --short | grep "Server Version" | cut -d ' ' -f3)
14+
case "${kubernetes_version}" in
15+
v1.23.*)
16+
embedded_helm_controller_fixed_version="v1.23.14"
17+
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
18+
cluster_args="--set helmController.enabled=false"
19+
fi
20+
;;
21+
v1.24.*)
22+
embedded_helm_controller_fixed_version="v1.24.8"
23+
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
24+
cluster_args="--set helmController.enabled=false"
25+
fi
26+
;;
27+
*)
28+
embedded_helm_controller_fixed_version="v1.25.4"
29+
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
30+
cluster_args="--set helmController.enabled=false"
31+
fi
32+
;;
33+
esac
34+
;;
35+
"rke")
36+
cluster_args=""
37+
;;
38+
"rke2")
39+
cluster_args=""
40+
kubernetes_version=$(kubectl version --short | grep "Server Version" | cut -d ' ' -f3)
41+
case "${kubernetes_version}" in
42+
v1.23.*)
43+
embedded_helm_controller_fixed_version="v1.23.14"
44+
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
45+
cluster_args="--set helmController.enabled=false"
46+
fi
47+
;;
48+
v1.24.*)
49+
embedded_helm_controller_fixed_version="v1.24.8"
50+
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
51+
cluster_args="--set helmController.enabled=false"
52+
fi
53+
;;
54+
*)
55+
embedded_helm_controller_fixed_version="v1.25.4"
56+
if [[ $(echo ${kubernetes_version} ${embedded_helm_controller_fixed_version} | tr " " "\n" | sort -rV | head -n 1 ) == "${embedded_helm_controller_fixed_version}" ]]; then
57+
cluster_args="--set helmController.enabled=false"
58+
fi
59+
;;
60+
esac
61+
;;
62+
*)
63+
echo "KUBERNETES_DISTRIBUTION_TYPE=${KUBERNETES_DISTRIBUTION_TYPE} is unknown"
64+
exit 1
65+
esac
66+
67+
helm upgrade --install --create-namespace -n cattle-helm-system helm-project-operator --set image.repository=${REPO:-rancher}/helm-project-operator --set image.tag=${TAG:-dev} ${cluster_args} ${RANCHER_HELM_ARGS} ${latest_chart}
68+
69+
echo "PASS: Helm Project Operator has been installed"
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source $(dirname $0)/../entry
5+
6+
cd $(dirname $0)/../../../../..
7+
8+
helm uninstall --wait -n cattle-helm-system helm-project-operator
9+
10+
echo "PASS: Helm Project Operator has been uninstalled"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
set -e
3+
4+
source $(dirname $0)/../entry
5+
6+
cd $(dirname $0)/../../../../..
7+
8+
if ! kubectl -n cattle-helm-system rollout status deployment helm-project-operator --timeout="${KUBECTL_WAIT_TIMEOUT}"; then
9+
echo "ERROR: Helm Project Operator did not roll out"
10+
kubectl get pods -n cattle-helm-system -o yaml
11+
exit 1
12+
fi
13+
14+
echo "PASS: Helm Project Operator is up and running"

.github/workflows/hpo-e2e-ci.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: "[helm-project-operator] E2E Helm Project Operator"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
enable_tmate:
7+
description: 'Enable debugging via tmate'
8+
required: false
9+
default: "false"
10+
debug:
11+
description: "Enable debug logs"
12+
required: false
13+
default: "false"
14+
k3s_version:
15+
description: "Version of k3s to use for the underlying cluster, should exist in https://hub.docker.com/r/rancher/k3s/tags"
16+
required: false
17+
pull_request:
18+
paths-ignore:
19+
- 'docs/**'
20+
- 'scripts/**'
21+
- '*.md'
22+
- '*.dapper'
23+
- '.gitignore'
24+
- 'CODEOWNERS'
25+
- 'LICENSE'
26+
- 'Makefile'
27+
28+
env:
29+
CLUSTER_NAME: e2e-ci-helm-project-operator
30+
CGO_ENABLED: 0
31+
YQ_VERSION: v4.44.3
32+
E2E_CI: true
33+
REPO: rancher
34+
TAG: v0.0.0-dev.1
35+
APISERVER_PORT: 8001
36+
DEFAULT_SLEEP_TIMEOUT_SECONDS: 10
37+
KUBECTL_WAIT_TIMEOUT: 120s
38+
DEBUG: ${{ github.event.inputs.debug || false }}
39+
40+
permissions:
41+
contents: write
42+
43+
jobs:
44+
e2e-helm-project-operator:
45+
strategy:
46+
matrix:
47+
arch:
48+
- x64
49+
#- arm64
50+
k3s_version:
51+
# k3d version list k3s | sed 's/+/-/' | sort -h
52+
- ${{ github.event.inputs.k3s_version || 'v1.20.15-k3s1' }}
53+
runs-on : runs-on,image=ubuntu22-full-${{ matrix.arch }},runner=4cpu-linux-${{ matrix.arch }},run-id=${{ github.run_id }}
54+
env:
55+
K3S_VERSION: ${{ matrix.k3s_version }}
56+
steps:
57+
- uses: actions/checkout@v4
58+
with:
59+
fetch-depth: 0
60+
- name : setup Go
61+
uses : actions/setup-go@v5
62+
with:
63+
go-version: 1.22
64+
- name: Install mikefarah/yq
65+
run: |
66+
sudo wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${{ matrix.arch == 'x64' && 'amd64' || matrix.arch }} -O /usr/bin/yq && sudo chmod +x /usr/bin/yq;
67+
- name: Perform pre-e2e image build
68+
run: |
69+
BUILD_TARGET=helm-project-operator REPO=${REPO} TAG=${TAG} ./scripts/build;
70+
BUILD_TARGET=helm-project-operator REPO=${REPO} TAG=${TAG} ./scripts/package;
71+
- name : Install k3d
72+
run : ./.github/workflows/e2e/scripts/install-k3d.sh
73+
- name : Setup k3d cluster
74+
run : K3S_VERSION=${{ env.K3S_VERSION }} ./.github/workflows/e2e/scripts/setup-cluster.sh
75+
- name: Import Images Into k3d
76+
run: |
77+
k3d image import ${REPO}/helm-project-operator:${TAG} -c "$CLUSTER_NAME";
78+
- name: Setup kubectl context
79+
run: |
80+
kubectl config use-context "k3d-$CLUSTER_NAME";
81+
- name: Set Up Tmate Debug Session
82+
if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.enable_tmate == 'true' }}
83+
uses: mxschmitt/action-tmate@v3
84+
timeout-minutes: 15
85+
with:
86+
limit-access-to-actor: true
87+
- name: Install Helm Project Operator
88+
run: ./.github/workflows/e2e/scripts/hpo/install-helm-project-operator.sh;
89+
90+
- name: Check if Helm Project Operator is up
91+
run: ./.github/workflows/e2e/scripts/hpo/validate-helm-project-operator.sh;
92+
93+
- name: Check if Project Registration Namespace is auto-created on namespace detection
94+
run: ./.github/workflows/e2e/scripts/hpo/create-project-namespace.sh;
95+
96+
- name: Deploy Example Chart via ProjectHelmChart CR
97+
run: ./.github/workflows/e2e/scripts/hpo/create-projecthelmchart.sh;
98+
99+
- name: Delete Example Chart
100+
run: ./.github/workflows/e2e/scripts/hpo/delete-projecthelmchart.sh;
101+
102+
- name: Uninstall Helm Project Operator
103+
run: ./.github/workflows/e2e/scripts/hpo/uninstall-helm-project-operator.sh;
104+
105+
- name: Delete k3d cluster
106+
if: always()
107+
run: k3d cluster delete "$CLUSTER_NAME";

0 commit comments

Comments
 (0)