-
Notifications
You must be signed in to change notification settings - Fork 95
764 lines (708 loc) · 27 KB
/
applications.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
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
name: Build and publish application binaries
on:
workflow_dispatch:
inputs:
debugInfo:
description: whether to create binaries with debugging info (dwarf debugging symbols)
default: 'False'
optimizationLevel:
description: optimization level that is used to compile pact and chainweb-node
default: '1'
profiling:
description: enable profiling runtime
default: 'False'
debug:
description: compile and link with -debug
default: 'False'
eventlog:
description: link with -eventlog
default: 'False'
merge_group:
push:
branches-ignore:
- 'gh-readonly-queue/**'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.kadena_cabal_cache_aws_access_key_id }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.kadena_cabal_cache_aws_secret_access_key }}
AWS_DEFAULT_REGION: us-east-1
S3_ARTIFACT_BUCKET: kadena-cabal-cache
S3_ARTIFACT_FOLDER: chainweb-node
USE_CABAL_CACHE: true
jobs:
# ########################################################################## #
# Configure Workflow
config:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
git-sha-short: ${{ steps.git-info.outputs.git-sha-short }}
git-ref-short: ${{ steps.git-info.outputs.git-ref-short }}
is-release: ${{ steps.git-info.outputs.is-release }}
debug-info: ${{ steps.compile-flags.outputs.debug-info }}
stripping: ${{ steps.compile-flags.outputs.stripping }}
opt-level: ${{ steps.compile-flags.outputs.opt-level }}
profiling: ${{ steps.compile-flags.outputs.profiling }}
debug: ${{ steps.compile-flags.outputs.debug }}
eventlog: ${{ steps.compile-flags.outputs.eventlog }}
tag-suffix: ${{ steps.compile-flags.outputs.tag-suffix }}
chainweb-network-version: ${{ steps.compile-flags.outputs.chainweb-network-version }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Git revision infos
id: git-info
run: |
echo "git-sha-short=${GITHUB_SHA:0:7}" >> $GITHUB_OUTPUT
echo "is-release=${{ contains(github.event_name, 'release') }}" >> $GITHUB_OUTPUT
echo "git-ref-short=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
- name: Set optimization level and debugging info
id: compile-flags
run: |
TAG_SUFFIX=
echo "chainweb-network-version=development" >> $GITHUB_OUTPUT
# Optimization
OPT_LEVEL=${{ github.event.inputs.optimizationLevel }}
if [[ -n "$OPT_LEVEL" && "$OPT_LEVEL" != "1" ]] ; then
echo "opt-level=$OPT_LEVEL" >> $GITHUB_OUTPUT
TAG_SUFFIX+=-opt$OPT_LEVEL
else
echo "opt-level=1" >> $GITHUB_OUTPUT
fi
# Debug info
DEBUG_INFO=${{ github.event.inputs.debugInfo }}
if [[ -n "$DEBUG_INFO" && "${DEBUG_INFO^^}" = "TRUE" ]] ; then
echo "building binaries with dwarf debug symbols"
echo "debug-info=True" >> $GITHUB_OUTPUT
echo "stripping=False" >> $GITHUB_OUTPUT
TAG_SUFFIX+=-dwarf
else
echo "building binaries without dwarf debug symbols"
echo "debug-info=False" >> $GITHUB_OUTPUT
echo "stripping=True" >> $GITHUB_OUTPUT
fi
# Profiling
PROFILING=${{ github.event.inputs.profiling }}
if [[ -n "$PROFILING" && "${PROFILING^^}" = "TRUE" ]] ; then
echo "building binaries with profiling runtime"
echo "profiling=True" >> $GITHUB_OUTPUT
TAG_SUFFIX+=-prof
else
echo "building binaries without profiling runtime"
echo "profiling=False" >> $GITHUB_OUTPUT
fi
# Debug
DEBUG=${{ github.event.inputs.debug }}
if [[ -n "$DEBUG" && "${DEBUG^^}" = "TRUE" ]] ; then
echo "building binaries with -debug"
echo "debug=True" >> $GITHUB_OUTPUT
TAG_SUFFIX+=-debug
else
echo "building binaries without -debug"
echo "debug=False" >> $GITHUB_OUTPUT
fi
# Eventlog
EVENTLOG=${{ github.event.inputs.eventlog }}
if [[ -n "$EVENTLOG" && "${EVENTLOG^^}" = "TRUE" ]] ; then
echo "building binaries with -eventlog"
echo "eventlog=True" >> $GITHUB_OUTPUT
TAG_SUFFIX+=-eventlog
else
echo "building binaries without -eventlog"
echo "eventlog=False" >> $GITHUB_OUTPUT
fi
echo "tag-suffix=$TAG_SUFFIX" >> $GITHUB_OUTPUT
# BUILD MATRIX
#
- name: Create matrix
id: set-matrix
run: |
if "${{ github.event_name == 'schedule' }}" == "true"; then
MATRIX="$(jq -c '.' <<EOF
{
"ghc": ["9.6.4", "9.8.1"],
"cabal": ["3.10"],
"os": ["ubuntu-20.04", "ubuntu-22.04"],
"use-freeze-file": ["false"]
]
}
EOF
)"
else
MATRIX="$(jq -c '.' <<EOF
{
"ghc": ["9.6.4"],
"cabal": ["3.10"],
"os": ["ubuntu-20.04", "ubuntu-22.04"],
"use-freeze-file": ["true"]
}
EOF
)"
fi
echo "matrix=$MATRIX" >> $GITHUB_OUTPUT
- name: Log config
run: |
echo "::group::context"
echo "GITHUB_SHA=${GITHUB_SHA}"
echo "github.event_name=${{ github.event_name }}"
echo "GITHUB_REF=${GITHUB_REF}"
echo "::endgroup::"
echo "::group::config"
echo "config.outputs.git-sha-short=${{ steps.git-info.outputs.git-sha-short }}"
echo "config.outputs.git-ref-short=${{ steps.git-info.outputs.git-ref-short }}"
echo "config.outputs.is-release=${{ steps.git-info.outputs.is-release }}"
echo "config.outputs.debug-info=${{ steps.compile-flags.outputs.debug-info }}"
echo "config.outputs.stripping=${{ steps.compile-flags.outputs.stripping }}"
echo "config.outputs.debug=${{ steps.compile-flags.outputs.debug }}"
echo "config.outputs.eventlog=${{ steps.compile-flags.outputs.eventlog }}"
echo "config.outputs.profiling=${{ steps.compile-flags.outputs.profiling }}"
echo "config.outputs.opt-level=${{ steps.compile-flags.outputs.opt-level }}"
echo "config.outputs.tag-suffix=${{ steps.compile-flags.outputs.tag-suffix }}"
echo "config.outputs.matrix=${{ steps.set-matrix.outputs.matrix }}"
echo "::endgroup::"
# ########################################################################## #
# Download Development Database for Testing
#
# Uploading artifacts is slow, but downloading is fast.
# For the development database that pays off.
sync-chain-db:
name: Download test chain database
needs: [config]
runs-on: 'ubuntu-latest'
strategy:
fail-fast: false
env:
DB_SNAPSHOT_URI: 's3://chainweb-chain-db/${{ needs.config.outputs.chainweb-network-version }}/pipeline-db/rocksDb'
steps:
- name: Sync chain database from S3
run: aws s3 sync "$DB_SNAPSHOT_URI" db/0/rocksDb --delete --exclude=LOCK
- name: Store chain database as artifact
uses: actions/upload-artifact@v3
with:
name: chain-db-${{ needs.config.outputs.chainweb-network-version }}
path: db
# ########################################################################## #
# Build and Upload Artifacts
build:
name: Build
needs: [config]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.config.outputs.matrix) }}
env:
ARTIFACTS_ARCHIVE: chainweb.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}.${{ needs.config.outputs.git-sha-short }}${{ needs.config.outputs.tag-suffix }}.tar.gz
ARTIFACTS_NAME: chainweb-applications.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}
steps:
# Setup
- name: Checkout repository
uses: actions/checkout@v3
with:
fetch-depth: 0
# This only works if also the times of the cache are adjusted accordingly
# to the time of the commit for the respective revision. This can be done
# by adjusting the time of all files in the cache before the end of the task
#
# - name: Set all tracked file modification times to the time of their last commit
# run: |
# rev=HEAD
# for f in $(git ls-tree -r -t --full-name --name-only "$rev") ; do
# touch -d $(git log --pretty=format:%cI -1 "$rev" -- "$f") "$f";
# done
# work around for https://github.com/haskell/actions/issues/187
- name: Set permissions for .ghcup
if: startsWith(matrix.os, 'ubuntu-')
run: sudo chown -R $USER /usr/local/.ghcup
- name: Install GHC and Cabal
uses: haskell-actions/setup@v2
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- name: Confirm GHC and Cabal installation
run: |
ghc --version
cabal --version
- name: Install non-Haskell dependencies (ubuntu)
if: contains(matrix.os, 'ubuntu')
run: sudo apt-get install -y libgflags-dev liblz4-dev libzstd-dev libsnappy-dev libbz2-dev
# Project Configuration
- name: Create cabal.project.local
run: |
cat > cabal.project.local <<EOF
package *
documentation: False
package chainweb
documentation: False
benchmarks: True
tests: True
ghc-options: -Wunused-packages
package pact
documentation: False
EOF
- name: Configure Optimization Level
run: |
cat >> cabal.project.local <<EOF
package pact
optimization: ${{ needs.config.outputs.opt-level }}
package chainweb
optimization: ${{ needs.config.outputs.opt-level }}
EOF
- name: Configure Profiling
run: |
cat >> cabal.project.local <<EOF
package *
profiling: ${{ needs.config.outputs.profiling }}
EOF
- name: Configure Debug Info and Symbol Stripping
run: |
cat >> cabal.project.local <<EOF
package *
debug-info: ${{ needs.config.outputs.debug-info }}
executable-stripping: ${{ needs.config.outputs.stripping }}
library-stripping: ${{ needs.config.outputs.stripping }}
EOF
- name: Set GHC Debug Flag
if: needs.config.outputs.debug == 'True'
run: |
cat >> cabal.project.local <<EOF
package chainweb
ghc-options: -debug
EOF
# dist cache
# the cache-key forces uploading of cache at least once a day, which ensures that
# upstream dependency changes are captured regularly.
- uses: actions/cache@v3
name: Cache dist-newstyle
with:
path: |
dist-newstyle
key: ${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.use-freeze-file }}-2-${{ hashFiles('cabal.*', '*.cabal', 'src/**', 'test/**') }}
restore-keys: |
${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.use-freeze-file }}-2-
${{ matrix.os }}-${{ matrix.ghc }}-
# Build
- name: Delete Freeze file if it exists
if: matrix.use-freeze-file != 'true'
# we generate and archive a new freeze file during the build
run: rm -f cabal.project.freeze
- name: Update package database
run: cabal update
- name: Display outdated packages
run: cabal outdated
- name: Configure build
run: cabal build all --dry-run
- name: Generate new freeze file
if: matrix.use-freeze-file != 'true'
run: cabal freeze
- name: Display Dependency Changes
run: |
diff -w <(git show HEAD:cabal.project.freeze) cabal.project.freeze || true
- name: Sync from cabal cache
if: env.USE_CABAL_CACHE == 'true'
uses: larskuhtz/cabal-cache-action@018b7ae0c480ba3dc4fa0cfa3a0bc1f05b7724b3
with:
bucket: "kadena-cabal-cache"
region: "us-east-1"
folder: "${{ matrix.os }}-${{ matrix.ghc }}-${{ matrix.use-freeze-file }}"
aws_access_key_id: "${{ secrets.kadena_cabal_cache_aws_access_key_id }}"
aws_secret_access_key: "${{ secrets.kadena_cabal_cache_aws_secret_access_key }}"
- name: Install build dependencies
run: cabal build chainweb --only-dependencies
- name: Build chainweb library
run: cabal build --ghc-options=-j2 lib:chainweb
- name: Build chainweb applications
run: cabal build -j2 --ghc-options=-j2 exe:chainweb-node test:chainweb-tests exe:cwtool chainweb:bench:bench
# Checks
- name: Check that working directory tree is clean
run: |
if ! git diff --exit-code -- :^cabal.project.freeze ; then
echo "Git working tree is not clean. The build changed some file that is checked into git." 1>&2
exit 1
fi
- name: Run ea and verify consistency of genesis headers
run: |
cabal run cwtool -- ea
if ! git diff --exit-code -- src/Chainweb/BlockHeader/Genesis/ src/Chainweb/Pact/Transactions/ ; then
echo "Inconsistent genesis headers detected. Did you forget to run ea?" 1>&2
exit 1
fi
# Archive Artifacts
- name: Prepare artifacts
run: |
mkdir -p artifacts/chainweb
cp $(cabal list-bin chainweb-node) artifacts/chainweb
cp $(cabal list-bin chainweb-tests) artifacts/chainweb
cp $(cabal list-bin cwtool) artifacts/chainweb
cp $(cabal list-bin bench) artifacts/chainweb
cp README.md artifacts/chainweb
cp CHANGELOG.md artifacts/chainweb
cp LICENSE artifacts/chainweb
cp chainweb.cabal artifacts/chainweb
cp cabal.project artifacts/chainweb
cp cabal.project.local artifacts/chainweb
cp cabal.project.freeze artifacts/chainweb
- name: Create artifacts archive
run: |
echo "tar -C ./artifacts/ -czf $ARTIFACTS_ARCHIVE chainweb"
tar -C ./artifacts/ -czf "$ARTIFACTS_ARCHIVE" chainweb
ls ./artifacts
- name: Safe artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACTS_NAME }}
path: ${{ env.ARTIFACTS_ARCHIVE }}
if-no-files-found: error
# ########################################################################## #
# Run Slow tests (Multinode test)
slow-tests:
name: Slow tests
needs: [config, build]
runs-on: ${{ matrix.os }}
env:
ARTIFACTS_NAME: chainweb-applications.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.config.outputs.matrix) }}
steps:
- uses: actions/checkout@v3
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACTS_NAME }}
path: .
- name: Install chainweb from artifacts
uses: ./.github/actions/install-chainweb-from-artifacts
with:
os: ${{ matrix.os }}
ghc: ${{ matrix.ghc }}
use-freeze-file: ${{ matrix.use-freeze-file }}
- name: Run slow tests
timeout-minutes: 20
run: |
ulimit -n 10000
cwtool slow-tests
# ########################################################################## #
# Run Benchmarks
benchmarks:
name: Benchmarks
needs: [config, build]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.config.outputs.matrix) }}
runs-on: ${{ matrix.os }}
env:
BENCH_FILE: results.${{ github.run_id }}.${{ github.run_number }}.json
BENCH_BUCKET: kadena-cabal-cache
BENCH_FOLDER: chainweb-benchmark-results/${{ matrix.ghc }}/${{ matrix.os }}
ARTIFACTS_NAME: chainweb-applications.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACTS_NAME }}
path: .
- name: Install chainweb from artifacts
uses: ./.github/actions/install-chainweb-from-artifacts
with:
os: ${{ matrix.os }}
ghc: ${{ matrix.ghc }}
use-freeze-file: ${{ matrix.use-freeze-file }}
- name: Run all benchmarks
timeout-minutes: 12
run: bench --json $BENCH_FILE +RTS -N
- name: Upload results
run: |
aws s3 cp $BENCH_FILE s3://$BENCH_BUCKET/$BENCH_FOLDER/
aws s3api put-object-acl --bucket $BENCH_BUCKET --key=$BENCH_FOLDER/$BENCH_FILE --acl public-read
# ########################################################################## #
# Validate Devnet Database and Replay Pact History
validate-devnet-database:
name: Validate Devnet Database Snapshot and Replay Pact History
needs: [config, sync-chain-db, build]
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.config.outputs.matrix) }}
runs-on: ${{ matrix.os }}
env:
ARTIFACTS_NAME: chainweb-applications.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Download ${{ needs.config.outputs.chainweb-network-version }} chain database artifact
uses: actions/download-artifact@v3
with:
name: chain-db-${{ needs.config.outputs.chainweb-network-version }}
path: db
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACTS_NAME }}
path: .
- name: Install chainweb from artifacts
uses: ./.github/actions/install-chainweb-from-artifacts
with:
os: ${{ matrix.os }}
ghc: ${{ matrix.ghc }}
use-freeze-file: ${{ matrix.use-freeze-file }}
- name: Write chainweb-node configuration
run: |
cat >> config.yaml <<EOF
databaseDirectory: "db"
chainweb:
onlySyncPact: true
chainwebVersion: ${{ needs.config.outputs.chainweb-network-version }}
validateHashesOnReplay: true
p2p:
peer:
interface: localhost
hostaddress:
port: 4445
private: true
ignoreBootstrapNodes: true
transactionIndex:
enabled: false
mempoolP2p:
enabled: false
cuts:
pruneChainDatabase: headers-checked
logging:
telemetryBackend:
enabled: false
configuration:
color: 'true'
backend:
color: 'true'
filter:
rules:
- value: mempool
key: component
level: warn
- value: connection-manager
key: component
level: warn
- value: sync
key: sub-component
level: warn
- value: MempoolAccess
key: sub-component
level: warn
- value: PactService
key: logger
level: warn
- value: Checkpointer
key: logger
level: warn
default: info
EOF
- name: Validate database and replay pact transactions
timeout-minutes: 6
run: |
chainweb-node +RTS -T -H1G -A64M -RTS \
--config-file=config.yaml \
--log-level=info \
--disable-pow
# ########################################################################## #
# Run Unit Tests
unit-tests:
name: Unit tests
needs: [config, build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.config.outputs.matrix) }}
env:
TEST_RESULT_FILE: test-results.${{ github.run_id }}.${{ github.run_number }}.json
TEST_RESULT_BUCKET: kadena-cabal-cache
TEST_RESULT_FOLDER: chainweb-test-results/ghc-${{ matrix.ghc }}/${{ matrix.os }}
ARTIFACTS_NAME: chainweb-applications.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACTS_NAME }}
path: .
- name: Install chainweb from artifacts
uses: ./.github/actions/install-chainweb-from-artifacts
with:
os: ${{ matrix.os }}
ghc: ${{ matrix.ghc }}
use-freeze-file: ${{ matrix.use-freeze-file }}
- name: Run Tests
id: tests
timeout-minutes: 10
run: |
ulimit -n 10000
chainweb-tests --hide-successes --results-json test-results.json
# Publish test results to S3
- name: Upload test results
if: always() && steps.tests.outcome != 'skipped' && steps.tests.outcome != 'cancelled'
run: |
cat > filter.jq <<EOF
.gitRevision = "${{ github.sha }}" |
.gitRef = "${{ needs.config.outputs.git-short-ref }}" |
.githubRunId = ${{ github.run_id }} |
.githubRunNumber = ${{ github.run_number }}
EOF
jq -f filter.jq test-results.json > $TEST_RESULT_FILE
aws s3 cp $TEST_RESULT_FILE s3://$TEST_RESULT_BUCKET/$TEST_RESULT_FOLDER/
aws s3api put-object-acl --bucket $TEST_RESULT_BUCKET --key=$TEST_RESULT_FOLDER/$TEST_RESULT_FILE --acl public-read
# ########################################################################## #
# Publish Artifiacts to S3
publish:
name: Publish
needs: [config, build]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.config.outputs.matrix) }}
env:
ARTIFACTS_ARCHIVE: chainweb.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}.${{ needs.config.outputs.git-sha-short }}${{ needs.config.outputs.tag-suffix }}.tar.gz
ARTIFACTS_NAME: chainweb-applications.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}
steps:
- name: Download build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACTS_NAME }}
path: .
- name: Publish applications to S3
run: |
aws s3 cp $ARTIFACTS_ARCHIVE s3://$S3_ARTIFACT_BUCKET/$S3_ARTIFACT_FOLDER/
aws s3api put-object-acl --bucket $S3_ARTIFACT_BUCKET --key=$S3_ARTIFACT_FOLDER/$ARTIFACTS_ARCHIVE --acl public-read
# ########################################################################## #
# Build and publish docker image
docker-image:
name: Build and publish docker image
needs: [config, build]
runs-on: ${{ matrix.os }}
if: "${{ github.event_name != 'schedule' }}"
strategy:
fail-fast: false
matrix:
# when adding more than one build, use a different package name or
# different tags
include:
- ghc: "9.6.4"
os: "ubuntu-20.04"
use-freeze-file: "true"
env:
OS: ${{ matrix.os }}
ARTIFACTS_NAME: chainweb-applications.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}
ARTIFACTS_ARCHIVE: chainweb.${{ matrix.use-freeze-file }}.${{ matrix.ghc }}.${{ matrix.os }}.${{ needs.config.outputs.git-sha-short }}${{ needs.config.outputs.tag-suffix }}.tar.gz
steps:
- name: Get build artifacts
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACTS_NAME }}
path: .
- name: Extract artifacts
run: |
tar -xzf "$ARTIFACTS_ARCHIVE"
- name: Create Dockerfile
run: |
cat > Dockerfile <<DEOF
FROM ubuntu:${OS#ubuntu-}
LABEL com.chainweb.docker.image.compiler="ghc-${{ matrix.ghc }}"
LABEL com.chainweb.docker.image.os="${OS}"
LABEL com.chainweb.docker.image.optimization="${{ needs.config.outputs.opt-level }}"
LABEL com.chainweb.docker.image.debug-info="${{ needs.config.outputs.debug-info }}"
LABEL com.chainweb.docker.image.profiling="${{ needs.config.outputs.profiling }}"
LABEL com.chainweb.docker.image.debug="${{ needs.config.outputs.debug }}"
LABEL com.chainweb.docker.image.eventlog="${{ needs.config.outputs.eventlog }}"
LABEL com.chainweb.docker.image.revision="${{ needs.config.outputs.git-sha-short }}"
RUN <<EOF
apt-get update &&
apt-get install -y \
ca-certificates \
libgmp10 \
libssl1.1 \
libsnappy1v5 \
zlib1g \
liblz4-1 \
libbz2-1.0 \
libgflags2.2 \
zstd \
locales &&
rm -rf /var/lib/apt/lists/* &&
locale-gen en_US.UTF-8 &&
update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
EOF
ENV LANG=en_US.UTF-8
WORKDIR /chainweb
COPY chainweb/chainweb-node .
COPY chainweb/chainweb-tests .
COPY chainweb/cwtool .
COPY chainweb/LICENSE .
COPY chainweb/README.md .
COPY chainweb/CHANGELOG.md .
COPY chainweb/chainweb.cabal .
COPY chainweb/cabal.project .
COPY chainweb/cabal.project.local .
COPY chainweb/cabal.project.freeze .
STOPSIGNAL SIGTERM
ENTRYPOINT [ "/chainweb/chainweb-node" ]
DEOF
- name: Set frozen tag
id: frozen-tag
run: |
if [ "${{ matrix.use-freeze-file }}" == "true" ] ; then
echo "value=-frozen" >> $GITHUB_OUTPUT
else
echo "value=" >> $GITHUB_OUTPUT
fi
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/kadena-io/chainweb-node
flavor: |
suffix=${{ steps.frozen-tag.outputs.value }}${{ needs.config.outputs.tag-suffix }}
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: kadena-build
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
id: docker_build
uses: docker/build-push-action@v4
with:
push: true
context: .
file: ./Dockerfile
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache
# ########################################################################## #
# Trigger Integration Tests Run
integration-tests:
name: Run Integration Tests from remote repo
needs: [ config, docker-image ]
runs-on: ubuntu-latest
env:
GIT_SHA_SHORT: ${{ needs.config.outputs.git-sha-short }}
steps:
- name: Start remote integration tests
uses: aurelien-baudet/workflow-dispatch@93e95b157d791ae7f42aef8f8a0d3d723eba1c31
with:
workflow: Integration Tests on devnet chain
token: ${{ secrets.GH_WORKFLOW_PAT_FOR_TESTS }}
inputs: '{ "chainweb_node_container_id" : "sha-${{ needs.config.outputs.git-sha-short }}" }'
ref: refs/heads/master
repo: kadena-io/integration-tests
display-workflow-run-url: true
wait-for-completion: false # here you could make this pipeline wait them out