forked from FraunhoferISST/DataspaceConnector
-
Notifications
You must be signed in to change notification settings - Fork 29
368 lines (342 loc) · 13.2 KB
/
ci.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
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
name: CI
on:
pull_request:
branches: [ main ]
paths-ignore:
- 'docs/**'
concurrency:
group: ${{ github.head_ref }}
cancel-in-progress: true
jobs:
setup:
timeout-minutes: 5
runs-on: ubuntu-latest
outputs:
branch_name: ${{ steps.get_branch_name.outputs.HEAD_REF }}
steps:
- name: Build branch name
id: get_branch_name
run: |
HEAD_REF=$(echo "${GITHUB_HEAD_REF}" | sed 's_/_\-_g' )
echo ::set-output name=HEAD_REF::"${HEAD_REF}"
style:
needs: [setup]
timeout-minutes: 5
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Cache maven packages
uses: actions/[email protected]
with:
path: ~/.m2
key: ${{ runner.os }}-${{ needs.setup.outputs.branch_name }}-style-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ needs.setup.outputs.branch_name }}-style-
- name: Run style checks
run: mvn -B checkstyle:check --file pom.xml
static-code-analysis:
needs: [setup, style]
timeout-minutes: 5
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Cache maven packages
uses: actions/[email protected]
with:
path: ~/.m2
key: ${{ runner.os }}-${{ needs.setup.outputs.branch_name }}-analysis-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ needs.setup.outputs.branch_name }}-analysis-
- name: Run static code analysis
run: mvn -B compile spotbugs:check --file pom.xml
unit-and-integration-tests:
needs: [setup, style]
timeout-minutes: 30
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
java: [17]
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: ${{ matrix.java }}
- name: Cache maven packages
uses: actions/[email protected]
with:
path: ~/.m2
key: ${{ runner.os }}-${{ needs.setup.outputs.branch_name }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ needs.setup.outputs.branch_name }}-m2-
- name: Unit- and Integrationtests
run: mvn -B -U verify --file pom.xml -Prelease
mutation-tests:
needs: [setup, unit-and-integration-tests]
timeout-minutes: 30
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'
- name: Cache maven packages
uses: actions/[email protected]
with:
path: ~/.m2
key: ${{ runner.os }}-${{ needs.setup.outputs.branch_name }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-${{ needs.setup.outputs.branch_name }}-m2-
- name: Run Mutation Tests
run: mvn -B -Dmaven.javadoc.skip=true test org.pitest:pitest-maven:mutationCoverage --file pom.xml
linting:
timeout-minutes: 5
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v3
- name: Lint Docker
uses: hadolint/[email protected]
with:
dockerfile: Dockerfile
config: .hadolint.yaml
build_test_image:
needs: [linting, unit-and-integration-tests]
timeout-minutes: 15
runs-on: ubuntu-latest
outputs:
image_artifact_name: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}
image_name: ${{ steps.get_image_name.outputs.image_name }}
steps:
- name: Install SBoM generator
run: |
SYFT_EXPECTED_DIGEST='74a9becd5ccb4c02de99050a632e7bfc72176d5e4e844093b1e2c5bedfb45888'
curl -sSfL https://github.com/anchore/syft/releases/download/v0.29.0/syft_0.29.0_linux_amd64.tar.gz -o syft.tar.gz
SYFT_RESULT_DIGEST=$(sha256sum syft.tar.gz | cut -d' ' -f1);
if [[ $SYFT_RESULT_DIGEST != "${SYFT_EXPECTED_DIGEST}" ]]; then exit 1; fi
mkdir -p syft-install/
tar -zxf syft.tar.gz -C syft-install/
mv syft-install/syft /usr/local/bin/
rm -rf syft.tar.gz syft-install/
- name: Install SBom pusher
run: |
ORAS_EXPECTED_DIGEST='660a4ecd87414d1f29610b2ed4630482f1f0d104431576d37e59752c27de37ed'
curl -sSfL https://github.com/oras-project/oras/releases/download/v0.12.0/oras_0.12.0_linux_amd64.tar.gz -o oras.tar.gz
ORAS_RESULT_DIGEST=$(sha256sum oras.tar.gz | cut -d' ' -f1);
if [[ $ORAS_RESULT_DIGEST != "${ORAS_EXPECTED_DIGEST}" ]]; then exit 1; fi
mkdir -p oras-install/
tar -zxf oras.tar.gz -C oras-install/
mv oras-install/oras /usr/local/bin/
rm -rf oras.tar.gz oras-install/
- name: Checkout Repo
uses: actions/checkout@v3
- name: Build image artifact name
id: get_image_artifact_name
run: |
IMAGE_ARTIFACT_NAME=$(echo "${GITHUB_HEAD_REF}" | sed 's_/_\-_g' )
echo ::set-output name=image_artifact_name::"${IMAGE_ARTIFACT_NAME}"
- name: Build image name
id: get_image_name
run: echo ::set-output name=image_name::"ghcr.io/international-data-spaces-association/dataspace-connector"
- name: Build image
run: |
docker build . -t "${IMAGE}:ci"
env:
IMAGE: ${{ steps.get_image_name.outputs.image_name }}
DOCKER_BUILDKIT: 1
- name: Generate SBoM
run: |
BOM="${ARTIFACT}-sbom.json"
syft "${IMAGE}:ci" -o spdx-json > "${BOM}"
env:
IMAGE: ${{ steps.get_image_name.outputs.image_name }}
ARTIFACT: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}
- name: Build tar ball
id: build_tar_ball
run: |
docker save --output "${ARTIFACT}.tar" "${IMAGE}:ci"
env:
IMAGE: ${{ steps.get_image_name.outputs.image_name }}
ARTIFACT: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}
- name: Push image
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}-image
path: ${{ github.workspace }}/${{ steps.get_image_artifact_name.outputs.image_artifact_name }}.tar
retention-days: 1
- name: Push SBoM
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}-image-sbom.json
path: ${{ github.workspace }}/${{ steps.get_image_artifact_name.outputs.image_artifact_name }}-sbom.json
retention-days: 1
image-security-scan:
needs: [build_test_image]
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
steps:
- name: Download image
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_test_image.outputs.image_artifact_name }}-image
- name: Load image into docker
run: docker load --input "${GITHUB_WORKSPACE}/${ARTIFACT}.tar"
env:
ARTIFACT: ${{ needs.build_test_image.outputs.image_artifact_name }}
- name: Checkout Repo
uses: actions/checkout@v3
- name: Run vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: '${{ needs.build_test_image.outputs.image_name }}:ci'
format: 'table'
exit-code: '1'
ignore-unfixed: true
vuln-type: 'os,library'
severity: 'UNKNOWN,LOW,MEDIUM,HIGH,CRITICAL'
timeout: "9m0s"
build_test_backend_image:
needs: [linting, unit-and-integration-tests]
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
outputs:
image_artifact_name: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}
image_name: ${{ steps.get_image_name.outputs.image_name }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Build image artifact name
id: get_image_artifact_name
run: |
IMAGE_ARTIFACT_NAME=$(echo "${GITHUB_HEAD_REF}" | sed 's_/_\-_g' )-backend
echo ::set-output name=image_artifact_name::"${IMAGE_ARTIFACT_NAME}"
- name: Build image name
id: get_image_name
run: echo ::set-output name=image_name::"ghcr.io/international-data-spaces-association/dataspace-connector/tests/route-backend"
- name: Build image
run: |
cd ./scripts/tests/route-backend/
docker build . -t "${IMAGE}" -f route-backend.dockerfile
env:
IMAGE: ${{ steps.get_image_name.outputs.image_name }}
DOCKER_BUILDKIT: 1
- name: Build tar ball
id: build_tar_ball
run: |
docker save --output "${BACKEND_ARTIFACT}.tar" "${BACKEND_IMAGE}"
env:
BACKEND_IMAGE: ${{ steps.get_image_name.outputs.image_name }}
BACKEND_ARTIFACT: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}
- name: Push image
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}-image
path: ${{ github.workspace }}/${{ steps.get_image_artifact_name.outputs.image_artifact_name }}.tar
retention-days: 1
build_test_runner_image:
needs: [linting, unit-and-integration-tests]
timeout-minutes: 10
runs-on: ubuntu-latest
strategy:
fail-fast: false
outputs:
image_artifact_name: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}
image_name: ${{ steps.get_image_name.outputs.image_name }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Build image artifact name
id: get_image_artifact_name
run: |
IMAGE_ARTIFACT_NAME=$(echo "${GITHUB_HEAD_REF}" | sed 's_/_\-_g' )-runner
echo ::set-output name=image_artifact_name::"${IMAGE_ARTIFACT_NAME}"
- name: Build image name
id: get_image_name
run: echo ::set-output name=image_name::"ghcr.io/international-data-spaces-association/dataspace-connector/tests/runner"
- name: Build image
run: |
cd ./scripts/tests/runner/
docker build . -t "${IMAGE}" -f runner.dockerfile
env:
IMAGE: ${{ steps.get_image_name.outputs.image_name }}
DOCKER_BUILDKIT: 1
- name: Build tar ball
id: build_tar_ball
run: |
docker save --output "${BACKEND_ARTIFACT}.tar" "${BACKEND_IMAGE}"
env:
BACKEND_IMAGE: ${{ steps.get_image_name.outputs.image_name }}
BACKEND_ARTIFACT: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}
- name: Push image
uses: actions/upload-artifact@v3
with:
name: ${{ steps.get_image_artifact_name.outputs.image_artifact_name }}-image
path: ${{ github.workspace }}/${{ steps.get_image_artifact_name.outputs.image_artifact_name }}.tar
retention-days: 1
e2e-test:
needs: [build_test_image, build_test_backend_image, build_test_runner_image]
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup environment
run: |
curl -sfL https://get.k3s.io | K3S_KUBECONFIG_MODE=666 sh -
cat /etc/rancher/k3s/k3s.yaml
mkdir -p ~/.kube
cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
chmod 600 ~/.kube/config
- name: Download image
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_test_image.outputs.image_artifact_name }}-image
- name: Download backend image
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_test_backend_image.outputs.image_artifact_name }}-image
- name: Download test runner image
uses: actions/download-artifact@v3
with:
name: ${{ needs.build_test_runner_image.outputs.image_artifact_name }}-image
- name: Load image into cluster
run: sudo k3s ctr images import "${GITHUB_WORKSPACE}/${ARTIFACT}.tar"
env:
ARTIFACT: ${{ needs.build_test_image.outputs.image_artifact_name }}
- name: Load backend image into cluster
run: sudo k3s ctr images import "${GITHUB_WORKSPACE}/${BACKEND_ARTIFACT}.tar"
env:
BACKEND_ARTIFACT: ${{ needs.build_test_backend_image.outputs.image_artifact_name }}
- name: Load backend image into cluster
run: sudo k3s ctr images import "${GITHUB_WORKSPACE}/${RUNNER_ARTIFACT}.tar"
env:
RUNNER_ARTIFACT: ${{ needs.build_test_runner_image.outputs.image_artifact_name }}
- name: Test environment
run: |
kubectl cluster-info
- name: Run scripts
run: |
./scripts/ci/e2e/test-provider-consumer.sh