forked from clockworklabs/SpacetimeDB
-
Notifications
You must be signed in to change notification settings - Fork 0
1657 lines (1430 loc) · 57.6 KB
/
Copy pathci.yml
File metadata and controls
1657 lines (1430 loc) · 57.6 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
on:
pull_request:
push:
branches:
- master
merge_group:
workflow_dispatch:
inputs:
pr_number:
description: "Pull Request Number"
required: false
default: ""
name: CI
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.event.inputs.pr_number || format('sha-{0}', github.sha) }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: read
jobs:
merge_queue_noop:
name: Merge queue no-op/reuse
runs-on: spacetimedb-linux
permissions:
actions: write
contents: read
pull-requests: read
outputs:
# A reused failure also skips fresh jobs; the final step reports that failure on this commit.
skip: ${{ steps.compare.outputs.skip == 'true' || steps.reuse.outputs.reused == 'true' }}
steps:
- name: Checkout merge queue commit
uses: actions/checkout@v4
- name: Compare merge queue commit to PR head
id: compare
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HEAD_REF: ${{ github.event.merge_group.head_ref }}
shell: bash
run: |
set -euo pipefail
echo "skip=false" >>"$GITHUB_OUTPUT"
if [[ "${GITHUB_EVENT_NAME}" != "merge_group" ]]; then
echo "Not a merge_group event; running CI normally."
exit 0
fi
if [[ ! "${HEAD_REF}" =~ /pr-([0-9]+)- ]]; then
echo "Could not parse PR number from merge group head ref: ${HEAD_REF}"
exit 0
fi
pr_number="${BASH_REMATCH[1]}"
pr_head_sha="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${pr_number}" --jq '.head.sha')"
pr_head_repo="$(gh api "repos/${GITHUB_REPOSITORY}/pulls/${pr_number}" --jq '.head.repo.full_name')"
if [[ -z "${pr_head_sha}" || "${pr_head_sha}" == "null" || -z "${pr_head_repo}" || "${pr_head_repo}" == "null" ]]; then
echo "Could not resolve PR head SHA for PR #${pr_number}; running CI normally."
exit 0
fi
git fetch --no-tags --depth=1 "https://github.com/${pr_head_repo}.git" "${pr_head_sha}"
if git diff --quiet "${pr_head_sha}" "${GITHUB_SHA}" --; then
echo "Merge queue commit ${GITHUB_SHA} has the same tree as PR #${pr_number} head ${pr_head_sha}; skipping duplicate CI."
echo "skip=true" >>"$GITHUB_OUTPUT"
else
echo "Merge queue commit ${GITHUB_SHA} differs from PR #${pr_number} head ${pr_head_sha}; running CI normally."
fi
# The merge queue coordinator is part of cargo ci and needs the repository's pinned Rust toolchain.
- uses: dsherret/rust-toolchain-file@v1
if: ${{ github.event_name == 'merge_group' && steps.compare.outputs.skip != 'true' }}
- name: Reuse merge queue run
id: reuse
if: ${{ github.event_name == 'merge_group' && steps.compare.outputs.skip != 'true' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo ci other-workflows coordinate merge-queue-reuse
- name: Report merge queue workflow reuse failure on this commit
if: ${{ steps.reuse.outputs.failed == 'true' }}
run: exit 1
upload-build-artifacts-linux:
needs: [merge_queue_noop, lints]
if: ${{ needs.merge_queue_noop.outputs.skip != 'true' }}
name: Upload build artifacts (Linux)
runs-on: spacetimedb-linux
timeout-minutes: 15
env:
RUST_BACKTRACE: full
ARTIFACT_SUFFIX: linux
EXE_SUFFIX: ""
steps: &upload-build-artifact-steps
- &set-cargo-target-dir
name: Set Cargo target directory
shell: bash
run: |
if [[ "${RUNNER_OS}" == "Linux" ]]; then
cargo_target_dir="${HOME}/actions-runner/_work/target"
else
# Forward slashes keep the Windows path compatible with Cargo,
# PowerShell, GitHub Actions, and Git Bash filesystem commands.
cargo_target_dir="${GITHUB_WORKSPACE//\\//}/target"
fi
echo "CARGO_TARGET_DIR=${cargo_target_dir}" >>"${GITHUB_ENV}"
- &configure-sccache
name: Configure sccache
if: runner.os == 'Linux'
shell: bash
run: |
if command -v sccache >/dev/null 2>&1; then
# sccache cannot cache incremental compilation artifacts, so
# disable Cargo's incremental mode whenever the wrapper is active.
echo "CARGO_INCREMENTAL=0" >>"${GITHUB_ENV}"
echo "RUSTC_WRAPPER=/usr/local/bin/sccache" >>"${GITHUB_ENV}"
echo "SCCACHE_DIR=${HOME}/.cache/sccache" >>"${GITHUB_ENV}"
echo "SCCACHE_CACHE_SIZE=20G" >>"${GITHUB_ENV}"
fi
- &find-git-ref
name: Find Git ref
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
if test -n "${PR_NUMBER}"; then
GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
else
GIT_REF="${{ github.ref }}"
fi
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
- &checkout-sources
name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- uses: dsherret/rust-toolchain-file@v1
- &set-default-rust-toolchain
name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- &verify-openssl-assembler
name: Verify OpenSSL assembler
if: runner.os == 'Windows'
shell: pwsh
run: nasm -v
# These keys intentionally spell out stable native-build inputs instead of
# hashing the workspace. Keep the versions in sync with Cargo.lock and bump
# v1 if a fixed feature set or build configuration changes. This manual
# versioning is temporary until a better caching mechanism replaces it.
# - V8 uses its default features and has profile-specific native output.
# - OpenSSL is the vendored static build with legacy enabled. Windows uses
# NASM, which is represented by a separate cache-key suffix.
- &set-native-cache-keys
name: Set native cache keys
id: native-cache-keys
if: runner.os == 'Windows'
shell: bash
run: |
target="$(rustc -vV | sed -n 's/^host: //p')"
openssl_suffix=""
if [[ "${OPENSSL_RUST_USE_NASM:-}" == "1" ]]; then
openssl_suffix="-nasm"
fi
echo "v8-release-key=rusty-v8-v1-145.0.0-${target}" >>"$GITHUB_OUTPUT"
echo "v8-debug-key=rusty-v8-debug-v1-145.0.0-${target}" >>"$GITHUB_OUTPUT"
echo "openssl-key=openssl-v1-300.5.3+3.5.4-${target}${openssl_suffix}" >>"$GITHUB_OUTPUT"
- &cache-rusty-v8
name: Cache rusty_v8
if: runner.os == 'Windows'
uses: actions/cache@v4
with: &v8-release-cache
path: ${{ env.CARGO_TARGET_DIR }}/release/gn_out/obj
key: ${{ steps.native-cache-keys.outputs.v8-release-key }}
- &cache-openssl
name: Cache OpenSSL
id: cache-openssl
if: runner.os == 'Windows'
uses: actions/cache@v4
with: &openssl-cache
path: ${{ github.workspace }}/.ci-cache/openssl
key: ${{ steps.native-cache-keys.outputs.openssl-key }}
- &configure-cached-openssl
name: Configure cached OpenSSL
if: runner.os == 'Windows' && steps.cache-openssl.outputs.cache-hit == 'true'
shell: bash
run: |
# Reuse the cached vendored output as a prebuilt OpenSSL installation.
echo "OPENSSL_NO_VENDOR=1" >>"$GITHUB_ENV"
echo "OPENSSL_DIR=${{ github.workspace }}/.ci-cache/openssl" >>"$GITHUB_ENV"
- name: Build CLI and standalone
shell: bash
run: |
cargo build --timings --release \
-p spacetimedb-cli \
-p spacetimedb-standalone \
--features spacetimedb-standalone/allow_loopback_http_for_tests
- &prepare-openssl-cache
name: Prepare OpenSSL cache
if: runner.os == 'Windows' && steps.cache-openssl.outputs.cache-hit != 'true'
shell: bash
run: |
openssl_cache_dir="${PWD}/.ci-cache/openssl"
cd "${CARGO_TARGET_DIR}"
shopt -s nullglob
openssl_installs=(release/build/openssl-sys-*/out/openssl-build/install)
if (( ${#openssl_installs[@]} != 1 )); then
echo "Expected one vendored OpenSSL installation, found ${#openssl_installs[@]}."
exit 1
fi
mkdir -p "${openssl_cache_dir}"
cp -R "${openssl_installs[0]}/." "${openssl_cache_dir}/"
- name: Package build artifacts
shell: bash
run: |
archive_path="${PWD}/build-support.tar.gz"
cd "${CARGO_TARGET_DIR}"
tar -czf "${archive_path}" \
"release/spacetimedb-cli${EXE_SUFFIX}" \
"release/spacetimedb-standalone${EXE_SUFFIX}"
- &show-sccache-stats
name: Show sccache statistics
if: always() && runner.os == 'Linux'
shell: bash
run: |
if command -v sccache >/dev/null 2>&1; then
sccache --show-stats
else
echo "::notice::sccache is not installed on this Linux runner"
fi
- name: Upload Cargo timing reports
if: always()
uses: actions/upload-artifact@v4
with:
name: build-artifacts-cargo-timings-${{ env.ARTIFACT_SUFFIX }}
path: ${{ env.CARGO_TARGET_DIR }}/cargo-timings/
if-no-files-found: warn
overwrite: true
retention-days: 14
- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: build-artifacts-${{ env.ARTIFACT_SUFFIX }}
path: build-support.tar.gz
if-no-files-found: error
overwrite: true
retention-days: 14
upload-build-artifacts-windows:
needs: [merge_queue_noop, lints]
if: ${{ needs.merge_queue_noop.outputs.skip != 'true' }}
name: Upload build artifacts (Windows)
runs-on: spacetimedb-windows-runner
timeout-minutes: 15
env:
RUST_BACKTRACE: full
ARTIFACT_SUFFIX: windows
EXE_SUFFIX: .exe
OPENSSL_RUST_USE_NASM: "1"
steps: *upload-build-artifact-steps
smoketest_build_linux:
needs: [upload-build-artifacts-linux]
name: Build smoketests (Linux)
runs-on: spacetimedb-linux
timeout-minutes: 15
env:
RUST_BACKTRACE: full
ARTIFACT_SUFFIX: linux
EXE_SUFFIX: ""
SMOKETEST_SUITE: standalone
steps: &smoketest-build-steps
- *set-cargo-target-dir
- *configure-sccache
- *find-git-ref
- *checkout-sources
- uses: dsherret/rust-toolchain-file@v1
- *set-default-rust-toolchain
- *set-native-cache-keys
- *verify-openssl-assembler
- &restore-openssl
name: Restore OpenSSL
id: cache-openssl
if: runner.os == 'Windows'
uses: actions/cache/restore@v4
with: *openssl-cache
- *configure-cached-openssl
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- name: Build smoketest dependencies and archive test binaries
shell: bash
run: |
cargo run --timings --package ci-smoketests -- --suite "${SMOKETEST_SUITE}" archive --archive-file smoketest-nextest.tar.zst
archive_path="${PWD}/smoketest-support.tar.gz"
cd "${CARGO_TARGET_DIR}"
shopt -s nullglob
precompiled_modules=(wasm32-unknown-unknown/release/smoketest_module_*.wasm)
if (( ${#precompiled_modules[@]} == 0 )); then
echo "No precompiled smoketest modules were produced."
exit 1
fi
tar -czf "${archive_path}" \
"debug/ci-smoketests${EXE_SUFFIX}" \
"${precompiled_modules[@]}"
- *show-sccache-stats
- name: Upload Cargo timing reports
if: always()
uses: actions/upload-artifact@v4
with:
name: smoketest-build-cargo-timings-${{ env.ARTIFACT_SUFFIX }}
path: ${{ env.CARGO_TARGET_DIR }}/cargo-timings/
if-no-files-found: warn
overwrite: true
retention-days: 14
- name: Upload smoketest build
uses: actions/upload-artifact@v4
with:
name: smoketest-build-${{ env.ARTIFACT_SUFFIX }}
path: |
smoketest-nextest.tar.zst
smoketest-support.tar.gz
if-no-files-found: error
overwrite: true
retention-days: 14
smoketest_build_windows:
needs: [upload-build-artifacts-windows]
name: Build smoketests (Windows)
runs-on: spacetimedb-windows-runner
timeout-minutes: 15
env:
RUST_BACKTRACE: full
ARTIFACT_SUFFIX: windows
EXE_SUFFIX: .exe
OPENSSL_RUST_USE_NASM: "1"
SMOKETEST_SUITE: all
steps: *smoketest-build-steps
smoketest_partitions_linux:
needs: [smoketest_build_linux]
name: Smoketests (Linux ${{ matrix.partition }}/1)
strategy:
fail-fast: false
matrix:
partition: [1]
runs-on: spacetimedb-linux
timeout-minutes: 30
env:
RUST_BACKTRACE: full
SPACETIMEDB_CPP_DIR: ${{ github.workspace }}/crates/bindings-cpp
ARTIFACT_SUFFIX: linux
PARTITION_COUNT: 1
steps: &smoketest-partition-steps
- *set-cargo-target-dir
- *configure-sccache
- *find-git-ref
- *checkout-sources
- uses: dsherret/rust-toolchain-file@v1
- *set-default-rust-toolchain
- uses: actions/setup-dotnet@v4
with:
global-json-file: global.json
# Node.js and pnpm are required for the TypeScript smoketests.
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- uses: ./.github/actions/setup-pnpm
- name: Install TypeScript SDK dependencies
run: pnpm --filter spacetimedb install
- name: Install emscripten (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
git clone https://github.com/emscripten-core/emsdk.git $env:USERPROFILE\emsdk
cd $env:USERPROFILE\emsdk
.\emsdk install 4.0.21
.\emsdk activate 4.0.21
- name: Install psql
if: runner.os == 'Windows'
shell: pwsh
run: |
# Fail properly if any individual command fails
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
choco install psql -y --no-progress
# Check for existence, since `choco` doesn't seem to fail the step if it fails to install..
# See https://github.com/clockworklabs/SpacetimeDB/pull/4399 for more background.
Get-Command psql
- name: Update dotnet workloads
if: runner.os == 'Windows'
shell: pwsh
run: |
# Fail properly if any individual command fails
$ErrorActionPreference = 'Stop'
$PSNativeCommandUseErrorActionPreference = $true
cd modules
# the sdk-manifests on windows-latest are messed up, so we need to update them
dotnet workload config --update-mode manifests
dotnet workload update --from-previous-sdk
# Explicitly install wasi-experimental for .NET 8 SDK (needed for test_build_csharp_module)
# Create temp global.json to target .NET 8 SDK for workload install
$sdk8Json = '{"sdk":{"version":"8.0.400","rollForward":"latestFeature"}}'
$sdk8Json | Out-File -FilePath global.json -Encoding utf8
dotnet workload install wasi-experimental
Remove-Item global.json
- name: Override NuGet packages
shell: bash
run: |
dotnet pack -c Release crates/bindings-csharp/BSATN.Runtime
dotnet pack -c Release crates/bindings-csharp/Runtime
cd sdks/csharp
./tools~/write-nuget-config.sh ../..
- name: Install cargo-nextest
uses: taiki-e/install-action@nextest
- &download-build-artifacts
name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: build-artifacts-${{ env.ARTIFACT_SUFFIX }}
path: build-artifacts
- &extract-build-artifacts
name: Extract build artifacts
shell: bash
run: |
archive_path="${PWD}/build-artifacts/build-support.tar.gz"
exe_suffix=""
if [[ "${RUNNER_OS}" == "Windows" ]]; then
exe_suffix=".exe"
fi
mkdir -p "${CARGO_TARGET_DIR}"
cd "${CARGO_TARGET_DIR}"
tar -xzf "${archive_path}"
test -f "release/spacetimedb-cli${exe_suffix}"
test -f "release/spacetimedb-standalone${exe_suffix}"
- name: Download smoketest build
uses: actions/download-artifact@v4
with:
name: smoketest-build-${{ env.ARTIFACT_SUFFIX }}
- name: Extract smoketest support files
shell: bash
run: |
archive_path="${PWD}/smoketest-support.tar.gz"
mkdir -p "${CARGO_TARGET_DIR}"
cd "${CARGO_TARGET_DIR}"
tar -xzf "${archive_path}"
# Serial execution avoids contention between the C# tests over generated bindings.
- name: Run smoketest partition (Linux)
if: runner.os == 'Linux'
shell: bash
run: |
if [ -f ~/emsdk/emsdk_env.sh ]; then
source ~/emsdk/emsdk_env.sh
fi
cargo ci smoketests run-archive \
--archive-file smoketest-nextest.tar.zst \
-- \
--partition hash:${{ matrix.partition }}/${{ env.PARTITION_COUNT }}
# Due to Emscripten PATH issues this remains separate from the Linux command.
- name: Run smoketest partition (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: |
if (Test-Path "$env:USERPROFILE\emsdk\emsdk_env.ps1") {
& "$env:USERPROFILE\emsdk\emsdk_env.ps1" | Out-Null
}
& "$env:CARGO_TARGET_DIR\debug\ci-smoketests.exe" run-archive `
--archive-file smoketest-nextest.tar.zst `
-- `
--partition hash:${{ matrix.partition }}/${{ env.PARTITION_COUNT }}
- name: Upload timing reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cargo-timings-smoketests-${{ matrix.name }}
path: ${{ env.CARGO_TARGET_DIR }}/cargo-timings/
retention-days: 14
smoketest_partitions_windows:
needs: [smoketest_build_windows]
name: Smoketests (Windows ${{ matrix.partition }}/4)
strategy:
fail-fast: false
matrix:
partition: [1, 2, 3, 4]
runs-on: spacetimedb-windows-runner
timeout-minutes: 30
env:
RUST_BACKTRACE: full
SPACETIMEDB_CPP_DIR: ${{ github.workspace }}/crates/bindings-cpp
ARTIFACT_SUFFIX: windows
PARTITION_COUNT: 4
steps: *smoketest-partition-steps
# this is a no-op version of the above check with a trivially-passing body.
# we can't just let the check be entirely skipped because each matrix target is a required check,
# and skipping this check means that the matrix isn't "populated" so the required checks wouldn't be met.
smoketests_noop:
needs: [merge_queue_noop]
if: ${{ needs.merge_queue_noop.outputs.skip == 'true' }}
name: Smoketests (${{ matrix.name }})
strategy:
matrix:
include:
- name: Linux 1/1
- name: Windows 1/4
- name: Windows 2/4
- name: Windows 3/4
- name: Windows 4/4
runs-on: spacetimedb-linux
steps:
- name: Skip duplicate merge queue smoketest
run: echo "Merge queue commit has the same tree as the PR head; smoketest already ran for the PR."
test:
needs: [merge_queue_noop, lints, upload-build-artifacts-linux]
if: ${{ needs.merge_queue_noop.outputs.skip != 'true' }}
name: Test Suite
runs-on: spacetimedb-linux
env:
RUST_BACKTRACE: full
ARTIFACT_SUFFIX: linux
steps:
- *set-cargo-target-dir
- *configure-sccache
- &set-spacetime-bin
name: Set SpacetimeDB binary path
shell: bash
run: echo "SPACETIME_BIN=${CARGO_TARGET_DIR}/release/spacetimedb-cli" >>"${GITHUB_ENV}"
- name: Find Git ref
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
if test -n "${PR_NUMBER}"; then
GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
else
GIT_REF="${{ github.ref }}"
fi
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- *download-build-artifacts
- *extract-build-artifacts
- uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- uses: ./.github/actions/setup-pnpm
with:
run_install: true
# Install cmake and emscripten for C++ module compilation tests.
- name: Install cmake and emscripten
run: |
sudo apt-get update
sudo apt-get install -y cmake
git clone https://github.com/emscripten-core/emsdk.git ~/emsdk
cd ~/emsdk
./emsdk install 4.0.21
./emsdk activate 4.0.21
- name: Install wasm-bindgen CLI
run: |
REQUIRED_WASM_BINDGEN_VERSION="$(
awk '
$1 == "name" && $3 == "\"wasm-bindgen\"" { in_pkg = 1; next }
in_pkg && $1 == "version" {
gsub(/"/, "", $3);
print $3;
exit;
}
' Cargo.lock
)"
if [ -z "${REQUIRED_WASM_BINDGEN_VERSION}" ]; then
echo "Failed to determine wasm-bindgen version from Cargo.lock"
exit 1
fi
INSTALLED_WASM_BINDGEN_VERSION="$(wasm-bindgen --version 2>/dev/null | awk '{print $2}' || true)"
if [ "${INSTALLED_WASM_BINDGEN_VERSION}" != "${REQUIRED_WASM_BINDGEN_VERSION}" ]; then
cargo install --locked --force wasm-bindgen-cli --version "${REQUIRED_WASM_BINDGEN_VERSION}"
fi
wasm-bindgen --version
# Source emsdk environment to make emcc (Emscripten compiler) available in PATH.
- name: Run tests
run: |
source ~/emsdk/emsdk_env.sh
cargo ci test
- *show-sccache-stats
- name: Upload timing reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cargo-timings-test
path: ${{ env.CARGO_TARGET_DIR }}/cargo-timings/
retention-days: 14
index_scan_bench:
needs: [merge_queue_noop, lints]
if: ${{ needs.merge_queue_noop.outputs.skip != 'true' }}
name: Index Scan Bench
runs-on: spacetimedb-benchmark-runner
concurrency:
group: ci-benchmark-runner
queue: max
timeout-minutes: 60
env:
RUST_BACKTRACE: full
steps:
- *set-cargo-target-dir
- *configure-sccache
- name: Find Git ref
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
if test -n "${PR_NUMBER}"; then
GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
else
GIT_REF="${{ github.ref }}"
fi
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Run index scan benchmark regression check
run: cargo run --release -p spacetimedb-index-scan-gate
- *show-sccache-stats
lints:
needs: [merge_queue_noop]
if: ${{ needs.merge_queue_noop.outputs.skip != 'true' }}
name: Lints
runs-on: spacetimedb-linux
env:
RUST_BACKTRACE: full
steps:
- *set-cargo-target-dir
- *configure-sccache
- name: Checkout sources
uses: actions/checkout@v3
- uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
- uses: actions/setup-dotnet@v3
with:
global-json-file: global.json
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- uses: ./.github/actions/setup-pnpm
with:
run_install: true
- name: Run ci lint
run: cargo ci lint
- *show-sccache-stats
- name: Upload timing reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cargo-timings-public-lints
path: ${{ env.CARGO_TARGET_DIR }}/cargo-timings/
retention-days: 14
codeowners_check:
if: ${{ github.event_name == 'pull_request' }}
name: CODEOWNERS check
runs-on: spacetimedb-linux
permissions:
contents: read
pull-requests: read
env:
RUST_BACKTRACE: full
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- *set-cargo-target-dir
- *configure-sccache
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Run CODEOWNERS check
run: |
cargo ci other-workflows codeowners-check \
--base-ref "origin/${{ github.event.pull_request.base.ref }}" \
--pr-number "${{ github.event.pull_request.number }}"
- name: Upload timing reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cargo-timings-codeowners-check
path: ${{ env.CARGO_TARGET_DIR }}/cargo-timings/
retention-days: 14
module_latest_deps:
needs: [merge_queue_noop, upload-build-artifacts-linux]
if: ${{ needs.merge_queue_noop.outputs.skip != 'true' }}
name: Build and test wasm bindings
runs-on: spacetimedb-linux
env:
RUST_BACKTRACE: full
ARTIFACT_SUFFIX: linux
steps:
- *set-cargo-target-dir
- *configure-sccache
- *set-spacetime-bin
- *find-git-ref
- *checkout-sources
- uses: dsherret/rust-toolchain-file@v1
- *set-default-rust-toolchain
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
- *download-build-artifacts
- *extract-build-artifacts
- name: Build module with latest compatible dependencies
run: cargo ci module-latest-deps
- *show-sccache-stats
publish_checks:
needs: [merge_queue_noop]
if: ${{ needs.merge_queue_noop.outputs.skip != 'true' }}
name: Check that packages are publishable
runs-on: spacetimedb-linux
permissions: read-all
env:
RUST_BACKTRACE: full
steps:
- *set-cargo-target-dir
- *configure-sccache
- uses: actions/checkout@v3
- uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Run checks
run: cargo ci publish-checks
- name: Upload timing reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cargo-timings-publish-checks
path: ${{ env.CARGO_TARGET_DIR }}/cargo-timings/
retention-days: 14
update:
needs: [merge_queue_noop]
if: ${{ needs.merge_queue_noop.outputs.skip != 'true' }}
name: Test spacetimedb-update flow (${{ matrix.target }})
permissions: read-all
strategy:
matrix:
include:
- { target: x86_64-unknown-linux-gnu, runner: spacetimedb-linux }
- { target: aarch64-apple-darwin, runner: macos-latest }
- { target: x86_64-pc-windows-msvc, runner: windows-latest }
runs-on: ${{ matrix.runner }}
env:
RUST_BACKTRACE: full
steps:
- *set-cargo-target-dir
- *configure-sccache
- *find-git-ref
- *checkout-sources
- name: Install Rust
uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Install rust target
run: rustup target add ${{ matrix.target }}
- name: Test spacetimedb-update
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cargo ci update-flow --target=${{ matrix.target }} --github-token-auth
- *show-sccache-stats
- name: Upload timing reports
if: always()
uses: actions/upload-artifact@v4
with:
name: cargo-timings-update-flow-${{ matrix.target }}
path: ${{ env.CARGO_TARGET_DIR }}/cargo-timings/
retention-days: 14
# this is a no-op version of the above check with a trivially-passing body.
# we can't just let the check be entirely skipped because each matrix target is a required check,
# and skipping this check means that the matrix isn't "populated" so the required checks wouldn't be met.
update_noop:
needs: [merge_queue_noop]
if: ${{ needs.merge_queue_noop.outputs.skip == 'true' }}
name: Test spacetimedb-update flow (${{ matrix.target }})
permissions: read-all
strategy:
matrix:
include:
- { target: x86_64-unknown-linux-gnu }
- { target: aarch64-apple-darwin }
- { target: x86_64-pc-windows-msvc }
runs-on: spacetimedb-linux
steps:
- name: Skip duplicate merge queue update test
run: echo "Merge queue commit has the same tree as the PR head; update-flow already ran for the PR."
unreal_engine_tests:
name: Unreal Engine Tests
# This can't go on e.g. ubuntu-latest because that runner runs out of disk space. ChatGPT suggested that the general solution tends to be to use
# a custom runner.
runs-on: spacetimedb-linux
# Disable the tests because they are very flaky at the moment.
# TODO: Remove this line and re-enable the `if` line just below here.
if: false
# Skip if this is an external contribution. GitHub secrets will be empty, so the step would fail anyway.
# if: ${{ github.event_name != 'pull_request' || !github.event.pull_request.head.repo.fork }}
container:
image: ghcr.io/epicgames/unreal-engine:dev-5.6
credentials:
# Note(bfops): I don't think that `github.actor` needs to match the user that the token is for, because I'm using a token for my account and
# it seems to be totally happy.
# However, the token needs to be for a user that has access to the EpicGames org (see
# https://dev.epicgames.com/documentation/en-us/unreal-engine/downloading-source-code-in-unreal-engine?application_version=5.6)
username: ${{ github.actor }}
password: ${{ secrets.GHCR_TOKEN }}
# Run as root because otherwise we get permission denied for various directories inside the container. I tried doing dances to allow it to run
# without this (reassigning env vars and stuff), but was unable to get it to work and it felt like an uphill battle.
options: --user 0:0
env:
RUST_BACKTRACE: full
steps:
- *set-cargo-target-dir
- *configure-sccache
# Uncomment this before merging so that it will run properly if run manually through the GH actions flow. It was playing weird with rolled back
# commits though.
# - name: Find Git ref
# env:
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# shell: bash
# run: |
# PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
# if test -n "${PR_NUMBER}"; then
# GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
# else
# GIT_REF="${{ github.ref }}"
# fi
# echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
- name: Checkout sources
uses: actions/checkout@v4
with:
ref: ${{ env.GIT_REF }}
- uses: dsherret/rust-toolchain-file@v1
- name: Set default rust toolchain
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
- name: Run Unreal Engine tests
working-directory: sdks/unreal
env:
UE_ROOT_PATH: /home/ue4/UnrealEngine
run: |
apt-get update
apt-get install -y acl curl ca-certificates
REPO="$GITHUB_WORKSPACE"
# Let ue4 read/write the workspace & tool caches without changing ownership
for p in "$REPO" "${RUNNER_TEMP:-/__t}" "${RUNNER_TOOL_CACHE:-/__t}"; do
[ -d "$p" ] && setfacl -R -m u:ue4:rwX -m d:u:ue4:rwX "$p" || true
done
# Rust tool caches live under the runner tool cache so they persist
export CARGO_HOME="${RUNNER_TOOL_CACHE:-/__t}/cargo"
export RUSTUP_HOME="${RUNNER_TOOL_CACHE:-/__t}/rustup"
mkdir -p "$CARGO_HOME" "$RUSTUP_HOME"
chown -R ue4:ue4 "$CARGO_HOME" "$RUSTUP_HOME"
# Make sure the UE build script is executable (and parents traversable)
UE_DIR="${UE_ROOT_PATH:-/home/ue4/UnrealEngine}"
chmod a+rx "$UE_DIR" "$UE_DIR/Engine" "$UE_DIR/Engine/Build" "$UE_DIR/Engine/Build/BatchFiles/Linux" || true
chmod a+rx "$UE_DIR/Engine/Build/BatchFiles/Linux/Build.sh" || true
# Run the build & tests as ue4 (who owns the UE tree)
sudo -E -H -u ue4 env \
HOME=/home/ue4 \
XDG_CONFIG_HOME=/home/ue4/.config \
CARGO_HOME="$CARGO_HOME" \
RUSTUP_HOME="$RUSTUP_HOME" \
PATH="$CARGO_HOME/bin:$PATH" \
bash -lc '
set -euxo pipefail
# Install rustup for ue4 if needed (uses the shared caches)
if ! command -v cargo >/dev/null 2>&1; then
curl -sSf https://sh.rustup.rs | sh -s -- -y
fi