Skip to content

Commit 7b0ec8a

Browse files
authored
CI - Fix cargo-related errors (#4242)
# Description of Changes CI is currently failing in a bunch of places since we tweaked the Rust versions available in our CI runner, and it revealed that many of our workflows don't set the default rust toolchain. # API and ABI breaking changes None. CI only. # Expected complexity level and risk 1 # Testing - [x] CI passes in this PR --------- Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com>
1 parent d8fcc92 commit 7b0ec8a

4 files changed

Lines changed: 42 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,8 @@ jobs:
280280
ref: ${{ env.GIT_REF }}
281281

282282
- uses: dsherret/rust-toolchain-file@v1
283+
- name: Set default rust toolchain
284+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
283285
- name: Cache Rust dependencies
284286
uses: Swatinem/rust-cache@v2
285287
with:
@@ -332,6 +334,8 @@ jobs:
332334
uses: actions/checkout@v3
333335

334336
- uses: dsherret/rust-toolchain-file@v1
337+
- name: Set default rust toolchain
338+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
335339
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
336340

337341
- name: Cache Rust dependencies
@@ -359,6 +363,8 @@ jobs:
359363
- uses: actions/checkout@v3
360364

361365
- uses: dsherret/rust-toolchain-file@v1
366+
- name: Set default rust toolchain
367+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
362368
- run: echo ::add-matcher::.github/workflows/rust_matcher.json
363369

364370
- name: Cache Rust dependencies
@@ -379,6 +385,9 @@ jobs:
379385
permissions: read-all
380386
steps:
381387
- uses: actions/checkout@v3
388+
- uses: dsherret/rust-toolchain-file@v1
389+
- name: Set default rust toolchain
390+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
382391
- name: Set up Python env
383392
run: |
384393
test -d venv || python3 -m venv venv
@@ -415,6 +424,8 @@ jobs:
415424

416425
- name: Install Rust
417426
uses: dsherret/rust-toolchain-file@v1
427+
- name: Set default rust toolchain
428+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
418429

419430
- name: Install rust target
420431
run: rustup target add ${{ matrix.target }}
@@ -489,6 +500,8 @@ jobs:
489500
with:
490501
ref: ${{ env.GIT_REF }}
491502
- uses: dsherret/rust-toolchain-file@v1
503+
- name: Set default rust toolchain
504+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
492505
- name: Run Unreal Engine tests
493506
working-directory: sdks/unreal
494507
env:
@@ -559,6 +572,8 @@ jobs:
559572
ref: ${{ env.GIT_REF }}
560573

561574
- uses: dsherret/rust-toolchain-file@v1
575+
- name: Set default rust toolchain
576+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
562577

563578
- name: Check for docs change
564579
run: cargo ci self-docs --check
@@ -611,6 +626,8 @@ jobs:
611626
${{ runner.os }}-pnpm-store-
612627
613628
- uses: dsherret/rust-toolchain-file@v1
629+
- name: Set default rust toolchain
630+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
614631

615632
- name: Cache Rust dependencies
616633
uses: Swatinem/rust-cache@v2
@@ -709,6 +726,8 @@ jobs:
709726
710727
- name: Install Rust toolchain
711728
uses: dsherret/rust-toolchain-file@v1
729+
- name: Set default rust toolchain
730+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
712731

713732
- name: Cache Rust dependencies
714733
uses: Swatinem/rust-cache@v2
@@ -735,6 +754,8 @@ jobs:
735754
736755
- name: Install SpacetimeDB CLI from the local checkout
737756
run: |
757+
export CARGO_HOME="$HOME/.cargo"
758+
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
738759
cargo install --force --path crates/cli --locked --message-format=short
739760
cargo install --force --path crates/standalone --locked --message-format=short
740761
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
@@ -845,6 +866,8 @@ jobs:
845866

846867
- name: Install Rust toolchain
847868
uses: dsherret/rust-toolchain-file@v1
869+
- name: Set default rust toolchain
870+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
848871

849872
- name: Cache Rust dependencies
850873
uses: Swatinem/rust-cache@v2
@@ -877,6 +900,8 @@ jobs:
877900
878901
- name: Install SpacetimeDB CLI from the local checkout
879902
run: |
903+
export CARGO_HOME="$HOME/.cargo"
904+
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
880905
cargo install --force --path crates/cli --locked --message-format=short
881906
cargo install --force --path crates/standalone --locked --message-format=short
882907
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
@@ -1062,6 +1087,8 @@ jobs:
10621087
ref: ${{ env.GIT_REF }}
10631088

10641089
- uses: dsherret/rust-toolchain-file@v1
1090+
- name: Set default rust toolchain
1091+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
10651092

10661093
- name: Cache Rust dependencies
10671094
uses: Swatinem/rust-cache@v2

.github/workflows/package.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ jobs:
4141

4242
- name: Install Rust
4343
uses: dsherret/rust-toolchain-file@v1
44+
- name: Set default rust toolchain
45+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
4446

4547
- name: Install rust target
4648
run: rustup target add ${{ matrix.target }}

.github/workflows/typescript-test.yml

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ jobs:
7676

7777
- name: Install Rust toolchain
7878
uses: dsherret/rust-toolchain-file@v1
79+
- name: Set default rust toolchain
80+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
7981

8082
- name: Cache Rust dependencies
8183
uses: Swatinem/rust-cache@v2
@@ -99,29 +101,23 @@ jobs:
99101
cargo clean -p v8 || true
100102
cargo build -p v8
101103
fi
104+
if ! [ -f "${CARGO_TARGET_DIR}"/release/gn_out/obj/librusty_v8.a ]; then
105+
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
106+
cargo clean --release -p v8 || true
107+
cargo build --release -p v8
108+
fi
102109
103110
- name: Install SpacetimeDB CLI from the local checkout
104111
run: |
112+
export CARGO_HOME="$HOME/.cargo"
113+
echo "$CARGO_HOME/bin" >> "$GITHUB_PATH"
105114
cargo install --force --path crates/cli --locked --message-format=short
106115
cargo install --force --path crates/standalone --locked --message-format=short
107116
# Add a handy alias using the old binary name, so that we don't have to rewrite all scripts (incl. in submodules).
108-
rm -f $CARGO_HOME/bin/spacetime
109-
ln -s $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
117+
ln -sf $CARGO_HOME/bin/spacetimedb-cli $CARGO_HOME/bin/spacetime
110118
# Clear any existing information
111119
spacetime server clear -y
112120
113-
# This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
114-
# This may be due to reusing CARGO_TARGET_DIR while mixing different build strategies (`cargo install` and `cargo build -p`).
115-
# However, this fix seems to work.
116-
- name: Check v8 outputs
117-
run: |
118-
find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true
119-
if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then
120-
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
121-
cargo clean -p v8 || true
122-
cargo build -p v8
123-
fi
124-
125121
- name: Generate client bindings
126122
working-directory: templates/chat-react-ts
127123
run: |

.github/workflows/upgrade-version-check.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
steps:
1313
- name: Checkout
1414
uses: actions/checkout@v3
15+
- uses: dsherret/rust-toolchain-file@v1
16+
- name: Set default rust toolchain
17+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
1518
# pnpm is required for regenerating the typescript bindings
1619
- name: Set up Node.js
1720
uses: actions/setup-node@v4

0 commit comments

Comments
 (0)