-
Notifications
You must be signed in to change notification settings - Fork 5
423 lines (367 loc) · 13.6 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
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
---
name: CI
on: # yamllint disable-line rule:truthy
workflow_dispatch:
push:
branches: [main, devel]
tags:
- 'v*.*.*'
pull_request:
branches: [main, devel]
env:
REGISTRY: ghcr.io
IMAGE_BASE_NAME: ${{ github.repository_owner }}/dse
PACKAGE_VERSION: 0.0.2
package_name: ModelC
build_dir: dse/modelc/build
CCACHE_SECONDARY_STORAGE: ${{ secrets.CCACHE_SECONDARY_STORAGE }}
jobs:
build:
runs-on: [ubuntu-latest]
strategy:
matrix:
package_arch:
- linux-amd64
- linux-x86
- linux-i386
- windows-x64
- windows-x86
container:
image: ghcr.io/boschglobal/dse-gcc-builder:main
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build package metadata
id: package_meta
uses: docker/metadata-action@v5
with:
images: dse/modelc
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Get package version
if: startsWith(github.ref, 'refs/tags/')
id: package
run: |
echo "PACKAGE_VERSION=${{ fromJSON(steps.package_meta.outputs.json).labels['org.opencontainers.image.version'] }}" >> $GITHUB_ENV
- name: Build
env:
PACKAGE_ARCH: ${{ matrix.package_arch }}
run: |
make
- name: Test
if: ${{ matrix.package_arch == 'linux-amd64' }}
env:
PACKAGE_ARCH: ${{ matrix.package_arch }}
run: |
make test_cmocka
- name: Stats
run: |
ccache -s -v || true
- name: Package
env:
PACKAGE_ARCH: ${{ matrix.package_arch }}
run: |
make package
tar -czf sandbox_out.tar.gz -C . ${{ env.build_dir }}/_out
- uses: actions/upload-artifact@v3
with:
name: ${{ env.package_name }}-${{ matrix.package_arch }}-package
path: |
${{ env.build_dir }}/_dist/${{ env.package_name }}-${{ env.PACKAGE_VERSION }}-${{ matrix.package_arch }}.tar.gz
${{ env.build_dir }}/_dist/${{ env.package_name }}-${{ env.PACKAGE_VERSION }}-${{ matrix.package_arch }}.zip
retention-days: 1
- uses: actions/upload-artifact@v3
with:
name: ${{ env.package_name }}-${{ matrix.package_arch }}-sandbox
path: |
sandbox_out.tar.gz
retention-days: 1
test_e2e:
runs-on: [ubuntu-latest]
needs: [build, runtimes, tools]
container:
image: ghcr.io/boschglobal/dse-testscript:latest
volumes:
- /var/run/docker.sock:/var/run/docker.sock
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: image_simer
path: /tmp
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: image_testscript
path: /tmp
- name: Load images
run: |
docker load --input /tmp/simer.tar
docker load --input /tmp/testscript.tar
docker image ls -a
- uses: actions/download-artifact@v3
with:
name: ${{ env.package_name }}-linux-amd64-sandbox
path: .
- name: Sandbox
run: |
tar xzf sandbox_out.tar.gz
find ${{ env.build_dir }}/_out -type f -name '*' -exec ls -sh --color=auto {} \;
- name: Set environment
run: |
echo "HOST_DOCKER_WORKSPACE=${{ github.workspace }}" >> $GITHUB_ENV
- name: Test
run: |
export HOST_DOCKER_WORKSPACE=${{ env.HOST_DOCKER_WORKSPACE }}
make test_e2e
publish:
if: startsWith(github.ref, 'refs/tags/')
runs-on: [ubuntu-latest]
needs: [build, test_e2e]
strategy:
matrix:
package_arch:
- linux-amd64
- linux-x86
- linux-i386
- windows-x64
- windows-x86
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Build package metadata
id: package_meta
uses: docker/metadata-action@v5
with:
images: dse/modelc
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
- name: Get package version
if: startsWith(github.ref, 'refs/tags/')
id: package
run: |
echo "PACKAGE_VERSION=${{ fromJSON(steps.package_meta.outputs.json).labels['org.opencontainers.image.version'] }}" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: ${{ env.package_name }}-${{ matrix.package_arch }}-package
path: ${{ env.build_dir }}/_dist
- name: Publish
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
${{ env.build_dir }}/_dist/${{ env.package_name }}-${{ env.PACKAGE_VERSION }}-${{ matrix.package_arch }}.zip
docker_push:
if: startsWith(github.ref, 'refs/tags/')
runs-on: [ubuntu-latest]
needs: [runtimes, tools, test_e2e]
strategy:
matrix:
container:
- simer
- testscript
steps:
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: image_${{ matrix.container }}
path: /tmp
- name: Load and Push Image
run: |
docker load --input /tmp/${{ matrix.container }}.tar
docker image ls -a
docker image push --all-tags ${{ env.REGISTRY }}/${{ env.IMAGE_BASE_NAME }}-${{ matrix.container }}
runtimes:
if: startsWith(github.ref, 'refs/tags/')
runs-on: [ubuntu-latest]
needs: [build]
strategy:
matrix:
container:
- testscript
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE_NAME }}-${{ matrix.container }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Version
if: startsWith(github.ref, 'refs/tags/')
id: package
run: |
echo "PACKAGE_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}" >> $GITHUB_ENV
- name: Build Image
uses: docker/build-push-action@v4
with:
push: false
context: .
file: ./extra/docker/${{ matrix.container }}/Dockerfile
build-args: |
PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/${{ matrix.container }}.tar
- name: Upload image artifact
uses: actions/upload-artifact@v3
with:
name: image_${{ matrix.container }}
path: /tmp/${{ matrix.container }}.tar
retention-days: 1
tools:
if: startsWith(github.ref, 'refs/tags/')
runs-on: [ubuntu-latest]
needs: [build]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE_NAME }}-simer
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Version
if: startsWith(github.ref, 'refs/tags/')
id: package
run: |
echo "PACKAGE_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: ${{ env.package_name }}-linux-amd64-sandbox
path: sandbox/ModelC-linux-amd64-sandbox
- uses: actions/download-artifact@v3
with:
name: ${{ env.package_name }}-linux-x86-sandbox
path: sandbox/ModelC-linux-x86-sandbox
- uses: actions/download-artifact@v3
with:
name: ${{ env.package_name }}-linux-i386-sandbox
path: sandbox/ModelC-linux-i386-sandbox
- name: Sandbox
run: |
(cd sandbox/${{ env.package_name }}-linux-amd64-sandbox; tar xzf sandbox_out.tar.gz)
(cd sandbox/${{ env.package_name }}-linux-x86-sandbox; tar xzf sandbox_out.tar.gz)
(cd sandbox/${{ env.package_name }}-linux-i386-sandbox; tar xzf sandbox_out.tar.gz)
mkdir -p extra/tools/simer/build/stage/bin
mkdir -p extra/tools/simer/build/stage/lib
mkdir -p extra/tools/simer/build/stage/lib32
cp sandbox/${{ env.package_name }}-linux-amd64-sandbox/${{ env.build_dir }}/_out/bin/simbus extra/tools/simer/build/stage/bin/simbus
cp sandbox/${{ env.package_name }}-linux-amd64-sandbox/${{ env.build_dir }}/_out/bin/modelc extra/tools/simer/build/stage/bin/modelc
cp sandbox/${{ env.package_name }}-linux-amd64-sandbox/${{ env.build_dir }}/_out/lib/mcl_model.so extra/tools/simer/build/stage/lib/mcl_model.so
cp sandbox/${{ env.package_name }}-linux-x86-sandbox/${{ env.build_dir }}/_out/bin/modelc extra/tools/simer/build/stage/bin/modelc32
cp sandbox/${{ env.package_name }}-linux-x86-sandbox/${{ env.build_dir }}/_out/bin/modelc extra/tools/simer/build/stage/bin/modelc32_x86
cp sandbox/${{ env.package_name }}-linux-x86-sandbox/${{ env.build_dir }}/_out/lib/mcl_model.so extra/tools/simer/build/stage/lib32/mcl_model.so
cp sandbox/${{ env.package_name }}-linux-x86-sandbox/${{ env.build_dir }}/_out/lib/mcl_model.so extra/tools/simer/build/stage/lib32/mcl_model_x86.so
cp sandbox/${{ env.package_name }}-linux-i386-sandbox/${{ env.build_dir }}/_out/bin/modelc extra/tools/simer/build/stage/bin/modelc32_i386
cp sandbox/${{ env.package_name }}-linux-i386-sandbox/${{ env.build_dir }}/_out/lib/mcl_model.so extra/tools/simer/build/stage/lib32/mcl_model_i386.so
cp -r sandbox/${{ env.package_name }}-linux-amd64-sandbox/${{ env.build_dir }}/_out/licenses -t extra/tools/simer/build/stage
ls -R extra/tools/simer/build/stage
- name: Build and push
uses: docker/build-push-action@v4
with:
push: false
context: extra/tools/simer
file: ./extra/tools/simer/build/package/Dockerfile
build-args: |
PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=docker,dest=/tmp/simer.tar
- name: Upload image artifact
uses: actions/upload-artifact@v3
with:
name: image_simer
path: /tmp/simer.tar
retention-days: 1
containers:
if: startsWith(github.ref, 'refs/tags/')
runs-on: [ubuntu-latest]
needs: [build, test_e2e]
strategy:
matrix:
name: [modelc]
arch: [linux-amd64]
include:
- name: modelc
arch: linux-amd64
- name: modelc-x86
arch: linux-x86
- name: simbus-sa
arch: linux-amd64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_BASE_NAME }}-${{ matrix.name }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Version
if: startsWith(github.ref, 'refs/tags/')
id: package
run: |
echo "PACKAGE_VERSION=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}" >> $GITHUB_ENV
- uses: actions/download-artifact@v3
with:
name: ${{ env.package_name }}-${{ matrix.arch }}-sandbox
path: .
- name: Sandbox
run: |
tar xzf sandbox_out.tar.gz
find ${{ env.build_dir }}/_out -type f -name '*' -exec ls -sh --color=auto {} \;
- name: Build and push
uses: docker/build-push-action@v4
with:
push: true
context: .
file: ./extra/docker/${{ matrix.name }}/Dockerfile
build-args: |
PACKAGE_VERSION=${{ env.PACKAGE_VERSION }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}