-
Notifications
You must be signed in to change notification settings - Fork 3.1k
1637 lines (1453 loc) · 60 KB
/
Copy pathbuild.yml
File metadata and controls
1637 lines (1453 loc) · 60 KB
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: build
permissions: # Principle of least privilege
contents: read
actions: read
on:
push:
branches: [master, nightly, develop, test-ci, test-pre-commit]
pull_request:
branches-ignore: [master, nightly]
concurrency:
# yamllint disable-line rule:line-length
group: ${{ github.workflow }}-${{ github.event.pull_request.number || format('{0}-{1}', github.ref_name, github.sha) }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
# Fork PRs lack repo/org vars, so audit instead of block.
EGRESS_POLICY: >-
${{ github.event.pull_request.head.repo.fork && 'audit'
|| vars.STEP_SECURITY_EGRESS_POLICY
|| 'block' }}
jobs:
plan:
runs-on: ubuntu-latest
outputs:
run-tests: ${{ steps.plan.outputs.run_tests }}
run-rust-tests: ${{ steps.plan.outputs.run_rust_tests }}
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
fetch-depth: 0
persist-credentials: false
- name: Plan
id: plan
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
BASE_REF: ${{ github.event.pull_request.base.ref }}
BEFORE_SHA: ${{ github.event.before }}
run: bash scripts/ci/plan.sh
pre-commit:
# Fork PRs stay GitHub-hosted.
runs-on: >-
${{ github.event.pull_request.head.repo.fork
&& 'ubuntu-22.04'
|| fromJson('["self-hosted", "Linux", "X64", "build"]') }}
env:
# Self-hosted keeps Rust artifacts outside the workspace.
CARGO_TARGET_DIR: >-
${{ github.event.pull_request.head.repo.fork
&& format('{0}/target', github.workspace)
|| '/home/runner/.cache/cargo-target/pre-commit' }}
CARGO_CI_PROFILE: >-
${{ github.event.pull_request.head.repo.fork && 'ci-pr' || 'nextest' }}
# Scopes incremental clippy/doc checks; empty for non-PR/push events.
CHANGED_BASE_SHA: >-
${{ github.event.pull_request.base.sha || github.event.before }}
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
# Full history so changed-file scripts can resolve CHANGED_BASE_SHA.
fetch-depth: 0
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (post-checkout)
run: bash scripts/ci/verify-ci-inputs.sh post-checkout
- name: Common setup
uses: ./.github/actions/common-setup
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
python-version: "3.13"
free-disk-space: "true"
build-type: "pre-commit"
rust-cache-enabled: >-
${{ github.event.pull_request.head.repo.fork && 'true' || 'false' }}
- name: Limit Cargo build jobs on GitHub-hosted runners
if: github.event.pull_request.head.repo.fork
run: echo "CARGO_BUILD_JOBS=2" >> "$GITHUB_ENV"
- name: Run pre-commit
run: prek run --all-files
- name: Verify capnp schemas are up-to-date
run: make check-capnp-schemas
# Dependency license, advisory, and ban checks (master only - gates releases)
# https://embarkstudios.github.io/cargo-deny/
cargo-deny:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Install cargo-deny
uses: ./.github/actions/cargo-tool-install
with:
tool-name: cargo-deny
- name: Run cargo-deny (advisories, licenses, sources, bans)
run: |
cargo deny --all-features check advisories licenses sources bans
cargo deny --manifest-path crates/adapters/lighter/fuzz/Cargo.toml \
--locked --all-features check --config .cargo/deny-fuzz.toml \
advisories licenses sources bans
cargo deny --manifest-path crates/adapters/derive/fuzz/Cargo.toml \
--locked --all-features check --config .cargo/deny-fuzz.toml \
advisories licenses sources bans
# Supply chain security auditing (master only - gates releases)
# https://mozilla.github.io/cargo-vet/configuring-ci.html
cargo-vet:
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-22.04
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Install cargo-vet
uses: ./.github/actions/cargo-tool-install
with:
tool-name: cargo-vet
- name: Run cargo-vet
run: |
cargo vet --locked
cargo vet --locked --manifest-path crates/adapters/lighter/fuzz/Cargo.toml \
--store-path .supply-chain
cargo vet --locked --manifest-path crates/adapters/derive/fuzz/Cargo.toml \
--store-path .supply-chain
build-linux-x86:
if: github.ref != 'refs/heads/test-pre-commit' && needs.plan.outputs.run-tests == 'true'
strategy:
fail-fast: false
matrix:
python-version:
- "3.12"
- "3.13"
- "3.14"
defaults:
run:
shell: bash
# Ubuntu 22.04 (glibc 2.35) keeps the wheel runtime range broad.
# Fork PRs stay GitHub-hosted.
name: build - python ${{ matrix.python-version }} (ubuntu-22.04)
runs-on: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork
&& 'ubuntu-22.04'
|| github.event_name == 'pull_request'
&& fromJson('["self-hosted", "Linux", "X64", "build"]')
|| github.event_name == 'push' && github.ref_name == 'develop'
&& fromJson('["self-hosted", "Linux", "X64", "build"]')
|| fromJson('["depot-ubuntu-22.04-8"]') }}
needs:
- plan
- pre-commit
env:
BUILD_MODE: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork
&& 'ci-pr' || 'release' }}
CARGO_CI_PROFILE: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork
&& 'ci-pr' || 'nextest' }}
PARALLEL_BUILD: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork
&& 'false' || 'true' }}
# Self-hosted develop pushes keep Rust artifacts outside the workspace so
# they survive actions/checkout's git clean -ffdx between runs.
CARGO_TARGET_DIR: >-
${{ github.event_name == 'push' && github.ref_name == 'develop'
&& format('/home/runner/.cache/cargo-target/build-linux-x86/py{0}', matrix.python-version)
|| format('{0}/target/build-linux-x86', github.workspace) }}
RUST_BACKTRACE: 1
# yamllint disable rule:line-length
services:
redis:
image: public.ecr.aws/docker/library/redis:7.4.5-alpine3.21@sha256:bb186d083732f669da90be8b0f975a37812b15e913465bb14d845db72a4e3e08
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: public.ecr.aws/docker/library/postgres:16.4-alpine@sha256:5660c2cbfea50c7a9127d17dc4e48543eedd3d7a41a595a2dfa572471e37e64c
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: pass
POSTGRES_DB: nautilus
ports:
- 5432:5432
options: --health-cmd "pg_isready -U postgres -d nautilus" --health-interval 10s --health-timeout 5s --health-retries
5
# yamllint enable rule:line-length
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (post-checkout)
run: bash scripts/ci/verify-ci-inputs.sh post-checkout
- name: Common setup
uses: ./.github/actions/common-setup
with:
python-version: ${{ matrix.python-version }}
free-disk-space: "true"
# Persistent CARGO_TARGET_DIR on the self-hosted build pool replaces
# Swatinem/rust-cache for develop push builds.
rust-cache-enabled: ${{ github.event_name == 'push' && github.ref_name == 'develop' && 'false' || 'true' }}
rust-cache-key: build-linux-x86
rust-cache-workspaces: . -> target/build-linux-x86
rust-cache-save-if: ${{ github.event_name == 'push' }}
- name: Limit Cargo build jobs on GitHub-hosted runners
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork
run: echo "CARGO_BUILD_JOBS=2" >> "$GITHUB_ENV"
- name: Install Nautilus CLI
env:
NAUTILUS_CLI_FORCE_SOURCE: ${{ github.ref == 'refs/heads/nightly' && '1' || '0' }}
run: bash scripts/ci/install-nautilus-cli.sh
- name: Init postgres schema
run: nautilus database init --schema ${{ github.workspace }}/schema/sql
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: pass
POSTGRES_DATABASE: nautilus
- name: Cached test data
uses: ./.github/actions/common-test-data
# Fork-PR runners vary in disk size; fail early with a clear message
# rather than a cryptic linker Bus error when a small VM runs out.
- name: Check available disk space
if: >-
needs.plan.outputs.run-rust-tests == 'true'
&& github.event_name == 'pull_request'
&& github.event.pull_request.head.repo.fork
run: |
echo "::group::Disk space before Rust tests"
df -h /
echo "::endgroup::"
avail_gb=$(($(df -Pk / | awk 'NR==2 {print $4}') / 1024 / 1024))
echo "Available on / : ${avail_gb}G"
if [ "${avail_gb}" -lt 25 ]; then
echo "::error::Only ${avail_gb}G free, runner too small for the Rust build. Re-run for a larger VM."
exit 1
elif [ "${avail_gb}" -lt 40 ]; then
echo "::warning::Only ${avail_gb}G free, the Rust build may run out of space, re-run if it fails."
fi
- name: Run Rust tests (core)
if: needs.plan.outputs.run-rust-tests == 'true'
run: make cargo-test-core EXTRA_FEATURES="capnp,hypersync" NEXTEST_PROFILE=ci
- name: Run Rust tests (adapters)
if: needs.plan.outputs.run-rust-tests == 'true'
run: make cargo-test-adapters EXTRA_FEATURES="capnp,hypersync" NEXTEST_PROFILE=ci
- name: Clean Rust test artifacts
if: needs.plan.outputs.run-rust-tests == 'true'
run: |
rm -rf "${CARGO_TARGET_DIR}/nextest"
rm -rf "${CARGO_TARGET_DIR}/${CARGO_CI_PROFILE:-nextest}"
df -h . "${CARGO_TARGET_DIR}"
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (pre-wheel build)
run: bash scripts/ci/verify-ci-inputs.sh pre-wheel-build
- name: Build and install wheel
uses: ./.github/actions/common-wheel-build
with:
python-version: ${{ matrix.python-version }}
github_ref: ${{ github.ref }}
- name: Run tests
run: |
uv run --no-sync pytest --ignore=tests/performance_tests \
-n logical --dist=loadgroup --reruns 2 --reruns-delay 1
- name: Upload wheel artifact
uses: ./.github/actions/upload-artifact-wheel
with:
retention-days: ${{ github.ref_name == 'master' && '7' || '1' }}
build-linux-arm:
strategy:
fail-fast: false
matrix:
python-version:
- "3.12"
- "3.13"
- "3.14"
defaults:
run:
shell: bash
name: build - python ${{ matrix.python-version }} (ubuntu-22.04-arm)
runs-on: depot-ubuntu-22.04-arm-8
# ARM stays off PRs, develop pushes, and pre-commit-only test runs.
# yamllint disable-line rule:line-length
if: >
needs.plan.outputs.run-tests == 'true' &&
!(
(github.event_name == 'push' &&
(github.ref_name == 'develop' ||
github.ref_name == 'test-pre-commit'))
|| github.event_name == 'pull_request'
)
needs:
- plan
- pre-commit
env:
BUILD_MODE: release
CARGO_TARGET_DIR: ${{ github.workspace }}/target/build-linux-arm
RUST_BACKTRACE: 1
# yamllint disable rule:line-length
services:
redis:
image: public.ecr.aws/docker/library/redis:7.4.5-alpine3.21@sha256:bb186d083732f669da90be8b0f975a37812b15e913465bb14d845db72a4e3e08
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
postgres:
image: public.ecr.aws/docker/library/postgres:16.4-alpine@sha256:5660c2cbfea50c7a9127d17dc4e48543eedd3d7a41a595a2dfa572471e37e64c
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: pass
POSTGRES_DB: nautilus
ports:
- 5432:5432
options: --health-cmd "pg_isready -U postgres -d nautilus" --health-interval 10s --health-timeout 5s --health-retries
5
# yamllint enable rule:line-length
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (post-checkout)
run: bash scripts/ci/verify-ci-inputs.sh post-checkout
- name: Common setup
uses: ./.github/actions/common-setup
with:
python-version: ${{ matrix.python-version }}
free-disk-space: "true"
rust-cache-key: build-linux-arm
rust-cache-workspaces: . -> target/build-linux-arm
rust-cache-save-if: ${{ github.event_name == 'push' }}
- name: Install Nautilus CLI
env:
NAUTILUS_CLI_FORCE_SOURCE: ${{ github.ref == 'refs/heads/nightly' && '1' || '0' }}
run: bash scripts/ci/install-nautilus-cli.sh
- name: Init postgres schema
run: nautilus database init --schema ${{ github.workspace }}/schema/sql
env:
POSTGRES_HOST: localhost
POSTGRES_PORT: 5432
POSTGRES_USERNAME: postgres
POSTGRES_PASSWORD: pass
POSTGRES_DATABASE: nautilus
- name: Cached test data
uses: ./.github/actions/common-test-data
- name: Run Rust tests (core)
if: needs.plan.outputs.run-rust-tests == 'true'
run: make cargo-test-core EXTRA_FEATURES="capnp" NEXTEST_PROFILE=ci
- name: Run Rust tests (adapters)
if: needs.plan.outputs.run-rust-tests == 'true'
run: make cargo-test-adapters EXTRA_FEATURES="capnp" NEXTEST_PROFILE=ci
- name: Clean Rust test artifacts
if: needs.plan.outputs.run-rust-tests == 'true'
run: |
rm -rf "${CARGO_TARGET_DIR}/nextest"
df -h .
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (pre-wheel build)
run: bash scripts/ci/verify-ci-inputs.sh pre-wheel-build
- name: Build and install wheel
uses: ./.github/actions/common-wheel-build
with:
python-version: ${{ matrix.python-version }}
github_ref: ${{ github.ref }}
- name: Run tests
run: |
uv run --no-sync pytest --ignore=tests/performance_tests --reruns 2 --reruns-delay 1
- name: Upload wheel artifact
uses: ./.github/actions/upload-artifact-wheel
with:
retention-days: ${{ github.ref_name == 'master' && '7' || '1' }}
build-macos:
# macOS stays off develop pushes and pre-commit-only test runs.
if: >
needs.plan.outputs.run-tests == 'true' &&
github.event_name == 'push' &&
github.ref != 'refs/heads/develop' &&
github.ref != 'refs/heads/test-pre-commit'
strategy:
fail-fast: false
matrix:
python-version:
- "3.12"
- "3.13"
- "3.14"
defaults:
run:
shell: bash
name: build - python ${{ matrix.python-version }} (macos)
runs-on: macos-latest
needs:
- plan
- pre-commit
env:
BUILD_MODE: release
CARGO_TARGET_DIR: ${{ github.workspace }}/target/build-macos
RUST_BACKTRACE: 1
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (post-checkout)
run: bash scripts/ci/verify-ci-inputs.sh post-checkout
- name: Log macOS runner version
run: |
echo "::group::macOS runner info"
sw_vers
uname -a
echo "::endgroup::"
- name: Common setup
uses: ./.github/actions/common-setup
with:
python-version: ${{ matrix.python-version }}
free-disk-space: "true"
rust-cache-key: build-macos
rust-cache-workspaces: . -> target/build-macos
rust-cache-on-failure: "false"
rust-cache-save-if: ${{ github.event_name == 'push' }}
uv-cache-enabled: "false"
- name: Cached test data
uses: ./.github/actions/common-test-data
- name: Set compile jobs from cache state
run: bash scripts/ci/set-cargo-build-jobs.sh
- name: Run Rust tests (core)
if: needs.plan.outputs.run-rust-tests == 'true'
run: make cargo-test-core EXTRA_FEATURES="capnp,hypersync" NEXTEST_PROFILE=ci
- name: Run Rust tests (adapters)
if: needs.plan.outputs.run-rust-tests == 'true'
run: make cargo-test-adapters EXTRA_FEATURES="capnp,hypersync" NEXTEST_PROFILE=ci
- name: Clean Rust test artifacts
run: |
rm -rf "${CARGO_TARGET_DIR}/nextest"
rm -rf "${CARGO_TARGET_DIR}/${CARGO_CI_PROFILE:-nextest}"
if [ -d "$CARGO_TARGET_DIR" ]; then
df -h . "$CARGO_TARGET_DIR"
else
df -h .
fi
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (pre-wheel build)
run: bash scripts/ci/verify-ci-inputs.sh pre-wheel-build
- name: Build and install wheel
id: build-wheel
uses: ./.github/actions/common-wheel-build
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/target/build-macos
PARALLEL_BUILD: false
with:
python-version: ${{ matrix.python-version }}
github_ref: ${{ github.ref }}
- name: Diagnose failed macOS wheel build
if: failure() && steps.build-wheel.outcome == 'failure'
env:
# yamllint disable-line rule:line-length
MACOS_WHEEL_TARGET_DIR: ${{ github.workspace }}/target/build-macos/release
run: |
set +e
echo "::group::macOS runner and toolchain"
uname -a
sw_vers
rustc -Vv || true
cargo -Vv || true
python --version || true
which python || true
macos_env_pattern='^(ARCHFLAGS|CARGO[A-Z_]*|DYLD_LIBRARY_PATH|LD_LIBRARY_PATH|'
macos_env_pattern="${macos_env_pattern}LIBRARY_PATH|PYO3[A-Z_]*|RUST[A-Z_]*)="
env | grep -E "$macos_env_pattern" || true
echo "::endgroup::"
if [ ! -d "$MACOS_WHEEL_TARGET_DIR" ]; then
echo "Wheel target dir not found: $MACOS_WHEEL_TARGET_DIR"
exit 0
fi
build_scripts="$(find "$MACOS_WHEEL_TARGET_DIR/build" -type f -name build-script-build | sort)"
echo "::group::macOS build-script artifacts"
if [ -z "$build_scripts" ]; then
echo "No build-script-build artifacts found"
else
while IFS= read -r build_script; do
[ -z "$build_script" ] && continue
echo "--- $build_script"
ls -l "$build_script"
shasum -a 256 "$build_script" || true
file "$build_script" || true
otool -hv "$build_script" || true
done <<< "$build_scripts"
fi
echo "::endgroup::"
echo "::group::macOS Rust archives"
for archive in \
"$MACOS_WHEEL_TARGET_DIR/libnautilus_backtest.a" \
"$MACOS_WHEEL_TARGET_DIR/libnautilus_common.a" \
"$MACOS_WHEEL_TARGET_DIR/libnautilus_core.a" \
"$MACOS_WHEEL_TARGET_DIR/libnautilus_model.a" \
"$MACOS_WHEEL_TARGET_DIR/libnautilus_persistence.a"; do
if [ ! -f "$archive" ]; then
echo "Missing archive: $archive"
continue
fi
echo "--- $archive"
ls -l "$archive"
shasum -a 256 "$archive" || true
file "$archive" || true
ar -t "$archive" | head -n 20 || true
done
echo "::endgroup::"
- name: Run tests
run: |
uv run --no-sync pytest --ignore=tests/performance_tests --reruns 2 --reruns-delay 1
- name: Upload wheel artifact
uses: ./.github/actions/upload-artifact-wheel
with:
retention-days: ${{ github.ref_name == 'master' && '7' || '1' }}
build-windows:
# Windows stays off PRs, develop pushes, and pre-commit-only test runs.
# yamllint disable-line rule:line-length
if: >
needs.plan.outputs.run-tests == 'true' &&
!(
(github.event_name == 'push' &&
(github.ref_name == 'develop' ||
github.ref_name == 'test-pre-commit'))
|| github.event_name == 'pull_request'
)
strategy:
fail-fast: false
matrix:
python-version:
- "3.12"
- "3.13"
- "3.14"
defaults:
run:
shell: bash
name: build - python ${{ matrix.python-version }} (windows)
runs-on: depot-windows-2022-8
needs:
- plan
- pre-commit
env:
BUILD_MODE: release
CARGO_TARGET_DIR: ${{ github.workspace }}/target/build-windows
HIGH_PRECISION: false
PARALLEL_BUILD: false
RUST_BACKTRACE: 1
steps:
# Harden-Runner skips its agent on Depot Windows,
# and its post step assumes C:\agent exists. Keep this job out until upstream fixes cleanup.
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (post-checkout)
run: bash scripts/ci/verify-ci-inputs.sh post-checkout
- name: Common setup
uses: ./.github/actions/common-setup
with:
python-version: ${{ matrix.python-version }}
free-disk-space: "true"
rust-cache-key: build-windows
rust-cache-workspaces: . -> target/build-windows
rust-cache-save-if: ${{ github.event_name == 'push' }}
# Temporary: fail fast on rare runner worktree corruption while we isolate the root cause
- name: Verify immutable CI inputs (pre-wheel build)
run: bash scripts/ci/verify-ci-inputs.sh pre-wheel-build
- name: Build and install wheel
uses: ./.github/actions/common-wheel-build
with:
python-version: ${{ matrix.python-version }}
github_ref: ${{ github.ref }}
- name: Cached test data
uses: ./.github/actions/common-test-data
- name: Run tests
run: |
uv run --no-sync python -m pytest --ignore=tests/performance_tests --reruns 2 --reruns-delay 1
- name: Upload wheel artifact
uses: ./.github/actions/upload-artifact-wheel
with:
retention-days: ${{ github.ref_name == 'master' && '7' || '1' }}
publish-wheels-develop:
name: publish-wheels-develop
runs-on: ubuntu-latest
environment: r2-develop
permissions:
actions: write # Required for deleting artifacts
contents: read
id-token: write # Required for attestations
attestations: write # Required for attestations
needs:
- build-linux-x86
# - build-windows # Windows builds moved to nightly only
# - build-linux-arm # Keep for nightly only (slow build)
# - build-macos # macOS builds moved to nightly only
if: >
github.event_name == 'push' && github.ref == 'refs/heads/develop'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CLOUDFLARE_R2_URL: ${{ secrets.CLOUDFLARE_R2_URL }}
CLOUDFLARE_R2_REGION: "auto"
CLOUDFLARE_R2_BUCKET_NAME: "packages"
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
tuf-repo-cdn.sigstore.dev:443
${{ secrets.CLOUDFLARE_R2_ALLOWED_HOST }}:443
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Block develop publish after failed security audit
if: github.ref_name == 'develop'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: bash scripts/ci/check-security-audit-result.sh
- name: Download built wheels
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
pattern: "nautilus_trader-*.whl"
merge-multiple: true
# https://github.com/actions/attest-build-provenance
- name: Attest wheel provenance
uses: ./.github/actions/attest-build-provenance-retry
with:
subject-path: "dist/nautilus_trader-*.whl"
- name: Verify wheel attestations
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ATTESTATION_IDENTITY: ${{ github.server_url }}/${{ github.workflow_ref }}
ATTESTATION_ISSUER: https://token.actions.githubusercontent.com
run: bash ./scripts/ci/verify-gh-attestations.bash dist/nautilus_trader-*.whl
- name: Publish wheels to Cloudflare R2
uses: ./.github/actions/publish-wheels
- name: Fetch and delete artifacts for current run
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bash ./scripts/ci/publish-wheels-delete-artifacts.sh
security-gate-nightly:
name: security-gate-nightly
runs-on: ubuntu-latest
needs:
- build-linux-x86
- build-linux-arm
- build-macos
- build-windows
if: >
github.event_name == 'push' && github.ref == 'refs/heads/nightly'
steps:
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.SECURITY_AUDIT_ALLOWED_ENDPOINTS }}
- name: Checkout repository
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
# Requires admin access to modify; does not widen attack surface.
# See .github/OVERVIEW.md "Security gate override" for rationale.
- name: Check security gate override
id: gate
run: |
override="${{ vars.SECURITY_GATE_OVERRIDE }}"
if [ -n "$override" ] && [ "$(date -u +%s)" -lt "$(date -u -d "$override" +%s 2>/dev/null || echo 0)" ]; then
echo "::warning::Security gate override active until $override"
echo "override_active=true" >> "$GITHUB_OUTPUT"
else
echo "override_active=false" >> "$GITHUB_OUTPUT"
fi
- name: Install cargo-audit
if: steps.gate.outputs.override_active != 'true'
uses: ./.github/actions/cargo-tool-install
with:
tool-name: cargo-audit
- name: Run cargo-audit (fail on vulnerabilities)
if: steps.gate.outputs.override_active != 'true'
run: |
cargo audit --deny unsound
cargo audit --deny unsound --file crates/adapters/lighter/fuzz/Cargo.lock
cargo audit --deny unsound --file crates/adapters/derive/fuzz/Cargo.lock
- name: Run osv-scanner
id: osv-scan
if: steps.gate.outputs.override_active != 'true'
continue-on-error: true
uses: google/osv-scanner-action/osv-scanner-action@9a498708959aeaef5ef730655706c5a1df1edbc2 # v2.3.8
with:
scan-args: |
--config=osv-scanner.toml
--format json
--output=/github/workspace/osv-results.json
--lockfile=Cargo.lock
--lockfile=crates/adapters/lighter/fuzz/Cargo.lock
--lockfile=crates/adapters/derive/fuzz/Cargo.lock
--lockfile=uv.lock
--lockfile=python/uv.lock
- name: Check OSV severity (fail on critical/high only)
if: steps.osv-scan.outcome == 'failure' && steps.gate.outputs.override_active != 'true'
run: bash scripts/ci/osv-severity-gate.sh osv-results.json
publish-wheels-nightly:
name: publish-wheels-nightly
runs-on: ubuntu-latest
environment: r2-nightly
permissions:
actions: write # Required for deleting artifacts
contents: read
id-token: write # Required for attestations
attestations: write # Required for attestations
needs:
- security-gate-nightly
if: >
github.event_name == 'push' && github.ref == 'refs/heads/nightly'
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
CLOUDFLARE_R2_URL: ${{ secrets.CLOUDFLARE_R2_URL }}
CLOUDFLARE_R2_REGION: "auto"
CLOUDFLARE_R2_BUCKET_NAME: "packages"
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
tuf-repo-cdn.sigstore.dev:443
${{ secrets.CLOUDFLARE_R2_ALLOWED_HOST }}:443
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Download built wheels
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
path: dist
pattern: "nautilus_trader-*.whl"
merge-multiple: true
# https://github.com/actions/attest-build-provenance
- name: Attest wheel provenance
uses: ./.github/actions/attest-build-provenance-retry
with:
subject-path: "dist/nautilus_trader-*.whl"
- name: Verify wheel attestations
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ATTESTATION_IDENTITY: ${{ github.server_url }}/${{ github.workflow_ref }}
ATTESTATION_ISSUER: https://token.actions.githubusercontent.com
run: bash ./scripts/ci/verify-gh-attestations.bash dist/nautilus_trader-*.whl
- name: Publish wheels to Cloudflare R2
uses: ./.github/actions/publish-wheels
- name: Fetch and delete artifacts for current run
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
bash ./scripts/ci/publish-wheels-delete-artifacts.sh
publish-cargo-crates:
runs-on: ubuntu-latest
environment: release
permissions:
contents: read
id-token: write # Required for crates.io Trusted Publishing
needs:
- publish-wheels-master
- tag-release
if: >
github.event_name == 'push' && github.ref == 'refs/heads/master'
steps:
# https://github.com/step-security/harden-runner
- uses: step-security/harden-runner@9af89fc71515a100421586dfdb3dc9c984fbf411 # v2.19.4
with:
egress-policy: ${{ env.EGRESS_POLICY }}
allowed-endpoints: >-
${{ vars.COMMON_ALLOWED_ENDPOINTS }}
${{ vars.CI_ALLOWED_ENDPOINTS }}
crates.io:443
index.crates.io:443
static.crates.io:443
- name: Checkout repository
# https://github.com/actions/checkout
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
with:
persist-credentials: false
- name: Common setup
uses: ./.github/actions/common-setup
with:
python-version: "3.13"
build-type: "release"
uv-cache-enabled: "false"
prek-cache-enabled: "false"
capnp-cache-enabled: "false"
rust-cache-enabled: "false"
rust-cache-save-if: "false"
- name: Check Cargo crate publish plan
run: bash scripts/ci/publish-cargo-crates.sh --check
- name: Authenticate to crates.io
id: crates-io-auth
# https://github.com/rust-lang/crates-io-auth-action
uses: rust-lang/crates-io-auth-action@bbd81622f20ce9e2dd9622e3218b975523e45bbe # v1.0.4
- name: Publish Cargo crates
env:
CARGO_REGISTRY_TOKEN: ${{ steps.crates-io-auth.outputs.token }}
CARGO_PUBLISH_ATTEMPTS: "5"
CARGO_PUBLISH_POLL_SECONDS: "5"
CARGO_PUBLISH_RETRY_DELAY_SECONDS: "15"
CARGO_PUBLISH_SUCCESS_DELAY_SECONDS: "0"
CARGO_PUBLISH_WAIT_TIMEOUT_SECONDS: "120"
CARGO_PUBLISH_USER_AGENT: >-
nautilus-trader-release