From 8a64ff717c5374742dcc5c4bab17c995f7e215bf Mon Sep 17 00:00:00 2001 From: Dave Rolsky Date: Sat, 11 Jan 2025 12:49:28 -0600 Subject: [PATCH] Run tests twice, one for main crate and once for subcrate It seems like restoring the cache for subcrate deletes sometimes removes the compiled binaries for the parent crate. I'm not sure what's going on here, as it doesn't happen every time. --- .github/workflows/test.yml | 55 +++++++++++++++++++++++--------------- run-tests/src/main.rs | 33 +++++++++++++---------- 2 files changed, 53 insertions(+), 35 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7c06fbf..f92db14 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -262,27 +262,7 @@ jobs: target: ${{ matrix.platform.target }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} strip: true - - name: Run build command for subdir - uses: ./ - with: - command: build - cross-version: ${{ matrix.platform.cross-version }} - cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} - working-directory: subcrate - target: ${{ matrix.platform.target }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - strip: true - - name: Run bench command - uses: ./ - with: - command: bench - cross-version: ${{ matrix.platform.cross-version }} - cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} - target: ${{ matrix.platform.target }} - working-directory: bench - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: ${{ matrix.platform.can_execute }} - - name: Check binary and cross on ${{ matrix.platform.platform_name }} + - name: Check binary and cross for main crate on ${{ matrix.platform.platform_name }} shell: bash run: | set -e @@ -294,6 +274,39 @@ jobs: --expect-cross-version "${{ matrix.platform.expect_cross_version }}" \ ${{ matrix.platform.expect_cross }} \ ${{ matrix.platform.expect_stripped }} + - name: Run build command for subdir + uses: ./ + with: + command: build + cross-version: ${{ matrix.platform.cross-version }} + cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} + working-directory: subcrate + target: ${{ matrix.platform.target }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + strip: true + - name: Check binary and cross for subcrate on ${{ matrix.platform.platform_name }} + shell: bash + run: | + set -e + set -x + cargo run --manifest-path ./run-tests/Cargo.toml -- \ + --checkout-root "$PWD" \ + --target "${{ matrix.platform.target }}" \ + --expect-file-re "${{ matrix.platform.expect_file_re }}" \ + --expect-cross-version "${{ matrix.platform.expect_cross_version }}" \ + ${{ matrix.platform.expect_cross }} \ + ${{ matrix.platform.expect_stripped }} \ + --is-subcrate + - name: Run bench command + uses: ./ + with: + command: bench + cross-version: ${{ matrix.platform.cross-version }} + cache-cross-binary: ${{ matrix.platform.cache-cross-binary }} + target: ${{ matrix.platform.target }} + working-directory: bench + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + if: ${{ matrix.platform.can_execute }} test-validate-inputs: name: Test validate-inputs diff --git a/run-tests/src/main.rs b/run-tests/src/main.rs index 66f83b5..66e69df 100644 --- a/run-tests/src/main.rs +++ b/run-tests/src/main.rs @@ -24,6 +24,8 @@ struct Args { expect_cross_version: Option, #[arg(long)] expect_stripped: bool, + #[arg(long)] + is_subcrate: bool, } fn main() { @@ -39,24 +41,27 @@ fn main() { ); let checkout_root_path = PathBuf::from(args.checkout_root); - let bin_paths = vec![ - checkout_root_path - .join("target") - .join(&args.target) - .join("debug") - .join("bin1"), - checkout_root_path - .join("target") - .join(&args.target) - .join("debug") - .join("bin2"), - checkout_root_path + let bin_paths = if args.is_subcrate { + vec![checkout_root_path .join("subcrate") .join("target") .join(&args.target) .join("debug") - .join("subcrate"), - ]; + .join("subcrate")] + } else { + vec![ + checkout_root_path + .join("target") + .join(&args.target) + .join("debug") + .join("bin1"), + checkout_root_path + .join("target") + .join(&args.target) + .join("debug") + .join("bin2"), + ] + }; for mut bin_path in bin_paths { if cfg!(windows) {