From 8cddb8c9e115bc13a8a4ee8884839a6c3333dfe9 Mon Sep 17 00:00:00 2001 From: Travis Finkenauer Date: Sat, 13 Apr 2024 22:46:21 -0700 Subject: [PATCH] ci: run 'cargo update' for non MSRV jobs For MSRV jobs, we don't want to update the dependencies in "Cargo.lock" since newer dependencies may not work on an older toolchain. --- .github/workflows/main.yml | 12 +++++++----- capstone-rs/ci/test.sh | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5d9df9c..0502671 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,10 +11,12 @@ jobs: fail-fast: false matrix: rust: - - 1.70.0 - - stable - - beta - - nightly + # Don't pull in newest dependencies when using old Rust toolchain + - version: 1.70.0 + env: SKIP_CARGO_UPDATE=1 + - version: stable + - version: beta + - version: nightly steps: - uses: actions/checkout@v2 @@ -22,7 +24,7 @@ jobs: - uses: actions-rs/toolchain@v1 with: profile: minimal - toolchain: ${{ matrix.rust }} + toolchain: ${{ matrix.rust.version }} override: true - name: test diff --git a/capstone-rs/ci/test.sh b/capstone-rs/ci/test.sh index 86af801..3a665cc 100755 --- a/capstone-rs/ci/test.sh +++ b/capstone-rs/ci/test.sh @@ -11,6 +11,7 @@ # - JOB: {*test,valgrind-test,bench,cov} # - PROFILES: list of {debug,release} [debug release] # - SHOULD_FAIL: (disabled by default; set to non-empty string to enable) +# - SKIP_CARGO_UPDATE: set to disable "cargo update" part of tests # - VALGRIND_TESTS: run tests under Valgrind set -euo pipefail @@ -174,6 +175,7 @@ run_kcov() { cov() { echo "Running coverage" + cargo_update install_kcov cleanup_cov @@ -193,6 +195,9 @@ cov() { } bench() { + echo "Running bench" + cargo_update + ${CARGO} bench } @@ -232,6 +237,8 @@ test_rust_file() { } run_tests() { + cargo_update + TMPFILE="$(mktemp /tmp/capstone-rs.XXXXXXXXXX)" [ -f "$TMPFILE" ] || Error "Could not make temp file" for PROFILE in $PROFILES; do @@ -284,6 +291,15 @@ run_tests() { rm "$TMPFILE" } +cargo_update() { + if [ -z "${SKIP_CARGO_UPDATE:-}" ]; then + echo "Updating dependencies in Cargo.lock" + ${CARGO} update + else + echo "Skipping 'cargo update' since SKIP_CARGO_UPDATE is set" + fi +} + PROFILES="${PROFILES-debug}" for PROFILE in $PROFILES; do profile_args "$PROFILE"