-
Notifications
You must be signed in to change notification settings - Fork 1
216 lines (167 loc) · 5.57 KB
/
ccm-integration-tests.yml
File metadata and controls
216 lines (167 loc) · 5.57 KB
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
name: CCM Integration Tests
on:
push:
branches:
- main
pull_request:
# Allow to run this workflow manually from the Actions tab
workflow_dispatch:
# Run this regularly, to get integration tests results against new
# Kubernetes releases.
schedule:
- cron: '15 3 * * *'
permissions:
contents: read
env:
GO_VERSION: 1.25
jobs:
lint:
name: "Run Linters"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- uses: actions/setup-go@4dc6199c7b1a012772edbd06daecab0f50c9053c # v6.1.0
with:
go-version: '${{ env.GO_VERSION }}'
- name: Restore cache
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cache/golangci-lint
~/.cache/go-build
key: lint-${{ hashFiles('go.mod') }}
- name: Install go tools
run: go mod tidy -modfile tool.mod
- name: Run Linter
run: make lint
- name: Save cache
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: |
~/.cache/golangci-lint
~/.cache/go-build
key: lint-${{ hashFiles('go.mod') }}
unit:
name: "Run Unit Tests"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: '${{ env.GO_VERSION }}'
- name: Run Unit Tests
run: make test
test-matrix:
name: "Get Kubernetes Releases"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- name: "Generate Test Matrix"
id: list
run: 'echo "tests=$(helpers/test-matrix)" >> $GITHUB_OUTPUT'
outputs:
tests: ${{ steps.list.outputs.tests }}
build-image:
name: "Build Container Image"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- name: Evaluate image name
run: 'helpers/image-from-ref >> $GITHUB_ENV'
- name: Build image
run: 'docker build --platform=linux/amd64 --tag "$IMAGE" .'
- name: Export image
run: 'docker image save "$IMAGE" -o image.tar'
- name: Store hash
run: 'shasum -a 256 image.tar | tee image.tar.sha256'
- name: Store image
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: tested-image
path: |
image.tar
image.tar.sha256
retention-days: 30d
integration:
name: "Kubernetes ${{ matrix.kubernetes }}"
runs-on: ubuntu-latest
needs:
- lint
- unit
- test-matrix
- build-image
strategy:
fail-fast: false
max-parallel: 1
matrix:
include: "${{ fromJson(needs.test-matrix.outputs.tests) }}"
env:
CLOUDSCALE_API_TOKEN: ${{ secrets.CLOUDSCALE_API_TOKEN }}
HTTP_ECHO_BRANCH: ${{ vars.HTTP_ECHO_BRANCH }}
KUBERNETES: '${{ matrix.kubernetes }}'
SUBNET: '${{ matrix.subnet }}'
CLUSTER_PREFIX: '${{ matrix.cluster_prefix }}'
IMAGE_SOURCE: import
# Prevent integration tests from running in parallel. Ideally this should
# be seuqential, but that won't work due to the following issue:
#
# https://github.com/orgs/community/discussions/5435
#
# Instead we ensure that only one integration test per supported version
# is run at any given time.
concurrency:
group: integration-${{ matrix.kubernetes }}
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- name: Load image
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
with:
name: tested-image
- name: Validate hash
run: 'shasum --check image.tar.sha256'
- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5.6.0
with:
go-version: '${{ env.GO_VERSION }}'
- name: Evaluate image name
run: 'helpers/image-from-ref >> $GITHUB_ENV'
- name: Cleanup Leftovers
if: always()
run: helpers/cleanup
- name: Create Test Cluster
run: helpers/run-in-test-cluster
- name: Wait For CCM Startup
run: sleep 60
- name: Run Integration Tests
run: make integration
- name: Wait For Kubernetes-Internal Cleanup
if: always()
run: sleep 30
- name: Destroy Test Cluster
if: always()
run: helpers/cleanup
validate-workflows:
name: Validate GitHub Workflows
runs-on: ubuntu-latest
# More Information:
# https://github.com/zizmorcore/zizmor-action?tab=readme-ov-file#usage-with-github-advanced-security-recommended
#
# Use `uvx zizmor .github/` for a local preview using the latest zizmor version.
permissions:
contents: read
security-events: write
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
with:
persist-credentials: false
- name: Run zizmor 🌈
uses: zizmorcore/zizmor-action@e639db99335bc9038abc0e066dfcd72e23d26fb4 # v0.3.0