Skip to content

Commit 3a2e234

Browse files
CI - Fix smoketests running twice (#4281)
# Description of Changes Smoketests were running twice because `tests/foo.rs` automatically gets turned into a test binary, but we also had a `mod.rs` that listed each file, so they were getting tested via that as well. This was first broken in #4184. # API and ABI breaking changes None. # Expected complexity level and risk 1 # Testing - [x] CI passes - [x] If I run `cargo ci smoketests` locally, I still see the CLI tests running - [x] If I run `cargo ci smoketests` locally, I do not see a particular CLI test name appearing more than once (e.g. `cli_cannot_publish_breaking_change_without_flag`) - [x] `cargo ci smoketests check-mod-list` passes - [x] `cargo ci smoketests check-mod-list` fails if I `touch crates/smoketests/tests/smoketests/foo.rs` --------- Signed-off-by: Zeke Foppa <196249+bfops@users.noreply.github.com> Co-authored-by: Zeke Foppa <bfops@users.noreply.github.com> Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
1 parent 54e24cc commit 3a2e234

47 files changed

Lines changed: 200 additions & 11 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,3 +1187,59 @@ jobs:
11871187
fi
11881188
11891189
echo "No Python smoketest changes detected."
1190+
1191+
smoketests_mod_rs_complete:
1192+
name: Check smoketests/mod.rs is complete
1193+
runs-on: ubuntu-latest
1194+
permissions:
1195+
contents: read
1196+
env:
1197+
CARGO_TARGET_DIR: ${{ github.workspace }}/target
1198+
steps:
1199+
- name: Find Git ref
1200+
env:
1201+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1202+
shell: bash
1203+
run: |
1204+
PR_NUMBER="${{ github.event.inputs.pr_number || null }}"
1205+
if test -n "${PR_NUMBER}"; then
1206+
GIT_REF="$( gh pr view --repo clockworklabs/SpacetimeDB $PR_NUMBER --json headRefName --jq .headRefName )"
1207+
else
1208+
GIT_REF="${{ github.ref }}"
1209+
fi
1210+
echo "GIT_REF=${GIT_REF}" >>"$GITHUB_ENV"
1211+
- name: Checkout sources
1212+
uses: actions/checkout@v4
1213+
with:
1214+
ref: ${{ env.GIT_REF }}
1215+
- uses: dsherret/rust-toolchain-file@v1
1216+
- name: Set default rust toolchain
1217+
run: rustup default $(rustup show active-toolchain | cut -d' ' -f1)
1218+
- name: Cache Rust dependencies
1219+
uses: Swatinem/rust-cache@v2
1220+
with:
1221+
workspaces: ${{ github.workspace }}
1222+
shared-key: spacetimedb
1223+
cache-on-failure: false
1224+
cache-all-crates: true
1225+
cache-workspace-crates: true
1226+
prefix-key: v1
1227+
1228+
# This step shouldn't be needed, but somehow we end up with caches that are missing librusty_v8.a.
1229+
# ChatGPT suspects that this could be due to different build invocations using the same target dir,
1230+
# and this makes sense to me because we only see it in this job where we mix `cargo build -p` with
1231+
# `cargo build --manifest-path` (which apparently build different dependency trees).
1232+
# However, we've been unable to fix it so... /shrug
1233+
- name: Check v8 outputs
1234+
shell: bash
1235+
run: |
1236+
find "${CARGO_TARGET_DIR}"/ -type f | grep '[/_]v8' || true
1237+
if ! [ -f "${CARGO_TARGET_DIR}"/debug/gn_out/obj/librusty_v8.a ]; then
1238+
echo "Could not find v8 output file librusty_v8.a; rebuilding manually."
1239+
cargo clean -p v8 || true
1240+
cargo build -p v8
1241+
fi
1242+
1243+
- name: Verify crates/smoketests/tests/smoketests/mod.rs lists all entries
1244+
run: |
1245+
cargo ci smoketests check-mod-list
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Single test binary entry point - includes all smoketests
2+
// We put the tests in a single submodule because if they are at the toplevel then
3+
// they all build and link independently, which takes a lot of linker time.
4+
// This has the unfortunate side effect of requiring that they are all listed in a mod.rs,
5+
// but what can you do ¯\_(ツ)_/¯.
6+
mod smoketests;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)