-
Notifications
You must be signed in to change notification settings - Fork 42
355 lines (301 loc) · 10.1 KB
/
ci.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
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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
---
name: CI Workflow
on:
push:
branches:
- main
schedule:
- cron: "5 0 * * *" # TODO: Run every 4 hours to soak test, should be less frequent before merge (weekly/daily/???)
workflow_dispatch:
env:
IMAGE_NAME: cluster-api-provider-packet
GHCR_REGISTRY: ghcr.io/${{ github.repository_owner }}
DOCKER_REGISTRY: ${{ secrets.DOCKER_ORG }}
QUAY_REGISTRY: quay.io/${{ secrets.QUAY_ORG }}
REGISTRY: quay.io/${{ secrets.QUAY_ORG }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
validate:
name: "Validate ${{ matrix.target }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
target: ["verify", "lint", "test"]
steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: ${{ matrix.target }}
run: make ${{ matrix.target }}
build-image:
name: Build and Push Image
runs-on: ubuntu-latest
permissions:
packages: write # needed to push docker image to ghcr.io
pull-requests: write # needed to create and update comments in PRs
steps:
- name: Checkout git repo
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to ghcr.io registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Log into DockerHub
uses: docker/login-action@v3
env:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
if: ${{ env.DOCKER_USERNAME != '' }}
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log into quay.io
uses: docker/login-action@v3
env:
QUAY_USERNAME: ${{ secrets.QUAY_USERNAME }}
if: ${{ env.QUAY_USERNAME != '' }}
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.QUAY_REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.DOCKER_REGISTRY }}/${{ env.IMAGE_NAME }}
flavor: |
latest=false
tags: |
type=semver,pattern={{version}}
type=edge
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha,priority=1001
- name: Docker Build and Push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64, linux/arm64
# If PR, put image tags in the PR comments
# from https://github.com/marketplace/actions/create-or-update-comment
- name: Find comment for image tags
uses: peter-evans/find-comment@v3
if: github.event_name == 'pull_request'
id: fc
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: Docker image tag(s) pushed
# If PR, put image tags in the PR comments
- name: Create or update comment for image tags
uses: peter-evans/create-or-update-comment@v4
if: github.event_name == 'pull_request'
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body: |
Docker image tag(s) pushed:
```text
${{ steps.docker_meta.outputs.tags }}
```
Labels added to images:
```text
${{ steps.docker_meta.outputs.labels }}
```
edit-mode: replace
outputs:
image-tag: "${{ steps.docker_meta.outputs.version }}"
release-manifests:
name: Make Release Manifests
runs-on: ubuntu-latest
needs: [build-image]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Make Release
run: make release
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: release-manifests
path: out/release
e2e-quickstart:
name: "E2E quickstart"
concurrency: ci-${{ github.ref }}-e2e-quickstart
runs-on: ubuntu-latest
needs: [build-image, release-manifests]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: release-manifests
path: out/release
- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
- name: "e2e-quickstart"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
SKIP_IMAGE_BUILD: "1"
MANIFEST_PATH: "../../../out/release"
METRO: da
CONTROLPLANE_NODE_TYPE: c3.medium.x86
WORKER_NODE_TYPE: c3.medium.x86
GINKGO_NODES: "1"
run: ./scripts/ci-e2e-capi-quickstart.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-quickstart
path: _artifacts
e2e:
name: "E2E"
concurrency: ci-${{ github.ref }}-e2e
runs-on: ubuntu-latest
needs: [build-image, release-manifests]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: release-manifests
path: out/release
- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
- name: "e2e"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
SKIP_IMAGE_BUILD: "1"
MANIFEST_PATH: "../../../out/release"
METRO: da
CONTROLPLANE_NODE_TYPE: c3.medium.x86
WORKER_NODE_TYPE: c3.medium.x86
GINKGO_NODES: "1"
run: ./scripts/ci-e2e-capi.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e
path: _artifacts
e2e-conformance:
name: "E2E conformance"
concurrency: ci-${{ github.ref }}-e2e-conformance
runs-on: ubuntu-latest
needs: [build-image, release-manifests]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: release-manifests
path: out/release
- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
- name: "e2e-conformance"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
SKIP_IMAGE_BUILD: "1"
MANIFEST_PATH: "../../../out/release"
METRO: da
CONTROLPLANE_NODE_TYPE: c3.medium.x86
WORKER_NODE_TYPE: c3.medium.x86
GINKGO_NODES: "1"
run: ./scripts/ci-e2e-capi-conformance.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-conformance
path: _artifacts
e2e-workload-upgrade:
name: "E2E Workload-Upgrade"
concurrency: ci-${{ github.ref }}-e2e-workload-upgrade
runs-on: ubuntu-latest
needs: [build-image, release-manifests]
env:
TAG: ${{ needs.build-image.outputs.image-tag }}
steps:
- name: checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: "./go.mod"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: release-manifests
path: out/release
- name: Prepull the pre-built image
run: docker pull ${REGISTRY}/${IMAGE_NAME}:${TAG}
- name: "e2e-workload-upgrade"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKET_API_KEY: ${{ secrets.PACKET_API_TOKEN }}
PROJECT_ID: ${{ secrets.PROJECT_ID }}
E2E_CONF_FILE_SOURCE: "${{ github.workspace }}/test/e2e/config/packet-ci-actions.yaml"
SKIP_IMAGE_BUILD: "1"
MANIFEST_PATH: "../../../out/release"
METRO: da
CONTROLPLANE_NODE_TYPE: c3.medium.x86
WORKER_NODE_TYPE: c3.medium.x86
GINKGO_NODES: "1"
run: ./scripts/ci-e2e-capi-workload-upgrade.sh
- name: Upload artifact
uses: actions/upload-artifact@v4
if: ${{ always() }}
with:
name: e2e-workload-upgrade
path: _artifacts