forked from TouK/nussknacker
-
Notifications
You must be signed in to change notification settings - Fork 0
612 lines (602 loc) · 25.5 KB
/
pr.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
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
#this should be the same as workflow name in test-report.yml
name: CI
on:
pull_request:
branches:
- master
- staging
- demo
- preview/*
- release/*
paths-ignore:
- '**.md'
- 'docs/**'
push:
branches:
- master
- staging
- demo
- preview/*
- release/*
paths-ignore:
- '**.md'
- 'docs/**'
#TODO: currently release is done manually, we don't want to run this pipeline on released version, to avoid accidental pushes
tags-ignore:
- '**'
env:
#we use this variable in ciRunSbt.sh
#NOTE: for publishing we use different settings, we don't use ciRunSbt.sh there
#CROSS_BUILD: ${{ github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/preview') || startsWith(github.ref, 'refs/heads/release') }}
CROSS_BUILD: false #temporarly, until tests against 2.13 are stable
jobs:
setup:
runs-on: ubuntu-latest
outputs:
fe_changes_count: ${{ steps.filter.outputs.fe_changes_count }}
all_changes_count: ${{ steps.filter.outputs.all_changes_count }}
git_source_branch: ${{ steps.variables.outputs.git_source_branch }}
nk_snapshot_version: ${{ steps.variables.outputs.nk_snapshot_version }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 100
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: 'csv'
filters: |
fe_changes:
- 'designer/client/**'
- 'designer/submodules/**'
all_changes:
- '**'
- name: Define variables
id: variables
shell: bash
run: |
GIT_SOURCE_BRANCH=`([ "${GITHUB_HEAD_REF}" != "" ] && echo "${GITHUB_HEAD_REF}" || echo "${GITHUB_REF}") | sed 's/refs\/heads\///g'`
SANITIZED_BRANCH=`echo ${GIT_SOURCE_BRANCH} | sed 's/[^a-zA-Z0-9._-]/\_/g' | awk '{print tolower($0)}'`
VERSION_SUFFIX="-$SANITIZED_BRANCH-$(date -I)-$GITHUB_RUN_NUMBER-$GITHUB_SHA"
NK_SNAPSHOT_VERSION=`cat version.sbt | sed -e 's/.*:= *"//' -e 's/" *//' | sed "s/-SNAPSHOT/${VERSION_SUFFIX}-SNAPSHOT/"`
echo "::set-output name=git_source_branch::$GIT_SOURCE_BRANCH"
echo "::set-output name=nk_snapshot_version::$NK_SNAPSHOT_VERSION"
build:
name: Build
runs-on: ubuntu-latest
needs: [ setup ]
env:
# We can't just use conditional jobs mechanism ('if' directive) because 'dockerTest' job depends on this one
shouldPerformBackendBuild: ${{ needs.setup.outputs.fe_changes_count != needs.setup.outputs.all_changes_count || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/demo' || startsWith(github.ref, 'refs/heads/preview') || startsWith(github.ref, 'refs/heads/release') }}
steps:
- name: Cancel previous runs
if: ${{ env.shouldPerformBackendBuild == 'true' && github.event_name != 'push' }}
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
if: ${{ env.shouldPerformBackendBuild == 'true' }}
- uses: olafurpg/setup-scala@v10
if: ${{ env.shouldPerformBackendBuild == 'true' }}
with:
java-version: "[email protected]"
- name: Cache ivy packages
if: ${{ env.shouldPerformBackendBuild == 'true' }}
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-sbt
- name: Build
if: ${{ env.shouldPerformBackendBuild == 'true' }}
shell: bash
run: CROSS_BUILD=false ./ciRunSbt.sh Compile/compile Test/compile
- name: Tar artifacts
if: ${{ env.shouldPerformBackendBuild == 'true' }}
shell: bash
run: find . -wholename "**/target/**/*" -printf '%P\0' | tar --null -C '.' --files-from=- -czf 'target.tgz'
- name: Store target
if: ${{ env.shouldPerformBackendBuild == 'true' }}
uses: actions/upload-artifact@v2
with:
name: build-target
path: target.tgz
build-fe:
name: BuildFrontend
runs-on: ubuntu-latest
needs: [ setup ]
env:
NUSSKNACKER_VERSION: ${{ needs.setup.outputs.nk_snapshot_version }}
steps:
- name: Cancel previous runs
if: github.event_name != 'push'
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Cache npm
id: cache-npm
uses: actions/cache@v2
with:
path: |
**/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-${{ hashFiles('designer/client/package-lock.json', 'designer/client/.nvmrc', 'designer/submodules/package-lock.json', 'designer/submodules/.nvmrc') }}
- name: Get Node.js version
id: nvm
run: echo ::set-output name=NODE_VERSION::$(cat designer/client/.nvmrc)
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- name: Download node modules
if: steps.cache-npm.outputs.cache-hit != 'true'
run: |
npm ci --no-audit --prefix designer/client
npm ci --no-audit --prefix designer/submodules
- name: Build FE
run: (cd designer/client; npm run build)
- name: Build FE submodules
run: |
cd designer
cp -r client/.federated-types/nussknackerUi submodules/types/@remote
cd submodules
npm run build
- name: Tar fe artifacts
shell: bash
run: tar -czf 'fe-dist.tgz' designer/client/dist designer/submodules/dist
- name: Store dist
uses: actions/upload-artifact@v2
with:
name: build-fe-dist
path: fe-dist.tgz
tests:
name: Tests
runs-on: ubuntu-latest
needs: [ build, setup ]
if: ${{ needs.setup.outputs.fe_changes_count != needs.setup.outputs.all_changes_count || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/demo' || startsWith(github.ref, 'refs/heads/preview') || startsWith(github.ref, 'refs/heads/release') }}
steps:
- name: Cancel previous runs
if: github.event_name != 'push'
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
with:
java-version: "[email protected]"
- uses: actions/download-artifact@v2
with:
name: build-target
- name: Untar artifacts
shell: bash
run: tar xfz target.tgz
- name: Cache ivy packages
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-sbt
- name: Backend tests with coverage
shell: bash
if: ${{ github.ref == 'refs/heads/staging' }}
run: ./ciRunSbt.sh coverage test coverageReport
- name: Backend tests without coverage
shell: bash
if: ${{ github.ref != 'refs/heads/staging' }}
run: ./ciRunSbt.sh test
- name: Test Report
if: success() || failure()
uses: actions/upload-artifact@v2
with:
name: BackendTests-results
path: '**/test-reports/*.xml'
- name: Upload Coverage data to Coveralls
shell: bash
if: ${{ github.ref == 'refs/heads/staging' }}
run: ./ciRunSbt.sh coverageAggregate coveralls
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
crossCompile:
name: CrossCompile
runs-on: ubuntu-latest
needs: [ build, setup ]
if: ${{ needs.setup.outputs.fe_changes_count != needs.setup.outputs.all_changes_count || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/demo' || startsWith(github.ref, 'refs/heads/preview') || startsWith(github.ref, 'refs/heads/release') }}
steps:
- name: Cancel previous runs
if: github.event_name != 'push'
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
with:
java-version: "[email protected]"
- name: Cache ivy packages
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-sbt
- uses: actions/download-artifact@v2
with:
name: build-target
- name: Untar artifacts
shell: bash
run: tar xfz target.tgz
- name: Compile
shell: bash
run: CROSS_BUILD=true ./ciRunSbt.sh Compile/compile Test/compile
integrationTests:
name: IntegrationTests
needs: [ build, setup ]
if: ${{ needs.setup.outputs.fe_changes_count != needs.setup.outputs.all_changes_count || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/demo' || startsWith(github.ref, 'refs/heads/preview') || startsWith(github.ref, 'refs/heads/release') }}
runs-on: ubuntu-latest
steps:
- name: Cancel previous runs
if: github.event_name != 'push'
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
with:
java-version: "[email protected]"
- name: Cache ivy packages
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-sbt
- uses: actions/download-artifact@v2
with:
name: build-target
- name: Untar artifacts
shell: bash
run: tar xfz target.tgz
- name: Integration tests
shell: bash
env:
dockerUpLatest: true
run: ./ciRunSbt.sh It/test
- name: Test Report
if: success() || failure()
uses: actions/upload-artifact@v2
with:
name: IntegrationTests-results
path: '**/it-reports/*.xml'
slowTests:
name: Slow and K8s tests
runs-on: ubuntu-latest
needs: [ build, setup ]
if: ${{ needs.setup.outputs.fe_changes_count != needs.setup.outputs.all_changes_count || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/demo' || startsWith(github.ref, 'refs/heads/preview') || startsWith(github.ref, 'refs/heads/release') }}
steps:
- name: Cancel previous runs
if: github.event_name != 'push'
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v11
with:
java-version: "[email protected]"
- name: Cache ivy packages
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-sbt
- uses: actions/download-artifact@v2
with:
name: build-target
- name: Untar artifacts
shell: bash
run: tar xfz target.tgz
# We run k8s tests here instead of in integrationTests job because it causes RAM overhead and some other docker tests failing occasionally
- uses: AbsaOSS/[email protected]
env:
PROJECT_ROOT: ${{ github.workspace }}
with:
cluster-name: "k3s-default"
k3d-version: "v5.4.1" # default version - change with caution, there was some problem with 500 exit codes for after upgrade
args: >-
--config=.k3d/single-cluster.yml
--trace
- name: Slow tests
shell: bash
run: ./ciRunSbt.sh designer/Slow/test liteK8sDeploymentManager/ExternalDepsTests/test
- name: Test Report
if: success() || failure()
uses: actions/upload-artifact@v2
with:
name: SlowTests-results
path: '**/test-reports/*.xml'
frontendTests:
name: FrontendTests
runs-on: ubuntu-latest
needs: [ setup ]
env:
# We can't just use conditional jobs mechanism ('if' directive) because 'publish' job depends on this one.
shouldPerformFrontendTests: ${{ needs.setup.outputs.fe_changes_count > 0 }}
steps:
- name: Cancel previous runs
if: ${{ env.shouldPerformFrontendTests == 'true' && github.event_name != 'push' }}
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
if: ${{ env.shouldPerformFrontendTests == 'true' }}
- name: Cache npm
id: cache-npm
if: ${{ env.shouldPerformFrontendTests == 'true' }}
uses: actions/cache@v2
with:
path: |
**/node_modules
~/.cache/Cypress
key: ${{ runner.os }}-${{ hashFiles('designer/client/package-lock.json', 'designer/client/.nvmrc', 'designer/submodules/package-lock.json', 'designer/submodules/.nvmrc') }}
- name: Get Node.js version
if: ${{ env.shouldPerformFrontendTests == 'true' }}
id: nvm
run: echo ::set-output name=NODE_VERSION::$(cat designer/client/.nvmrc)
- name: Use Node.js ${{ matrix.node-version }}
if: ${{ env.shouldPerformFrontendTests == 'true' }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- name: Download node modules
if: ${{ env.shouldPerformFrontendTests == 'true' && steps.cache-npm.outputs.cache-hit != 'true' }}
run: |
npm ci --no-audit --prefix designer/client
npm ci --no-audit --prefix designer/submodules
- name: Test FE
if: ${{ env.shouldPerformFrontendTests == 'true' }}
run: (cd designer/client; npm run test:unit)
- name: Test Report
if: ${{ env.shouldPerformFrontendTests == 'true' && (success() || failure()) }}
uses: actions/upload-artifact@v2
with:
name: FrontendTests-results
path: designer/client/junit.xml
dockerTest:
name: Docker based tests
runs-on: self-hosted
needs: [ build, build-fe, setup ]
env:
# We skip docker build for fe-only changes. Would be more clean to split this step into two steps: build image and run tests
# e.g. by using ishworkh/docker-image-artifact-upload/download but it caused ~3min overhead for the whole pipeline so we
# have this conditional logic in this step. We force building images on our "special" branches because run between merges
# could cause that cypress tests will be run at stale image (because of cancel-workflow-action).
shouldBuildImage: ${{ needs.setup.outputs.fe_changes_count != needs.setup.outputs.all_changes_count || github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/demo' || startsWith(github.ref, 'refs/heads/preview') || startsWith(github.ref, 'refs/heads/release') }}
GIT_SOURCE_BRANCH: ${{ needs.setup.outputs.git_source_branch }}
BE_PORT: 7251
steps:
- name: Cancel previous runs
if: github.event_name != 'push'
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- name: Get Node.js version
id: nvm
run: echo ::set-output name=NODE_VERSION::$(cat designer/client/.nvmrc)
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
with:
node-version: ${{ steps.nvm.outputs.NODE_VERSION }}
- name: Download node modules
run: |
npm ci --no-audit --prefix designer/client
npm ci --no-audit --prefix designer/submodules
- uses: olafurpg/setup-scala@v10
if: ${{ env.shouldBuildImage == 'true' }}
with:
java-version: "[email protected]"
- uses: actions/download-artifact@v2
if: ${{ env.shouldBuildImage == 'true' }}
with:
name: build-target
- name: Untar artifacts
if: ${{ env.shouldBuildImage == 'true' }}
shell: bash
run: tar xfz target.tgz
- uses: actions/download-artifact@v2
with:
name: build-fe-dist
- name: Untar fe artifacts
shell: bash
run: tar xfz fe-dist.tgz
- name: set version
if: ${{ env.shouldBuildImage == 'true' }}
shell: bash
run: echo "NUSSKNACKER_VERSION=${{ needs.setup.outputs.nk_snapshot_version }}" >> $GITHUB_ENV
- name: Prepare docker
if: ${{ env.shouldBuildImage == 'true' }}
env:
addDevArtifacts: true
shell: bash
#Doc generation is rather costly, we don't want it in test image creation
run: sbt "set ThisBuild / version := \"$NUSSKNACKER_VERSION\"; set publishArtifact in (ThisBuild, packageDoc) := false; set sources in (Compile,doc) := Seq.empty" dist/Docker/publishLocal
- name: Test docker
if: ${{env.shouldBuildImage == 'true' }}
shell: bash
working-directory: e2e-tests
run: ./setupAndRun.sh
- name: FE tests e2e on build docker image
if: ${{ env.shouldBuildImage == 'true' }}
env:
CYPRESS_SNAPSHOT_UPDATE: "true"
CYPRESS_BASE_URL: http://localhost:${{ env.BE_PORT }}
DOCKER_PULL_OPTION: never
shell: bash
run: |
cd designer/client
npx start-server-and-test backend:docker ${{ env.BE_PORT }} test:e2e
- name: Determine docker tag version to use
if: ${{ env.shouldBuildImage == 'false' }}
shell: bash
run: |
# Take a look at build.sbt commonDockerSettings to see how this tag is determined. Thanks to fact that we publish all changes pushed to our "special" branches it should work quite correctly.
NK_REF_VERSION=`[ "${GITHUB_REF}" != "" ] && echo "${GITHUB_REF}" | sed -e 's/refs\/heads\///g' -e 's/[^a-zA-Z0-9._-]/\_/g' -e 's/$/-latest/' | xargs -I VER sh -c 'docker pull touk/nussknacker:VER > /dev/null && echo VER || echo ""'`
NK_BASE_REF_VERSION=`[ "${NK_REF_VERSION}" != "" ] && echo "${NK_REF_VERSION}" || [ "${GITHUB_BASE_REF}" != "" ] && echo "${GITHUB_BASE_REF}" | sed -e 's/refs\/heads\///g' -e 's/[^a-zA-Z0-9._-]/\_/g' -e 's/$/-latest/' | xargs -I VER sh -c 'docker pull touk/nussknacker:VER > /dev/null && echo VER || echo ""'`
echo "NUSSKNACKER_VERSION=`[ \"${NK_BASE_REF_VERSION}\" != \"\" ] && echo \"${NK_BASE_REF_VERSION}\" || echo staging-latest`" >> $GITHUB_ENV
- name: FE tests e2e on pulled image
if: ${{ env.shouldBuildImage == 'false' }}
env:
CYPRESS_SNAPSHOT_UPDATE: "true"
shell: bash
run: |
cd designer/client
npx start-server-and-test backend:docker ${{ env.BE_PORT }} start-prod 3000 test:e2e
- name: Test Report
if: success() || failure()
uses: actions/upload-artifact@v2
with:
name: CypressTests-results
path: designer/client/cypress-test-results/*.xml
- name: Store test results
if: always()
uses: actions/upload-artifact@v2
with:
name: e2e-test-results
path: |
designer/client/cypress/**/__image_snapshots__/
designer/client/cypress/screenshots/
designer/client/cypress/videos/
if-no-files-found: ignore
- name: Create Pull Request
id: update_snapshots
if: always() && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository)
env:
HASH: ${{ format('#{0}', github.event.number) }}
BRANCH: ${{ needs.setup.outputs.git_source_branch }}
with:
token: ${{ secrets.GITHUB_TOKEN }}
base: ${{ env.BRANCH }}
branch: snapshots-patch/${{ env.BRANCH }}
title: Update Cypress snapshots in ${{ env.BRANCH }}
commit-message: Updated snapshots
body: Updated snapshots in ${{ github.event_name == 'pull_request' && env.HASH || env.BRANCH}}
uses: peter-evans/create-pull-request@v3
- name: Comment PR
if: ${{ always() && github.event_name == 'pull_request' && steps.update_snapshots.outputs.pull-request-number }}
uses: thollander/actions-comment-pull-request@v1
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: '${{ steps.update_snapshots.outputs.pull-request-operation }}: #${{ steps.update_snapshots.outputs.pull-request-number }}'
- name: Force fail if update PR created
if: ${{ always() && github.event_name == 'pull_request' && steps.update_snapshots.outputs.pull-request-number }}
uses: actions/[email protected]
with:
script: |
core.setFailed('Snapshots updated, chceck comments!')
#TODO: extract to different workflow?
publish:
runs-on: ubuntu-latest
needs: [build, build-fe, setup, tests, crossCompile, integrationTests, slowTests, frontendTests, dockerTest]
#TODO: should we publish everything on all those branches?
if: ${{ github.ref == 'refs/heads/staging' || github.ref == 'refs/heads/master' || github.ref == 'refs/heads/demo' || startsWith(github.ref, 'refs/heads/preview') || startsWith(github.ref, 'refs/heads/release') }}
env:
#TODO: shouldn't be needed...
nexusUrl: https://oss.sonatype.org/content/repositories/snapshots
nexusUser: ${{ secrets.SONATYPE_USER }}
nexusPassword: ${{ secrets.SONATYPE_PASSWORD }}
# We add dev model to staging because it is used in dev used on this environment, but we also add it for other branches for purpose of cypress tests
addDevArtifacts: true
NUSSKNACKER_VERSION: ${{ needs.setup.outputs.nk_snapshot_version }}
GIT_SOURCE_BRANCH: ${{ needs.setup.outputs.git_source_branch }}
steps:
- name: Cancel previous runs
if: github.event_name != 'push'
uses: styfle/[email protected]
with:
access_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v2
- uses: olafurpg/setup-scala@v10
with:
java-version: "[email protected]"
- name: Cache ivy packages
uses: actions/cache@v2
with:
path: |
~/.ivy2/cache
~/.cache/coursier
~/.sbt
key: ${{ runner.os }}-sbt-cache-${{ hashFiles('**/*.sbt') }}
restore-keys: ${{ runner.os }}-sbt
- uses: actions/download-artifact@v2
with:
name: build-target
- name: Untar artifacts
shell: bash
run: tar xfz target.tgz
- uses: actions/download-artifact@v2
with:
name: build-fe-dist
- name: Untar fe artifacts
shell: bash
run: tar xfz fe-dist.tgz
- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Publish with scaladocs
if: ${{ github.ref == 'refs/heads/staging' }}
shell: bash
#TODO: handle version better, do we want to publish docker image for older scala versions? If so, how should it be tagged?
run: sbt -J-Xms1500M -J-Xmx1500M "set ThisBuild / version := \"$NUSSKNACKER_VERSION\"" +publish dist/Docker/publish liteEngineRuntimeApp/Docker/publish
- name: Publish without scaladocs
if: ${{ github.ref != 'refs/heads/staging' }}
shell: bash
#TODO: handle version better, do we want to publish docker image for older scala versions? If so, how should it be tagged?
run: sbt -J-Xms1500M -J-Xmx1500M "set ThisBuild / version := \"$NUSSKNACKER_VERSION\"; set publishArtifact in (ThisBuild, packageDoc) := false; set sources in (Compile,doc) := Seq.empty" +publish dist/Docker/publish liteEngineRuntimeApp/Docker/publish
trigger-external-build:
runs-on: ubuntu-latest
needs: [ setup, publish ]
if: ${{ github.ref == 'refs/heads/staging' }}
strategy:
matrix:
include:
- repo: nussknacker-helm
workflow_id: helm-test-workflow.yaml
ref: main
- repo: nussknacker-quickstart
workflow_id: pr.yml
ref: staging
- repo: nussknacker-quickstart
workflow_id: benchmark-workflow.yml
ref: staging
- repo: nussknacker-sample-components
workflow_id: pr.yml
ref: staging
- repo: nussknacker-flink-compatibility
workflow_id: test.yml
ref: staging
steps:
- uses: actions/github-script@v6
with:
github-token: ${{ secrets.ORG_TRIGGER_PAT_TOKEN }}
script: |
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: '${{ matrix.repo }}',
workflow_id: '${{ matrix.workflow_id }}',
ref: '${{ matrix.ref }}',
inputs: {"nussknacker_version": "${{ needs.setup.outputs.nk_snapshot_version }}"}
})