Skip to content

Commit

Permalink
ci: run 'cargo update' for non MSRV jobs
Browse files Browse the repository at this point in the history
For MSRV jobs, we don't want to update the dependencies in "Cargo.lock"
since newer dependencies may not work on an older toolchain.
  • Loading branch information
tmfink committed Apr 14, 2024
1 parent 9d08b16 commit 8cddb8c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ 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

- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
toolchain: ${{ matrix.rust.version }}
override: true

- name: test
Expand Down
16 changes: 16 additions & 0 deletions capstone-rs/ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -174,6 +175,7 @@ run_kcov() {

cov() {
echo "Running coverage"
cargo_update

install_kcov
cleanup_cov
Expand All @@ -193,6 +195,9 @@ cov() {
}

bench() {
echo "Running bench"
cargo_update

${CARGO} bench
}

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 8cddb8c

Please sign in to comment.