-
Notifications
You must be signed in to change notification settings - Fork 27
1032 lines (998 loc) · 35.6 KB
/
bencher.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
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
name: Bencher
on:
workflow_dispatch:
push:
branches: [main, devel]
tags: [v**]
pull_request:
branches: [main, devel]
env:
# General
CARGO_TERM_COLOR: always
GITHUB_REGISTRY: ghcr.io
FLY_REGISTRY: registry.fly.io
MOLD_VERSION: 2.0.0
# API
API_BUILDER_DOCKER_IMAGE: bencher-api-builder
API_LOCAL_DOCKER_IMAGE: bencher-api-local
API_LITESTREAM_DOCKER_IMAGE: bencher-api-litestream
# CLI
CLI_BIN_NAME: bencher
CLI_BIN_ARCH: amd64
CLI_DEB_DIR: deb
# Use minimum supported glibc version for Rust Tier 1
# https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-1-with-host-tools
GLIBC_VERSION: 2.17
# WASM
WASM_BENCHER_VALID: bencher-valid-pkg
# UI
UI_BUILDER_DOCKER_IMAGE: bencher-ui-builder
UI_DOCKER_IMAGE: bencher-ui
UI_BUILD_DIST: bencher-ui-dist
# Dev Container
DEV_CONTAINER_DOCKER_IMAGE: bencher-dev-container
jobs:
first_time_interaction:
name: Bencher First Time Interaction
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: |-
🐰 Congratulations on your first issue! 🎉
If you haven't already, hop on over to our [Discord server](https://discord.gg/yGEsdUh7R4).
<br />
<p align="center"><a href="https://discord.gg/yGEsdUh7R4"><img src="https://s3.amazonaws.com/public.bencher.dev/discord_invite.png" alt="Bencher Discord Server" /></a></p>
pr-message: |-
🐰 Congratulations on your first PR! 🎉
If you haven't already, hop on over to our [Discord server](https://discord.gg/yGEsdUh7R4).
<br />
<p align="center"><a href="https://discord.gg/yGEsdUh7R4"><img src="https://s3.amazonaws.com/public.bencher.dev/discord_invite.png" alt="Bencher Discord Server" /></a></p>
bencher_github_action:
name: Bencher CLI GitHub Action
runs-on: ubuntu-latest
# This will fail during releases builds
# because the version number requested is for the current, in progress release
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Build next Bencher CLI GitHub Action
working-directory: ./services/action
run: |
npm install --include=dev
npm run build
- uses: bencherdev/bencher@main
- name: Run current Bencher CLI GitHub Action
run: bencher run --project bencher --dry-run "bencher mock"
# Pretty Rust
cargo_fmt:
name: Cargo Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add fmt
run: rustup component add rustfmt
- name: Run fmt
run: cargo fmt -- --check
cargo_clippy:
name: Cargo Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Add clippy
run: rustup component add clippy
- name: Run clippy
run: cargo clippy --no-deps -- -Dwarnings
# Cargo Test
cargo_test:
name: Cargo Test
runs-on: ubuntu-latest
env:
TEST_BILLING_KEY: ${{ secrets.TEST_BILLING_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: cargo test
run: RUST_BACKTRACE=1 cargo test -- --nocapture
- name: Upload Perf JPEG
uses: actions/upload-artifact@v3
with:
name: perf.jpeg
path: ./lib/bencher_plot/perf.jpeg
open_api_spec:
name: OpenAPI Spec
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-swagger-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Generate OpenAPI Spec
run: cargo xtask swagger
- name: Check for changes
run: git diff --exit-code
# API Smoke Test
api_smoke_test:
name: API Smoke Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-api-smoke-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Install `bencher` CLI
run: cargo install --path services/cli --locked --force
- name: Run API Smoke Test
run: ./scripts/smoke_test.sh
api_smoke_test_compat:
name: API Smoke Test Compat
runs-on: ubuntu-latest
# This will fail whenever there is a breaking change in the API
# Pre-1.0 this is okay but good to be aware of
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-api-smoke-compat-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- uses: bencherdev/bencher@main
- name: Run API Smoke Test
run: ./scripts/smoke_test.sh
# Cargo Check (Minus)
cargo_check_api_minus:
name: Cargo Check API (Minus)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-api-minus${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: cargo check
working-directory: ./services/api
run: cargo check --no-default-features
cargo_check_cli_minus:
name: Cargo Check CLI (Minus)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-cli-minus${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: cargo check
working-directory: ./services/cli
run: cargo check --no-default-features
# Cargo Benchmark
cargo_bench:
name: Cargo Bench
runs-on: ubuntu-latest
# This will fail whenever Bencher Cloud is down
# or there are any breaking changes to the report format
continue-on-error: true
env:
BENCHER_PROJECT: bencher
BENCHER_TESTBED: ubuntu-latest
BENCHER_ADAPTER: rust
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-bench-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Install `bencher` CLI
run: cargo install --path services/cli --locked --force
- name: Dogfooding Benchmarks with Bencher
run: |
bencher run \
--if-branch "$GITHUB_REF_NAME" \
--else-if-branch "$GITHUB_BASE_REF" \
--err \
--github-actions ${{ secrets.GITHUB_TOKEN }} \
"cargo bench --package bencher_adapter"
# Cargo Audit
cargo_audit:
name: Cargo Audit
runs-on: ubuntu-latest
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-audit-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- uses: actions-rs/audit-check@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Cargo Unused Deps
cargo_udeps:
name: Cargo Unused Deps
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-udeps-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Install nightly toolchain
run: rustup toolchain install nightly
- name: Install udeps
run: cargo install --version 0.1.42 --locked --force cargo-udeps
- name: Run API udeps
working-directory: ./services/api
run: cargo +nightly udeps --all-targets
- name: Run CLI udeps
working-directory: ./services/cli
run: cargo +nightly udeps --all-targets --features seed
# Pretty JS
npx_biome_format:
name: Biome Format
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Biome format Action
working-directory: ./services/action
run: |
npm install --include=dev
npx biome ci --linter-enabled false --organize-imports-enabled false .
- name: Biome format Console UI
working-directory: ./services/console
run: |
npm install --include=dev
npx biome ci --linter-enabled false --organize-imports-enabled false .
npx_biome_lint:
name: Biome Lint
runs-on: ubuntu-latest
# TODO fix all lints
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Biome check Action
working-directory: ./services/action
run: |
npm install --include=dev
npx biome ci --formatter-enabled false --organize-imports-enabled false .
- name: Biome check Console UI
working-directory: ./services/console
run: |
npm install --include=dev
npx biome ci --formatter-enabled false --organize-imports-enabled false .
# UI WASM
build_bencher_valid_wasm:
name: Build `bencher_valid` WASM
runs-on: ubuntu-latest
env:
WASM_PACK_BUILD: "wasm-pack build --target web --no-default-features --features plus,wasm"
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-valid-build-${{ hashFiles('**/Cargo.lock') }}
- uses: jetli/[email protected]
- name: WASM pack `bencher_valid`
working-directory: ./lib/bencher_valid
run: |
$WASM_PACK_BUILD || \
$WASM_PACK_BUILD || \
$WASM_PACK_BUILD
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.WASM_BENCHER_VALID }}
path: ./lib/bencher_valid/pkg
test_bencher_valid_wasm:
name: Test `bencher_valid` WASM
runs-on: ubuntu-latest
needs: build_bencher_valid_wasm
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-valid-test-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: cargo test `bencher_valid` WASM
working-directory: ./lib/bencher_valid
run: cargo test --no-default-features --features plus,wasm
# NPM Test
npx_vitest:
name: vitest
runs-on: ubuntu-latest
needs: build_bencher_valid_wasm
steps:
- uses: actions/checkout@v4
- name: Download `bencher_valid` Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.WASM_BENCHER_VALID }}
path: ./lib/bencher_valid/pkg
- name: npx vitest
working-directory: ./services/console
run: |
npm install --include=dev
npx vitest run
# API Docker
# https://docs.docker.com/build/ci/github-actions/named-contexts/#using-with-a-container-builder
# https://www.kenmuse.com/blog/implementing-docker-layer-caching-in-github-actions/
build_local_api_docker:
name: Build Local API
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Builder Stage
uses: docker/build-push-action@v5
with:
context: .
file: ./services/api/builder.Dockerfile
tags: localhost:5000/${{ env.API_BUILDER_DOCKER_IMAGE }}
build-args: |
MOLD_VERSION=${{ env.MOLD_VERSION }}
cache-from: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_BUILDER_DOCKER_IMAGE }}:cache-${{ github.ref_name }}
cache-to: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_BUILDER_DOCKER_IMAGE }}:cache-${{ github.ref_name }},mode=max
push: true
- name: Tag Cached Builder
run: docker image ls -a
- name: Build Local API
uses: docker/build-push-action@v5
with:
context: ./services/api
file: ./services/api/local.Dockerfile
tags: ${{ env.API_LOCAL_DOCKER_IMAGE }}
cache-from: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_LOCAL_DOCKER_IMAGE }}:cache-${{ github.ref_name }}
cache-to: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_LOCAL_DOCKER_IMAGE }}:cache-${{ github.ref_name }},mode=max
build-contexts: |
${{ env.API_BUILDER_DOCKER_IMAGE }}=docker-image://localhost:5000/${{ env.API_BUILDER_DOCKER_IMAGE }}:latest
load: true
push: false
- name: Save Local API
run: |
docker save ${{ env.API_LOCAL_DOCKER_IMAGE }} \
| gzip > ${{ env.API_LOCAL_DOCKER_IMAGE }}.tar.gz
- name: Upload Local API Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.API_LOCAL_DOCKER_IMAGE }}.tar.gz
path: ./${{ env.API_LOCAL_DOCKER_IMAGE }}.tar.gz
build_litestream_api_docker:
name: Build Litestream API
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Builder Stage
uses: docker/build-push-action@v5
with:
context: .
file: ./services/api/builder.Dockerfile
tags: localhost:5000/${{ env.API_BUILDER_DOCKER_IMAGE }}
build-args: |
MOLD_VERSION=${{ env.MOLD_VERSION }}
cache-from: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_BUILDER_DOCKER_IMAGE }}:cache-${{ github.ref_name }}
cache-to: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_BUILDER_DOCKER_IMAGE }}:cache-${{ github.ref_name }},mode=max
push: true
- name: Build Litestream API
uses: docker/build-push-action@v5
with:
context: ./services/api
file: ./services/api/litestream.Dockerfile
tags: ${{ env.API_LITESTREAM_DOCKER_IMAGE }}
cache-from: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_LITESTREAM_DOCKER_IMAGE }}:cache-${{ github.ref_name }}
cache-to: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_LITESTREAM_DOCKER_IMAGE }}:cache-${{ github.ref_name }},mode=max
build-contexts: |
${{ env.API_BUILDER_DOCKER_IMAGE }}=docker-image://localhost:5000/${{ env.API_BUILDER_DOCKER_IMAGE }}:latest
load: true
push: false
- name: Save Litestream API
run: |
docker save ${{ env.API_LITESTREAM_DOCKER_IMAGE }} \
| gzip > ${{ env.API_LITESTREAM_DOCKER_IMAGE }}.tar.gz
- name: Upload Litestream API Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.API_LITESTREAM_DOCKER_IMAGE }}.tar.gz
path: ./${{ env.API_LITESTREAM_DOCKER_IMAGE }}.tar.gz
# CLI
build_cli_bin:
name: Build CLI
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-cli-zig-${{ hashFiles('**/Cargo.lock') }}
- uses: goto-bus-stop/setup-zig@v2
- name: Install zigbuild
run: cargo install --version 0.16.11 --locked --force cargo-zigbuild
- name: cargo build CLI
working-directory: ./services/cli
run: cargo zigbuild --release --target x86_64-unknown-linux-gnu.${{ env.GLIBC_VERSION }}
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.CLI_BIN_NAME }}
path: ./target/x86_64-unknown-linux-gnu/release/${{ env.CLI_BIN_NAME }}
build_cli_deb:
name: Package CLI (.deb)
runs-on: ubuntu-latest
needs: build_cli_bin
steps:
- uses: actions/checkout@v4
- name: Download CLI Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.CLI_BIN_NAME }}
- name: Build .deb package
run: |
./scripts/deb.sh $CLI_BIN_NAME $(./scripts/version.sh) $CLI_BIN_ARCH $CLI_DEB_DIR
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-environment-variable
echo "DEB_FILE=${CLI_BIN_NAME}_$(./scripts/version.sh)_${CLI_BIN_ARCH}.deb" >> $GITHUB_ENV
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.DEB_FILE }}
path: ${{ env.CLI_DEB_DIR }}/${{ env.DEB_FILE }}
build_ui_docker:
name: Build Console UI Docker
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v4
- name: Setup Docker buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: network=host
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build Builder Stage
uses: docker/build-push-action@v5
with:
context: .
file: ./services/console/builder.Dockerfile
tags: localhost:5000/${{ env.UI_BUILDER_DOCKER_IMAGE }}
build-args: |
MOLD_VERSION=${{ env.MOLD_VERSION }}
cache-from: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.UI_BUILDER_DOCKER_IMAGE }}:cache-${{ github.ref_name }}
cache-to: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.UI_BUILDER_DOCKER_IMAGE }}:cache-${{ github.ref_name }},mode=max
push: true
- name: Build Console UI
uses: docker/build-push-action@v5
with:
context: ./services/console
tags: ${{ env.UI_DOCKER_IMAGE }}
cache-from: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.UI_DOCKER_IMAGE }}:cache-${{ github.ref_name }}
cache-to: type=registry,ref=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.UI_DOCKER_IMAGE }}:cache-${{ github.ref_name }},mode=max
build-contexts: |
${{ env.UI_BUILDER_DOCKER_IMAGE }}=docker-image://localhost:5000/${{ env.UI_BUILDER_DOCKER_IMAGE }}:latest
load: true
push: false
- name: Save Console UI
run: |
docker save ${{ env.UI_DOCKER_IMAGE }} \
| gzip > ${{ env.UI_DOCKER_IMAGE }}.tar.gz
- name: Upload Console UI Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.UI_DOCKER_IMAGE }}.tar.gz
path: ./${{ env.UI_DOCKER_IMAGE }}.tar.gz
build_ui:
if: true && !startsWith(github.ref, 'refs/tags/')
name: Build Console UI
runs-on: ubuntu-latest
needs: build_bencher_valid_wasm
steps:
- uses: actions/checkout@v4
- name: Download `bencher_valid` Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.WASM_BENCHER_VALID }}
path: ./lib/bencher_valid/pkg
- name: Build Console UI
working-directory: ./services/console
run: npm run netlify
# API Fly.io
deploy_local_api_fly:
if: github.ref == 'refs/heads/devel'
name: Deploy Local API to Fly.io
runs-on: ubuntu-latest
needs:
- build_local_api_docker
- build_ui
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Download Local Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.API_LOCAL_DOCKER_IMAGE }}.tar.gz
- name: Load & Tag Local Image
run: |
docker load < ${{ env.API_LOCAL_DOCKER_IMAGE }}.tar.gz
docker tag ${{ env.API_LOCAL_DOCKER_IMAGE }} ${{ env.FLY_REGISTRY }}/bencher-api-dev
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy Local API to Fly.io
working-directory: ./services/api
run: flyctl deploy --local-only --config fly.dev.toml --wait-timeout 300
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-xtask-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Run Fly.io Dev Test
run: cargo xtask fly-test --dev
backup_database:
if: github.ref == 'refs/heads/main'
name: Backup Database
runs-on: ubuntu-latest
# continue-on-error: true
needs:
# Lint
- cargo_fmt
- cargo_clippy
- npx_biome_format
- npx_biome_lint
# Test
- cargo_test
- open_api_spec
- api_smoke_test
- api_smoke_test_compat
- cargo_bench
- cargo_audit
- cargo_udeps
- test_bencher_valid_wasm
- npx_vitest
# Build
- build_litestream_api_docker
- build_ui
- build_cli_bin
env:
BENCHER_API_TOKEN: ${{ secrets.BENCHER_API_TOKEN_ADMIN }}
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-cli-backup-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Install `bencher` CLI
run: cargo install --path services/cli --locked --force
- name: Backup API Server Database
run: bencher server backup --compress --data-store aws_s3 --rm
deploy_litestream_api_fly:
name: Deploy Litestream API to Fly.io Prod
runs-on: ubuntu-latest
needs: backup_database
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Download Litestream Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.API_LITESTREAM_DOCKER_IMAGE }}.tar.gz
- name: Load & Tag Litestream Image
run: |
docker load < ${{ env.API_LITESTREAM_DOCKER_IMAGE }}.tar.gz
docker tag ${{ env.API_LITESTREAM_DOCKER_IMAGE }} ${{ env.FLY_REGISTRY }}/bencher-api
- uses: superfly/flyctl-actions/setup-flyctl@master
- name: Deploy Litestream API to Fly.io
working-directory: ./services/api
run: flyctl deploy --local-only --config fly.toml --wait-timeout 300
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-xtask-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Run Fly.io Test
run: cargo xtask fly-test
# UI Netlify
deploy_ui_netlify_dev:
name: Deploy Console UI to Netlify
runs-on: ubuntu-latest
needs: deploy_local_api_fly
steps:
- uses: actions/checkout@v4
- name: Download `bencher_valid` Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.WASM_BENCHER_VALID }}
path: ./lib/bencher_valid/pkg
- name: Build Console UI
working-directory: ./services/console
run: npm run netlify
- uses: netlify/actions/cli@master
id: netlify
with:
args: |
deploy \
--alias ${GITHUB_REF#refs/*/} \
--message "${{ github.event.head_commit.message }}"
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-xtask-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
# https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context
# https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#tojson
# https://github.com/netlify/actions/blob/375963b92b795c7b979927c580dd6f2a65ebcf28/cli/entrypoint.sh#L20
- name: Run Netlify Dev Test
run: |
echo '${{ toJson(steps.netlify.outputs) }}' > ./netlify.json
cargo xtask netlify-test --dev
deploy_ui_netlify_prod:
name: Deploy UI to Netlify Prod
runs-on: ubuntu-latest
needs: deploy_litestream_api_fly
steps:
- uses: actions/checkout@v4
- name: Download `bencher_valid` Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.WASM_BENCHER_VALID }}
path: ./lib/bencher_valid/pkg
- name: Build Console UI
working-directory: ./services/console
run: npm run netlify
- uses: netlify/actions/cli@master
id: netlify
with:
args: |
deploy \
--alias ${GITHUB_REF#refs/*/} \
--message "${{ github.event.head_commit.message }}" \
--prod
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-xtask-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
# https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context
# https://docs.github.com/en/enterprise-cloud@latest/actions/learn-github-actions/expressions#tojson
# https://github.com/netlify/actions/blob/375963b92b795c7b979927c580dd6f2a65ebcf28/cli/entrypoint.sh#L20
- name: Run Netlify Test
run: |
echo '${{ toJson(steps.netlify.outputs) }}' > ./netlify.json
cargo xtask netlify-test
deploy_prod_notify:
name: Notify of deployment
runs-on: ubuntu-latest
needs: deploy_ui_netlify_prod
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-xtask-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}
- name: Notify of deployment
run: cargo xtask notify "Deployed ${{ github.ref_name }}"
# Release
release_bencher:
if: startsWith(github.ref, 'refs/tags/')
name: Release Bencher
runs-on: ubuntu-latest
needs:
# Lint
- cargo_fmt
- cargo_clippy
- npx_biome_format
- npx_biome_lint
# Test
- cargo_test
- open_api_spec
- api_smoke_test
- api_smoke_test_compat
- cargo_check_api_minus
- cargo_check_cli_minus
- cargo_bench
- cargo_audit
- cargo_udeps
- test_bencher_valid_wasm
- npx_vitest
# Integrations
- bencher_github_action
# Build
- build_local_api_docker
- build_litestream_api_docker
- build_cli_deb
- build_ui_docker
steps:
- uses: actions/checkout@v4
# Download
- name: Download Local API Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.API_LOCAL_DOCKER_IMAGE }}.tar.gz
- name: Download Litestream API Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.API_LITESTREAM_DOCKER_IMAGE }}.tar.gz
- name: Download CLI bin artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.CLI_BIN_NAME }}
- name: export DEB_FILE
run: echo "DEB_FILE=${CLI_BIN_NAME}_$(./scripts/version.sh)_${CLI_BIN_ARCH}.deb" >> $GITHUB_ENV
- name: Download CLI .deb Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.DEB_FILE }}
- name: Download UI Artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.UI_DOCKER_IMAGE }}.tar.gz
# Load
- name: Load Local API Image
run: docker load < ${{ env.API_LOCAL_DOCKER_IMAGE }}.tar.gz
- name: Load Litestream API Image
run: docker load < ${{ env.API_LITESTREAM_DOCKER_IMAGE }}.tar.gz
- name: Load UI Image
run: docker load < ${{ env.UI_DOCKER_IMAGE }}.tar.gz
# Login GHCR
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.GITHUB_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Tag & Push
- name: Tag & Push Local API Image
run: |
export GITHUB_IMAGE=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_LOCAL_DOCKER_IMAGE }}
docker tag ${{ env.API_LOCAL_DOCKER_IMAGE }} ${GITHUB_IMAGE}:latest
docker tag ${{ env.API_LOCAL_DOCKER_IMAGE }} ${GITHUB_IMAGE}:${GITHUB_REF#refs/*/}
docker push ${GITHUB_IMAGE}:latest
docker push ${GITHUB_IMAGE}:${GITHUB_REF#refs/*/}
- name: Tag & Push Litestream API Image
run: |
export GITHUB_IMAGE=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.API_LITESTREAM_DOCKER_IMAGE }}
docker tag ${{ env.API_LITESTREAM_DOCKER_IMAGE }} ${GITHUB_IMAGE}:latest
docker tag ${{ env.API_LITESTREAM_DOCKER_IMAGE }} ${GITHUB_IMAGE}:${GITHUB_REF#refs/*/}
docker push ${GITHUB_IMAGE}:latest
docker push ${GITHUB_IMAGE}:${GITHUB_REF#refs/*/}
- name: Tag & Push UI Image
run: |
export GITHUB_IMAGE=${{ env.GITHUB_REGISTRY }}/${{ github.repository_owner }}/${{ env.UI_DOCKER_IMAGE }}
docker tag ${{ env.UI_DOCKER_IMAGE }} ${GITHUB_IMAGE}:latest
docker tag ${{ env.UI_DOCKER_IMAGE }} ${GITHUB_IMAGE}:${GITHUB_REF#refs/*/}
docker push ${GITHUB_IMAGE}:latest
docker push ${GITHUB_IMAGE}:${GITHUB_REF#refs/*/}
- uses: actions/cache@v3
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-xtask-${{ hashFiles('**/Cargo.lock') }}
- uses: rui314/setup-mold@v1
with:
mold-version: ${{ env.MOLD_VERSION }}