generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (121 loc) · 4.51 KB
/
ci-e2e-test.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: E2E Workflow
on:
workflow_dispatch:
pull_request:
paths:
- 'pkg/**'
- 'e2e/**'
- 'cmd/**'
- 'Dockerfile*'
- 'go.mod'
- 'go.sum'
jobs:
init:
outputs:
tests: ${{ steps.e2es.outputs.result }}
runs-on: [ default ]
name: "Prepare E2E Scenarios"
steps:
- name: "Checkout"
uses: actions/checkout@v4
# find all e2e scenarios in the e2e directory and generate an array of scenario names
- name: "E2E Detection"
id: e2es
run: |
scenarios=$(find ${GITHUB_WORKSPACE}/e2e -type f -name 'e2e_test.go' -exec dirname {} \; | xargs -n 1 basename | jq -R -s -c 'split("\n")[:-1]')
echo $scenarios
echo "result=$scenarios" >> $GITHUB_OUTPUT
e2e:
name: "Run ${{ matrix.e2es }}(${{ matrix.k8s-version}}) E2E"
if: needs.init.outputs.tests != '[]'
needs: [ init ]
runs-on: [ default ]
env:
ADMIN_CLUSTER: greenhouse-admin
REMOTE_CLUSTER: greenhouse-remote
strategy:
fail-fast: false
matrix:
k8s-version: [ "v1.29.8", "v1.30.4", "v1.31.0" ]
e2es: ${{fromJson(needs.init.outputs.tests)}}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
token: ${{ secrets.GITHUB_TOKEN }}
# Create the admin cluster with latest kubernetes version
- name: Create Admin Cluster
uses: helm/[email protected]
with:
cluster_name: ${{ env.ADMIN_CLUSTER }}
node_image: 'kindest/node:v1.31.0'
# Create the remote cluster with kubernetes version from the matrix
- name: Create Remote Cluster
uses: helm/[email protected]
with:
node_image: 'kindest/node:${{ matrix.k8s-version }}'
cluster_name: ${{ env.REMOTE_CLUSTER }}
config: ${{ github.workspace }}/e2e/kind-config.yaml
# build CLI, setup e2e environment and prepare kubeconfigs
- name: "Prepare E2E Config"
id: config
run: |
make setup-e2e
echo "admin_config=$GITHUB_WORKSPACE/bin/${{env.ADMIN_CLUSTER}}.kubeconfig" >> $GITHUB_OUTPUT
echo "remote_config=$GITHUB_WORKSPACE/bin/${{env.REMOTE_CLUSTER}}.kubeconfig" >> $GITHUB_OUTPUT
echo "remote_int_config=$GITHUB_WORKSPACE/bin/${{env.REMOTE_CLUSTER}}-int.kubeconfig" >> $GITHUB_OUTPUT
# run the e2e tests with the scenario from the matrix
- name: "E2E Run"
id: e2e
continue-on-error: true
env:
SCENARIO: ${{ matrix.e2es }}
EXECUTION_ENV: gh-actions
GREENHOUSE_ADMIN_KUBECONFIG: ${{ steps.config.outputs.admin_config }}
GREENHOUSE_REMOTE_KUBECONFIG: ${{ steps.config.outputs.remote_config }}
GREENHOUSE_REMOTE_INT_KUBECONFIG: ${{ steps.config.outputs.remote_int_config }}
CONTROLLER_LOGS_PATH: ${{github.workspace}}/bin/${{matrix.e2es}}-${{matrix.k8s-version}}.txt
E2E_REPORT_PATH: ${{github.workspace}}/bin/${{matrix.e2es}}-${{matrix.k8s-version}}.json
run: |
echo "result=$CONTROLLER_LOGS_PATH" >> $GITHUB_OUTPUT
make e2e
# v4 upload-artifact needs unique names for each artifact (see https://github.com/actions/upload-artifact/tree/main?tab=readme-ov-file#not-uploading-to-the-same-artifact)
- name: "Upload E2E Logs"
uses: actions/upload-artifact@v4
if: ${{ steps.e2e.outputs.result != '' }} # skip if nothing needs to be uploaded
with:
name: e2e-logs-${{ matrix.e2es }}-${{ matrix.k8s-version }}
path: ${{steps.e2e.outputs.result}}
retention-days: 7
if-no-files-found: ignore
artifacts:
name: "Merge Artifacts"
runs-on: [ default ]
needs: [ e2e ]
steps:
- name: "Merge Uploads"
continue-on-error: true # If there are no artifacts available, the merge step will fail so we need to continue on error
uses: actions/upload-artifact/merge@v4
with:
name: e2e-logs
pattern: e2e-logs-*
retention-days: 7
delete-merged: true
# check if the e2e tests passed for all scenarios
checksOK:
name: "E2E Check"
needs: [ artifacts, e2e ]
runs-on: [ default ]
if: always()
steps:
- name: "Check if e2e passed"
run: |
if [ "${{ needs.e2e.result }}" == "success" ]; then
echo "✅ E2E passed 🎉"
else
echo "❌ E2E failed 😭"
exit 1
fi