forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 0
976 lines (905 loc) · 33.9 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
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
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
name: CI
on:
push:
branches:
- master
pull_request:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
REGISTRY: ghcr.io
RUST_VERSION: 1.79.0
NIGHTLY_RUST_VERSION: nightly-2024-07-16
jobs:
get-fuel-core-version:
runs-on: buildjet-4vcpu-ubuntu-2204
outputs:
fuel_core_version: ${{steps.get_fuel_core_ver.outputs.version}}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: get fuel core version
id: get_fuel_core_ver
run: |
cargo install toml-cli
version=$(toml get Cargo.toml workspace.dependencies.fuel-core-client.version | tr -d '"')
echo "version=$version" >> "$GITHUB_OUTPUT"
build-sway-lib-core:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Build sway-lib-core
run: forc build --path sway-lib-core
build-sway-lib-std:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Build sway-lib-std
run: forc build --path sway-lib-std
build-sway-examples:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Build Sway examples workspace
run: cargo run --locked -p forc -- build --locked --path ./examples/Forc.toml
build-reference-examples:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Build Sway examples workspace
run: cargo run --locked -p forc -- build --locked --path ./docs/reference/src/code/Forc.toml
forc-fmt-check-sway-lib-core:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Check Sway sway-lib-core formatting
run: cargo run --locked -p forc-fmt -- --check --path ./sway-lib-core
forc-fmt-check-sway-lib-std:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Check Sway sway-lib-std formatting
run: cargo run --locked -p forc-fmt -- --check --path ./sway-lib-std
forc-fmt-check-sway-examples:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Check Sway examples formatting
run: cargo run --locked -p forc-fmt -- --check --path ./examples
forc-fmt-check-panic:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install forc-fmt
run: cargo install --locked --debug --path ./forc-plugins/forc-fmt
- name: Run the formatter against all sway projects and fail if any of them panic
run: scripts/formatter/forc-fmt-check-panic.sh
check-sdk-harness-test-suite-compatibility:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
- name: Install toml-cli
run: cargo install toml-cli
- name: Read and compare versions
env:
PACKAGE_NAMES: "fuel-core-client" # multiple packages can be specified delimeted with `,`.
run: |
.github/workflows/scripts/check-sdk-harness-version.sh
build-mdbook:
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: buildjet/cache@v3
with:
path: |
~/.cargo/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Install Forc plugins
run: |
cargo install --locked --debug --path ./forc-plugins/forc-fmt
cargo install --locked --debug --path ./forc-plugins/forc-lsp
cargo install --locked --debug --path ./forc-plugins/forc-client
cargo install --locked --debug --path ./forc-plugins/forc-debug
cargo install --locked --debug --path ./forc-plugins/forc-doc
cargo install --locked --debug --path ./forc-plugins/forc-tx
cargo install --locked --debug --path ./forc-plugins/forc-crypto
cargo install --locked --debug forc-explore
- name: Install mdbook-forc-documenter
run: cargo install --locked --debug --path ./scripts/mdbook-forc-documenter
- name: Run mdbook build
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: "0.4.25"
- name: Emit book logs to tmp.txt, fail if build logs contain 'ERROR'
run: |
MDBOOK_preprocessor__FORC_documenter__STRICT="true" mdbook build docs/book 2>&1 | tee tmp.txt
if cat tmp.txt | grep 'ERROR'
then
cat tmp.txt
rm tmp.txt && exit 1
else
rm tmp.txt && exit 0
fi
- name: Emit reference logs to tmp.txt, fail if build logs contain 'ERROR'
run: |
mdbook build docs/reference
mdbook build docs/reference &> tmp.txt
if cat tmp.txt | grep 'ERROR'
then
cat tmp.txt
rm tmp.txt && exit 1
else
rm tmp.txt && exit 0
fi
build-forc-doc-sway-lib-std:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Install Forc plugins
run: |
cargo install --locked --debug --path ./forc-plugins/forc-doc
- name: Build sway-lib-std docs
run: forc doc --manifest-path ./sway-lib-std
build-forc-test-project:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: wasm32-unknown-unknown
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Initialize test project
run: forc new test-proj
- name: Update project forc manifest to use local sway-lib-std
run: echo "std = { path = \"../sway-lib-std/\" }" >> test-proj/Forc.toml
- name: Build test project
run: forc build --path test-proj
# TODO: Re-add this upon landing unit test support: #1832
# - name: Run test project's test suite
# run: (cd test-proj && forc test)
- name: Install cargo-generate
run: cargo install --locked cargo-generate
- name: Install fuel-core
run: cargo install --locked fuel-core-bin
- name: Generate Rust Integration Tests
run: (cd test-proj && cargo generate --init --path ../templates/sway-test-rs --name test-proj)
- name: Update project cargo manifest with workspace
run: |
echo "
[workspace]" >> test-proj/Cargo.toml
- name: Build and Run Default Integration Test
run: (cd test-proj && cargo test --release)
cargo-build-workspace:
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: "Build Workspace"
run: cargo build --locked --workspace --all-features --all-targets
env:
RUSTFLAGS: "-D warnings"
cargo-clippy:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
components: clippy
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Check Clippy Linter
run: cargo clippy --all-features --all-targets -- -D warnings
cargo-toml-fmt-check:
runs-on: ubuntu-latest # Switching this runner to buildjet causes failure.
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Install Cargo.toml linter
uses: baptiste0928/cargo-install@v1
with:
crate: cargo-toml-lint
version: "0.1"
- name: Run Cargo.toml linter
run: git ls-files | grep Cargo.toml$ | grep -v 'templates/' | xargs --verbose -n 1 cargo-toml-lint
cargo-fmt-check:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt
- name: Check Formatting
run: cargo fmt --all -- --check
cargo-run-e2e-test:
runs-on: buildjet-4vcpu-ubuntu-2204
needs: get-fuel-core-version
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown"
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install fuel-core for tests
run: |
curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz
tar -xvf fuel-core.tar.gz
chmod +x fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core
mv fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core /usr/local/bin/fuel-core
- name: Cargo Run E2E Tests (Fuel VM)
run: |
fuel-core run --db-type in-memory --debug &
sleep 5 &&
cargo run --locked --release --bin test -- --locked
cargo-run-e2e-test-release:
runs-on: buildjet-4vcpu-ubuntu-2204
needs: get-fuel-core-version
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown"
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install fuel-core for tests
run: |
curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz
tar -xvf fuel-core.tar.gz
chmod +x fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core
mv fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core /usr/local/bin/fuel-core
- name: Cargo Run E2E Tests (Fuel VM)
run: |
fuel-core run --db-type in-memory --debug &
sleep 5 &&
cargo run --locked --release --bin test -- --locked --release
cargo-run-e2e-test-evm:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown"
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Cargo Run E2E Tests (EVM)
run: cargo run --locked --release --bin test -- --target evm --locked --no-encoding-v1
# TODO: Remove this upon merging std tests with the rest of the E2E tests.
cargo-test-lib-std:
runs-on: buildjet-8vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown"
- uses: buildjet/cache@v3
with:
path: |
~/.cargo/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build All Tests
run: cargo run --locked --release -p forc -- build --release --locked --path ./test/src/sdk-harness
- name: Cargo Test sway-lib-std
run: cargo test --locked --release --manifest-path ./test/src/sdk-harness/Cargo.toml -- --nocapture
forc-run-benchmarks:
runs-on: buildjet-4vcpu-ubuntu-2204
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Run benchmarks
run: ./benchmark.sh
- name: Checkout benchmark data
if: github.event_name != 'push'
uses: actions/checkout@v3
with:
repository: FuelLabs/sway-performance-data
path: performance-data
- name: Checkout benchmark data
if: github.event_name == 'push'
uses: actions/checkout@v3
with:
repository: FuelLabs/sway-performance-data
path: performance-data
token: ${{ secrets.CI_ACCOUNT_PAT }}
- name: Prepare benchmarks data for commit
if: github.event_name == 'push'
run: ./benchmark.sh --prepare-for-commit
- uses: EndBug/add-and-commit@v9
with:
cwd: "./performance-data"
message: "Updated benchmark data"
default_author: github_actions
forc-unit-tests:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install Forc
run: cargo install --locked --debug --path ./forc
- name: Run Core Unit Tests
run: forc build --path sway-lib-core && forc test --path sway-lib-core
- name: Run Std Unit Tests
run: forc build --path sway-lib-std && forc test --path sway-lib-std
- name: Run In Language Unit Tests
run: forc build --path test/src/in_language_tests && forc test --path test/src/in_language_tests
forc-pkg-fuels-deps-check:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
# We require this check to avoid cyclic dependencies between 'fuels' and 'forc-pkg'.
# Detailed explanation is found in the echo below.
- name: Check 'forc-pkg' dependencies for 'fuels' crates
run: |
deps=$(cargo tree --manifest-path forc-pkg/Cargo.toml)
case "$deps" in
*fuels*)
echo -e "\nFound dependency on a 'fuels' crate.
To avoid cyclic dependencies between 'fuels' and 'forc-pkg',
we want to avoid using 'fuels' crates in 'forc-pkg' since 'fuels-rs' depends on 'forc-pkg' for its integration tests.
To fix this, please remove any 'fuels' dependency from forc-pkg/Cargo.toml.
Detailed explanation here: https://github.com/FuelLabs/fuels-rs/issues/752#issuecomment-1386242106"
exit 1
;;
*)
exit 0
;;
esac
cargo-test-forc-debug:
runs-on: buildjet-4vcpu-ubuntu-2204
needs: get-fuel-core-version
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown"
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install fuel-core for tests
run: |
curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz
tar -xvf fuel-core.tar.gz
chmod +x fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core
mv fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core /usr/local/bin/fuel-core
- name: Run tests
run: cargo test --locked --release -p forc-debug
cargo-test-forc-client:
runs-on: buildjet-4vcpu-ubuntu-2204
needs: get-fuel-core-version
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
targets: "x86_64-unknown-linux-gnu, wasm32-unknown-unknown"
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install fuel-core for tests
run: |
curl -sSLf https://github.com/FuelLabs/fuel-core/releases/download/v${{ needs.get-fuel-core-version.outputs.fuel_core_version }}/fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu.tar.gz -L -o fuel-core.tar.gz
tar -xvf fuel-core.tar.gz
chmod +x fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core
mv fuel-core-${{ needs.get-fuel-core-version.outputs.fuel_core_version }}-x86_64-unknown-linux-gnu/fuel-core /usr/local/bin/fuel-core
- name: Run tests
run: cargo test --locked --release -p forc-client -- --test-threads 1
cargo-test-sway-lsp:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Setup Rust and cargo-nextest
uses: moonrepo/setup-rust@v0
with:
channel: stable
cache-target: release
bins: cargo-nextest
- name: Run sway-lsp tests sequentially
env:
RUST_BACKTRACE: full
run: cargo nextest run --locked --release -p sway-lsp --no-capture --profile ci --config-file sway-lsp/tests/nextest.toml
cargo-test-forc:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Run forc tests separately
env:
RUST_BACKTRACE: full
run: cargo test --locked --release -p forc -- --nocapture
cargo-test-workspace:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Run tests
run: cargo test --locked --release --workspace --exclude forc-debug --exclude sway-lsp --exclude forc-client --exclude forc
cargo-unused-deps-check:
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
# `cargo-udeps` requires nightly to run
toolchain: ${{ env.NIGHTLY_RUST_VERSION }}
- uses: Swatinem/rust-cache@v2
with:
cache-provider: "buildjet"
- name: Install cargo-udeps
run: cargo install --locked cargo-udeps
- name: Check Unused Deps
run: cargo udeps --locked --all-targets
notify-slack-on-failure:
needs:
[
build-forc-test-project,
build-sway-examples,
build-sway-lib-core,
build-sway-lib-std,
cargo-build-workspace,
cargo-clippy,
cargo-fmt-check,
cargo-run-e2e-test,
cargo-run-e2e-test-evm,
cargo-test-lib-std,
cargo-test-workspace,
cargo-test-sway-lsp,
cargo-unused-deps-check,
]
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Notify Slack On Failure
uses: ravsamhq/notify-slack-action@v2
if: always() && github.ref == 'refs/heads/master'
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
# This job carries out some validation steps to prepare for a publish.
# This is a separate job because we want this to fail fast if something is invalid here.
pre-publish-check:
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Verify tag version
run: |
cargo install toml-cli
./.github/workflows/scripts/verify_tag.sh ${{ github.ref_name }}
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v2
if: always()
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
publish:
# Only do this job if publishing a release
needs:
[
build-forc-test-project,
build-sway-examples,
build-sway-lib-core,
build-sway-lib-std,
cargo-build-workspace,
cargo-clippy,
cargo-fmt-check,
cargo-run-e2e-test,
cargo-run-e2e-test-evm,
cargo-test-lib-std,
cargo-test-workspace,
cargo-test-sway-lsp,
cargo-unused-deps-check,
pre-publish-check,
]
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: buildjet-4vcpu-ubuntu-2204
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
- name: Publish crate
uses: FuelLabs/publish-crates@v1
with:
publish-delay: 30000
registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v2
if: always()
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
build-publish-master-image:
needs:
[
build-forc-test-project,
build-sway-examples,
build-sway-lib-core,
build-sway-lib-std,
cargo-build-workspace,
cargo-clippy,
cargo-fmt-check,
cargo-run-e2e-test,
cargo-run-e2e-test-evm,
cargo-test-lib-std,
cargo-test-workspace,
cargo-test-sway-lsp,
cargo-unused-deps-check,
]
if: github.ref == 'refs/heads/master'
runs-on: buildjet-4vcpu-ubuntu-2204
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/fuellabs/forc
tags: |
type=sha
type=ref,event=branch
type=ref,event=tag
flavor: |
latest=${{ github.ref == 'refs/heads/master' }}
labels: |
org.opencontainers.image.title=forc
org.opencontainers.image.description=Fuel Orchestrator.
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to the ghcr.io registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the image to ghcr.io
uses: docker/build-push-action@v2
with:
context: .
file: deployment/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v2
if: always()
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
build-publish-release-image:
# Build & Publish Docker Image Per Sway Release
needs: publish
runs-on: buildjet-4vcpu-ubuntu-2204
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/fuellabs/sway
tags: |
type=semver,pattern={{raw}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Log in to the ghcr.io registry
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push the image to ghcr.io
uses: docker/build-push-action@v2
with:
context: .
file: deployment/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Notify if Job Fails
uses: ravsamhq/notify-slack-action@v2
if: always()
with:
status: ${{ job.status }}
token: ${{ secrets.GITHUB_TOKEN }}
notification_title: "{workflow} has {status_message}"
message_format: "{emoji} *{workflow}* {status_message} in <{repo_url}|{repo}> : <{run_url}|View Run Results>"
footer: ""
notify_when: "failure"
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_NOTIFY_BUILD }}
build-and-release-forc-binaries:
name: Build and upload forc binaries to release
runs-on: ${{ matrix.job.os }}
if: github.event_name == 'release' && github.event.action == 'published'
needs: publish
strategy:
matrix:
job:
- os: ubuntu-20.04
platform: linux
target: x86_64-unknown-linux-gnu
arch: amd64
svm_target_platform: linux-amd64
- os: ubuntu-20.04
platform: linux
target: aarch64-unknown-linux-gnu
arch: arm64
svm_target_platform: linux-aarch64
- os: macos-latest
platform: darwin
target: x86_64-apple-darwin
arch: amd64
svm_target_platform: macosx-amd64
- os: macos-latest
platform: darwin
target: aarch64-apple-darwin
arch: arm64
svm_target_platform: macosx-aarch64
steps:
- name: Checkout sources
uses: actions/checkout@v3
- name: Install toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ env.RUST_VERSION }}
target: ${{ matrix.job.target }}
- uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
key: "${{ matrix.job.target }}"
- name: Use Cross
uses: baptiste0928/cargo-install@v1
with:
crate: cross
cache-key: "${{ matrix.job.target }}"
- name: Build forc binaries
run: |
cross build --profile=release --target ${{ matrix.job.target }} --bins
- name: Strip release binaries x86_64-linux-gnu
if: matrix.job.target == 'x86_64-unknown-linux-gnu'
run: |
for BINARY in forc forc-fmt forc-lsp forc-debug forc-deploy forc-run forc-doc forc-crypto forc-tx forc-submit; do
strip "target/${{ matrix.job.target }}/release/$BINARY"
done
- name: Strip release binaries aarch64-linux-gnu
if: matrix.job.target == 'aarch64-unknown-linux-gnu'
run: |
for BINARY in forc forc-fmt forc-lsp forc-debug forc-deploy forc-run forc-doc forc-crypto forc-tx forc-submit; do
docker run --rm -v \
"$PWD/target:/target:Z" \
ghcr.io/cross-rs/${{ matrix.job.target }}:main \
aarch64-linux-gnu-strip \
/target/${{ matrix.job.target }}/release/$BINARY
done
- name: Strip release binaries mac
if: matrix.job.os == 'macos-latest'
run: |
for BINARY in forc forc-fmt forc-lsp forc-debug forc-deploy forc-run forc-doc forc-crypto forc-tx forc-submit; do
strip -x "target/${{ matrix.job.target }}/release/$BINARY"
done
- name: Prep Assets
id: prep_assets
env:
PLATFORM_NAME: ${{ matrix.job.platform }}
TARGET: ${{ matrix.job.target }}
ARCH: ${{ matrix.job.arch }}
run: |
ZIP_FILE_NAME=forc-binaries-${{ env.PLATFORM_NAME }}_${{ env.ARCH }}.tar.gz
echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV
mkdir -pv ./forc-binaries
for BINARY in forc forc-fmt forc-lsp forc-debug forc-deploy forc-run forc-doc forc-crypto forc-tx forc-submit; do
cp "target/${{ matrix.job.target }}/release/$BINARY" ./forc-binaries
done
tar -czvf $ZIP_FILE_NAME ./forc-binaries
- name: Archive forc binaries
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ github.token }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./${{ env.ZIP_FILE_NAME }}
asset_name: ${{ env.ZIP_FILE_NAME }}
asset_content_type: application/gzip