Skip to content

Commit 5ac6573

Browse files
Kasamabfops
andauthored
add initial cargo ci (#3409)
# Description of Changes This changes the ci runs to execute `cargo ci` instead of running commands directly from the github workflow. The goal here is to unify the commands under `cargo ci` so that it's easier and more intuitive to run locally # API and ABI breaking changes There are no API/ABI changes. <!-- If this is an API or ABI breaking change, please apply the corresponding GitHub label. --> # Expected complexity level and risk Complexity: 1 It is not a complex change as it is mostly localized to the ci runs and is easily reversible if something goes wrong. The biggest risk here is to have future CI runs break, which can be remediated by reverting these changes. <!-- How complicated do you think these changes are? Grade on a scale from 1 to 5, where 1 is a trivial change, and 5 is a deep-reaching and complex change. This complexity rating applies not only to the complexity apparent in the diff, but also to its interactions with existing and future code. If you answered more than a 2, explain what is complex about the PR, and what other components it interacts with in potentially concerning ways. --> # Testing <!-- Describe any testing you've done, and any testing you'd like your reviewers to do, so that you're confident that all the changes work as expected! --> - [x] run `cargo ci` and its subcommands locally - [x] run the github workflow against this branch to check if the CI jobs are working properly. --------- Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com> Signed-off-by: Roberto Pommella Alegro <robertoaall@gmail.com> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com> Co-authored-by: Zeke Foppa <196249+bfops@users.noreply.github.com>
1 parent cdf8391 commit 5ac6573

8 files changed

Lines changed: 666 additions & 169 deletions

File tree

.cargo/config.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ rustflags = ["--cfg", "tokio_unstable"]
33

44
[alias]
55
bump-versions = "run -p upgrade-version --"
6+
ci = "run -p ci --"
67

78
[target.x86_64-pc-windows-msvc]
89
# Use a different linker. Otherwise, the build fails with some obscure linker error that

.github/workflows/ci.yml

Lines changed: 65 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,14 @@ jobs:
111111
if: runner.os == 'Windows'
112112
- name: Install python deps
113113
run: python -m pip install -r smoketests/requirements.txt
114-
- name: Run smoketests
114+
- name: Run smoketests (windows)
115115
# Note: clear_database and replication only work in private
116116
run: python -m smoketests ${{ matrix.smoketest_args }} -x clear_database replication teams
117+
if: runner.os == 'Windows'
118+
- name: Run smoketests (Linux)
119+
# Note: clear_database and replication only work in private
120+
run: cargo ci smoketests -- ${{ matrix.smoketest_args }} -x clear_database replication teams
121+
if: runner.os != 'Windows'
117122
- name: Stop containers (Linux)
118123
if: always() && runner.os == 'Linux'
119124
run: docker compose -f .github/docker-compose.yml down
@@ -167,34 +172,12 @@ jobs:
167172
with:
168173
run_install: true
169174

170-
- name: Create /stdb dir
171-
run: |
172-
sudo mkdir /stdb
173-
sudo chmod 777 /stdb
174-
175175
- name: Build typescript module sdk
176176
working-directory: crates/bindings-typescript
177177
run: pnpm build
178178

179-
- name: Run cargo test
180-
#Note: Unreal tests will be run separately
181-
run: cargo test --all -- --skip unreal
182-
183-
# The fallocate tests have been flakely when running in parallel
184-
- name: Run fallocate tests
185-
run: cargo test -p spacetimedb-durability --features fallocate -- --test-threads=1
186-
187-
- name: Check that the test outputs are up-to-date
188-
run: bash tools/check-diff.sh
189-
190-
- name: Ensure C# autogen bindings are up-to-date
191-
run: |
192-
cargo run -p spacetimedb-codegen --example regen-csharp-moduledef
193-
bash tools/check-diff.sh crates/bindings-csharp
194-
195-
- name: C# bindings tests
196-
working-directory: crates/bindings-csharp
197-
run: dotnet test -warnaserror
179+
- name: Run tests
180+
run: cargo ci test
198181

199182
lints:
200183
name: Lints
@@ -224,30 +207,8 @@ jobs:
224207
with:
225208
global-json-file: global.json
226209

227-
- name: Run cargo fmt
228-
run: cargo fmt --all -- --check
229-
230-
- name: Run cargo clippy
231-
run: cargo clippy --all --tests --benches -- -D warnings
232-
233-
- name: Run C# formatting check
234-
working-directory: crates/bindings-csharp
235-
run: |
236-
dotnet tool restore
237-
dotnet csharpier --check .
238-
239-
- name: Run `cargo doc` for bindings crate
240-
# `bindings` is the only crate we care strongly about documenting,
241-
# since we link to its docs.rs from our website.
242-
# We won't pass `--no-deps`, though,
243-
# since we want everything reachable through it to also work.
244-
# This includes `sats` and `lib`.
245-
working-directory: crates/bindings
246-
env:
247-
# Make `cargo doc` exit with error on warnings, most notably broken links
248-
RUSTDOCFLAGS: '--deny warnings'
249-
run: |
250-
cargo doc
210+
- name: Run ci lint
211+
run: cargo ci lint
251212

252213
wasm_bindings:
253214
name: Build and test wasm bindings
@@ -273,20 +234,7 @@ jobs:
273234
save-if: false
274235

275236
- name: Run bindgen tests
276-
run: cargo test -p spacetimedb-codegen
277-
278-
# Make sure the `Cargo.lock` file reflects the latest available versions.
279-
# This is what users would end up with on a fresh module, so we want to
280-
# catch any compile errors arising from a different transitive closure
281-
# of dependencies than what is in the workspace lock file.
282-
#
283-
# For context see also: https://github.com/clockworklabs/SpacetimeDB/pull/2714
284-
- name: Update dependencies
285-
run: cargo update
286-
287-
- name: Build module-test
288-
run: cargo run -p spacetimedb-cli -- build --project-path modules/module-test
289-
237+
run: cargo ci wasm-bindings
290238

291239
publish_checks:
292240
name: Check that packages are publishable
@@ -350,6 +298,7 @@ jobs:
350298

351299
- name: Build spacetimedb-update
352300
run: cargo build --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update
301+
if: runner.os == 'Windows'
353302

354303
- name: Run self-install
355304
env:
@@ -362,6 +311,13 @@ jobs:
362311
# happens very frequently on the `macos-runner`, but we haven't seen it on any others).
363312
cargo run --features github-token-auth --target ${{ matrix.target }} -p spacetimedb-update -- self-install --root-dir="${ROOT_DIR}" --yes
364313
"${ROOT_DIR}"/spacetime --root-dir="${ROOT_DIR}" help
314+
if: runner.os == 'Windows'
315+
316+
- name: Test spacetimedb-update
317+
env:
318+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
319+
run: cargo ci update-flow --target=${{ matrix.target }} --github-token-auth
320+
if: runner.os != 'Windows'
365321

366322
unreal_engine_tests:
367323
name: Unreal Engine Tests
@@ -386,20 +342,20 @@ jobs:
386342
# without this (reassigning env vars and stuff), but was unable to get it to work and it felt like an uphill battle.
387343
options: --user 0:0
388344
steps:
389-
# 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
390-
# commits though.
391-
# - name: Find Git ref
392-
# env:
393-
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
394-
# shell: bash
395-
# run: |
396-
# PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
397-
# if test -n "${PR_NUMBER}"; then
398-
# GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
399-
# else
400-
# GIT_REF="${{ github.ref }}"
401-
# fi
402-
# echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
345+
# 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
346+
# commits though.
347+
# - name: Find Git ref
348+
# env:
349+
# GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
350+
# shell: bash
351+
# run: |
352+
# PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
353+
# if test -n "${PR_NUMBER}"; then
354+
# GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
355+
# else
356+
# GIT_REF="${{ github.ref }}"
357+
# fi
358+
# echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
403359
- name: Checkout sources
404360
uses: actions/checkout@v4
405361
with:
@@ -452,6 +408,33 @@ jobs:
452408
cargo test -- --test-threads=1
453409
'
454410
411+
ci_command_docs:
412+
name: Check CI command docs
413+
runs-on: ubuntu-latest
414+
steps:
415+
- name: Find Git ref
416+
env:
417+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
418+
shell: bash
419+
run: |
420+
PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
421+
if test -n "${PR_NUMBER}"; then
422+
GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
423+
else
424+
GIT_REF="${{ github.ref }}"
425+
fi
426+
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
427+
428+
- name: Checkout sources
429+
uses: actions/checkout@v4
430+
with:
431+
ref: ${{ env.GIT_REF }}
432+
433+
- uses: dsherret/rust-toolchain-file@v1
434+
435+
- name: Check for docs change
436+
run: cargo ci self-docs --check
437+
455438
cli_docs:
456439
name: Check CLI docs
457440
permissions: read-all
@@ -515,15 +498,7 @@ jobs:
515498

516499
- name: Check for docs change
517500
run: |
518-
cargo run --features markdown-docs -p spacetimedb-cli > docs/docs/cli-reference.md
519-
pnpm format
520-
git status
521-
if git diff --exit-code HEAD -- docs/docs/cli-reference.md; then
522-
echo "No docs changes detected"
523-
else
524-
echo "It looks like the CLI docs have changed:"
525-
exit 1
526-
fi
501+
cargo ci cli-docs
527502
528503
unity-testsuite:
529504
# Skip if this is an external contribution.
@@ -609,7 +584,7 @@ jobs:
609584
enable_pr_comment: ${{ github.event_name == 'pull_request' }}
610585
target_path: sdks/csharp
611586
env:
612-
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
587+
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
613588

614589
- name: Start SpacetimeDB
615590
run: |
@@ -643,12 +618,12 @@ jobs:
643618
- name: Run Unity tests
644619
uses: game-ci/unity-test-runner@v4
645620
with:
646-
unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag
647-
projectPath: demo/Blackholio/client-unity # Path to the Unity project subdirectory
621+
unityVersion: 2022.3.32f1 # Adjust Unity version to a valid tag
622+
projectPath: demo/Blackholio/client-unity # Path to the Unity project subdirectory
648623
githubToken: ${{ secrets.GITHUB_TOKEN }}
649624
testMode: playmode
650625
useHostNetwork: true
651-
artifactsPath: ""
626+
artifactsPath: ''
652627
env:
653628
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }}
654629
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }}

Cargo.lock

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)