-
Notifications
You must be signed in to change notification settings - Fork 2
326 lines (323 loc) · 11.3 KB
/
test_publish.yml
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
name: Test, lint and publish
on:
push:
branches:
- main
tags:
- "v*"
pull_request:
branches:
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}
cancel-in-progress: true
env:
DEVCONTAINER_REGISTRY: ghcr.io
DEVCONTAINER_IMAGE_NAME: ${{ github.repository }}/devcontainer
DEVCONTAINER_IMAGE_TAG_MAIN: "cache-main"
CACHE_KEY: main-branch-poetry-cache-ubuntu
CACHE_PATH: .devcontainer/.poetry_cache
jobs:
build-devcontainer:
runs-on: ubuntu-latest
outputs:
image_repository: ${{ steps.docker_image.outputs.image_repository }}
image_tag: ${{ steps.docker_image.outputs.image_tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Docker image metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DEVCONTAINER_REGISTRY }}/${{ env.DEVCONTAINER_IMAGE_NAME }}
tags: |
type=ref,event=pr,prefix=cache-pr-,priority=600
type=ref,event=branch,prefix=cache-,priority=500
type=ref,event=tag,prefix=cache-,priority=500
flavor: |
latest=false
- name: Extract Docker image name
id: docker_image
env:
IMAGE_TAGS: ${{ steps.meta.outputs.tags }}
run: |
IMAGE=$(echo "$IMAGE_TAGS" | cut -d" " -f1)
IMAGE_REPOSITORY=$(echo "$IMAGE" | cut -d":" -f1)
IMAGE_TAG=$(echo "$IMAGE" | cut -d":" -f2)
echo "image=$IMAGE" >> "$GITHUB_OUTPUT"
echo "image_repository=$IMAGE_REPOSITORY" >> "$GITHUB_OUTPUT"
echo "image_tag=$IMAGE_TAG" >> "$GITHUB_OUTPUT"
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pre-build devcontainer
uses: devcontainers/[email protected]
continue-on-error: true
with:
push: always
skipContainerUserIdUpdate: false
imageName: ${{ steps.docker_image.outputs.image_repository }}
imageTag: ${{ steps.docker_image.outputs.image_tag }}
cacheFrom: |
${{ steps.docker_image.outputs.image_repository }}:${{ steps.docker_image.outputs.image_tag }}
${{ steps.docker_image.outputs.image_repository }}:${{ env.DEVCONTAINER_IMAGE_TAG_MAIN }}
style-checks:
runs-on: ubuntu-latest
needs:
- build-devcontainer
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache/restore@v4
name: Restore cache
with:
path: ${{ env.CACHE_PATH }}
key: ${{ env.CACHE_KEY }}
- name: Set Git config
shell: bash
run: |
git config --add user.name "Renku Bot"
git config --add user.email "[email protected]"
- name: Style checks
uses: devcontainers/[email protected]
with:
runCmd: make style_checks
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
optional-checks:
runs-on: ubuntu-latest
needs:
- build-devcontainer
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache/restore@v4
name: Restore cache
with:
path: ${{ env.CACHE_PATH }}
key: ${{ env.CACHE_KEY }}
- name: Set Git config
shell: bash
run: |
git config --add user.name "Renku Bot"
git config --add user.email "[email protected]"
- name: Check Avro Schemas are up to date
uses: devcontainers/[email protected]
with:
runCmd: make check_avro
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
test-main:
runs-on: ubuntu-latest
needs:
- build-devcontainer
- style-checks
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache/restore@v4
name: Restore cache
with:
path: ${{ env.CACHE_PATH }}
key: ${{ env.CACHE_KEY }}
- name: Set Git config
shell: bash
run: |
git config --add user.name "Renku Bot"
git config --add user.email "[email protected]"
- name: Test setup
uses: devcontainers/[email protected]
with:
runCmd: |
make test_setup
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
- name: Main tests
uses: devcontainers/[email protected]
with:
runCmd: |
make main_tests
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
- name: Combine coverage data
uses: devcontainers/[email protected]
with:
runCmd: |
make collect_coverage
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: run-main-tests
parallel: true
path-to-lcov: coverage.lcov
test-schemathesis:
runs-on: ubuntu-latest
needs:
- build-devcontainer
- style-checks
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache/restore@v4
name: Restore cache
with:
path: ${{ env.CACHE_PATH }}
key: ${{ env.CACHE_KEY }}
- name: Set Git config
shell: bash
run: |
git config --add user.name "Renku Bot"
git config --add user.email "[email protected]"
- name: Test setup
uses: devcontainers/[email protected]
with:
runCmd: |
make test_setup
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
- name: Schemathesis Tests
uses: devcontainers/[email protected]
with:
runCmd: |
make schemathesis_tests
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
env: |
HYPOTHESIS_PROFILE=ci
- name: Combine coverage data
uses: devcontainers/[email protected]
with:
runCmd: |
make collect_coverage
push: never
skipContainerUserIdUpdate: false
cacheFrom: ${{ needs.build-devcontainer.outputs.image_repository }}:${{ needs.build-devcontainer.outputs.image_tag }}
- name: Coveralls Parallel
uses: coverallsapp/github-action@v2
with:
flag-name: run-schemathesis-tests
parallel: true
path-to-lcov: coverage.lcov
coveralls:
needs:
- test-main
- test-schemathesis
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
COVERALLS_SERVICE_NAME: gihub-action
with:
parallel-finished: true
carryforward: "run-main-tests,run-schemathesis-tests"
continue-on-error: true
publish:
runs-on: ubuntu-latest
needs:
- test-main
- test-schemathesis
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta data services
id: meta
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
renku/renku-data-service
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.RENKU_DOCKER_USERNAME }}
password: ${{ secrets.RENKU_DOCKER_PASSWORD }}
- name: Build and push data services
uses: docker/build-push-action@v4
with:
context: .
file: ./projects/renku_data_service/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=registry,ref=renku/renku-data-service:buildcache
cache-to: type=registry,ref=renku/renku-data-service:buildcache,mode=max
- name: Docker meta background jobs
id: meta-background-jobs
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
renku/data-service-background-jobs
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and push background jobs
uses: docker/build-push-action@v4
with:
context: .
file: ./projects/background_jobs/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-background-jobs.outputs.tags }}
labels: ${{ steps.meta-background-jobs.outputs.labels }}
cache-from: type=registry,ref=renku/data-service-background-jobs:buildcache
cache-to: type=registry,ref=renku/data-service-background-jobs:buildcache,mode=max
- name: Docker meta secrets
id: meta-secrets-storage
uses: docker/metadata-action@v5
with:
# list of Docker images to use as base name for tags
images: |
renku/secrets-storage
# generate Docker tags based on the following events/attributes
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Build and push secrets image
uses: docker/build-push-action@v4
with:
context: .
file: ./projects/secrets_storage/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-secrets-storage.outputs.tags }}
labels: ${{ steps.meta-secrets-storage.outputs.labels }}
cache-from: type=registry,ref=renku/secrets-storage:buildcache
cache-to: type=registry,ref=renku/secrets-storage:buildcache,mode=max