generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
122 lines (108 loc) · 3.92 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
name: E2E Workflow
on:
workflow_dispatch:
pull_request:
paths:
- 'pkg/**'
- 'e2e/**'
- 'cmd/**'
- 'Dockerfile*'
- 'go.mod'
- 'go.sum'
- '.golangci.yaml'
jobs:
init:
outputs:
tests: ${{ steps.e2es.outputs.result }}
runs-on: [ default ]
name: "Prepare E2E Scenarios"
steps:
- name: "Checkout"
uses: actions/checkout@v4
- 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"]
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.GO_MODULE_TOKEN }}
- name: Create Admin Cluster
uses: helm/[email protected]
with:
version: 'v0.24.0'
cluster_name: ${{ env.ADMIN_CLUSTER }}
- name: Create Remote Cluster
uses: helm/[email protected]
with:
version: 'v0.24.0'
node_image: 'kindest/node:${{ matrix.k8s-version }}'
cluster_name: ${{ env.REMOTE_CLUSTER }}
config: ${{ github.workspace }}/e2e/kind-config.yaml
- name: "Prepare E2E Config"
id: config
run: |
make cli
${{ github.workspace }}/bin/greenhousectl dev setup -f ${{ github.workspace }}/e2e/config.json
kind get kubeconfig --name ${{ env.ADMIN_CLUSTER}} > ${{ github.workspace }}/bin/${{env.ADMIN_CLUSTER}}.kubeconfig
kind get kubeconfig --name ${{ env.REMOTE_CLUSTER}} > ${{ github.workspace }}/bin/${{env.REMOTE_CLUSTER}}.kubeconfig
kind get kubeconfig --name ${{ env.REMOTE_CLUSTER}} --internal > ${{ github.workspace }}/bin/${{env.REMOTE_CLUSTER}}-int.kubeconfig
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
- name: "E2E Run"
id: e2e
continue-on-error: true
working-directory: ${{ github.workspace }}/e2e
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}}.txt
run: |
go install github.com/onsi/ginkgo/v2/ginkgo@latest
ginkgo version
make e2e
echo "result=$CONTROLLER_LOGS_PATH" >> $GITHUB_OUTPUT
- name: "Upload Logs"
uses: actions/upload-artifact@v3
with:
name: e2e-logs
path: ${{steps.e2e.outputs.result}}
retention-days: 7
if-no-files-found: ignore
checksOK:
name: "E2E Check"
needs: [ 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