From 31009109ca83325ff55feef562d831f5a68d72b4 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 11 Dec 2024 19:09:13 +1100 Subject: [PATCH 1/7] chore(ci): reduce ci usage This should help reduce the CI usage by: 1. Only running CI on either: - PRs targetting `master` - pushes to `master` Most importantly, CI is no longer doubled in PRs (as previously, `push` and `pull_request` would _both_ be triggered). 2. Cancelling existing runs if a new commit is added Signed-off-by: JP-Ellis --- .github/workflows/build-ffi.yml | 12 +++++++++++- .github/workflows/build.yml | 13 +++++++++++-- .github/workflows/compatability-suite.yml | 12 +++++++++++- 3 files changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-ffi.yml b/.github/workflows/build-ffi.yml index 04497d61..f0f1e47a 100644 --- a/.github/workflows/build-ffi.yml +++ b/.github/workflows/build-ffi.yml @@ -1,6 +1,16 @@ name: Pact-Rust FFI Build -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true jobs: build: diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2c41762c..48e982e0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,16 @@ name: Pact-Rust Build -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true jobs: build: @@ -55,4 +65,3 @@ jobs: - uses: actions/checkout@v3 - run: cargo check --no-default-features working-directory: rust - diff --git a/.github/workflows/compatability-suite.yml b/.github/workflows/compatability-suite.yml index b2a03729..832c9358 100644 --- a/.github/workflows/compatability-suite.yml +++ b/.github/workflows/compatability-suite.yml @@ -1,6 +1,16 @@ name: Pact-Rust Compatibility Suite -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} + cancel-in-progress: true env: pact_do_not_track: true From eb0df9aa47aa3e0bdd6fd28f20c56ff8b2833138 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 11 Dec 2024 19:45:59 +1100 Subject: [PATCH 2/7] chore(ci): combine compatibility suite tests The building of dependencies takes a lot of time, providing no benefit to splitting the CI in each version. Instead, combine them all and use nextest to speed up tests. Signed-off-by: JP-Ellis --- .github/workflows/compatability-suite.yml | 47 ++++------------------- 1 file changed, 8 insertions(+), 39 deletions(-) diff --git a/.github/workflows/compatability-suite.yml b/.github/workflows/compatability-suite.yml index 832c9358..aac4044a 100644 --- a/.github/workflows/compatability-suite.yml +++ b/.github/workflows/compatability-suite.yml @@ -16,51 +16,20 @@ env: pact_do_not_track: true jobs: - v1: + compatibility-suite: runs-on: ${{ matrix.operating-system }} strategy: fail-fast: false matrix: - operating-system: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] - steps: - - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@stable - - name: Run Cucumber - run: cargo test --test v1* - working-directory: compatibility-suite - v2: - runs-on: ${{ matrix.operating-system }} - strategy: - fail-fast: false - matrix: - operating-system: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] - steps: - - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@stable - - name: Run Cucumber - run: cargo test --test v2* - working-directory: compatibility-suite - v3: - runs-on: ${{ matrix.operating-system }} - strategy: - fail-fast: false - matrix: - operating-system: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] - steps: - - uses: actions/checkout@v2 - - uses: dtolnay/rust-toolchain@stable - - name: Run Cucumber - run: cargo test --test v3* - working-directory: compatibility-suite - v4: - runs-on: ${{ matrix.operating-system }} - strategy: - fail-fast: false - matrix: - operating-system: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] + operating-system: [ubuntu-latest, windows-latest, macos-13, macos-14] steps: - uses: actions/checkout@v2 - uses: dtolnay/rust-toolchain@stable + - uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest - name: Run Cucumber - run: cargo test --test v4* + # Note: cucumber's test executables are incompatible with nextest + # See: https://github.com/nextest-rs/nextest/issues/1329 + run: cargo test working-directory: compatibility-suite From d72589b1955c09677109c48c6e2a3853b4229dbc Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 11 Dec 2024 19:47:04 +1100 Subject: [PATCH 3/7] chore(ci): make more use of nextest Nextest is typically faster to run Signed-off-by: JP-Ellis --- .github/workflows/build.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 48e982e0..5d09b94f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -28,24 +28,24 @@ jobs: with: toolchain: stable components: clippy + - uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest - name: Install shared mime info DB if: runner.os == 'macOS' run: brew install shared-mime-info - name: Tests - run: cargo test + run: cargo nextest run working-directory: rust env: RUST_LOG: debug RUST_BACKTRACE: 1 - name: Run mock_server_logs test - run: cargo test -p pact_ffi returns_mock_server_logs -- --nocapture --include-ignored + run: cargo nextest run -p pact_ffi returns_mock_server_logs -- --include-ignored working-directory: rust env: RUST_LOG: debug RUST_BACKTRACE: 1 - - name: Build Components - run: cargo build - working-directory: rust - name: Clippy if: runner.os == 'Linux' run: cargo clippy From 401854512e32faf888024e449b360c118806db2b Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 11 Dec 2024 20:16:41 +1100 Subject: [PATCH 4/7] chore(ci): use github runner's native container integration Signed-off-by: JP-Ellis --- .github/workflows/build.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d09b94f..e3b7dfed 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -53,10 +53,20 @@ jobs: musl-build: runs-on: ubuntu-latest + container: + image: pactfoundation/rust-musl-build steps: - uses: actions/checkout@v3 - - run: | - docker run --rm --user "$(id -u)":"$(id -g)" -v $(pwd):/workspace -w /workspace/rust -t -e TZ=UTC pactfoundation/rust-musl-build ./scripts/ci-musl-build.sh + - uses: dtolnay/rust-toolchain@stable + with: + toolchain: stable + components: clippy + - uses: taiki-e/install-action@v2 + with: + tool: cargo-nextest + - name: Tests + run: cargo nextest run + working-directory: rust check-features: From 0856baa2d9462f04f0f5d832a4ec94c541bc7a83 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 11 Dec 2024 20:17:02 +1100 Subject: [PATCH 5/7] chore(ci): consolidate envs Signed-off-by: JP-Ellis --- .github/workflows/build-ffi.yml | 8 ++++++-- .github/workflows/build.yml | 14 ++++++-------- .github/workflows/compatability-suite.yml | 5 ++++- .github/workflows/release.yml | 9 ++++++--- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-ffi.yml b/.github/workflows/build-ffi.yml index f0f1e47a..444d6b16 100644 --- a/.github/workflows/build-ffi.yml +++ b/.github/workflows/build-ffi.yml @@ -12,6 +12,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref || github.run_id }} cancel-in-progress: true +env: + RUST_BACKTRACE: "1" + RUST_LOG: "debug" + PACT_DO_NOT_TRACK: "true" + CARGO_TERM_COLOR: always + jobs: build: runs-on: ${{ matrix.operating-system }} @@ -20,8 +26,6 @@ jobs: matrix: operating-system: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] rust: [ stable ] - env: - pact_do_not_track: true steps: - uses: actions/checkout@v3 - run: rustc --version || true diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e3b7dfed..d0f54038 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,6 +12,12 @@ concurrency: group: ${{ github.workflow }}-${{ github.ref || github.run_id }} cancel-in-progress: true +env: + RUST_BACKTRACE: "1" + RUST_LOG: "debug" + PACT_DO_NOT_TRACK: "true" + CARGO_TERM_COLOR: always + jobs: build: runs-on: ${{ matrix.operating-system }} @@ -20,8 +26,6 @@ jobs: matrix: operating-system: [ ubuntu-latest, windows-latest, macos-13, macos-14 ] rust: [ stable ] - env: - pact_do_not_track: true steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable @@ -37,15 +41,9 @@ jobs: - name: Tests run: cargo nextest run working-directory: rust - env: - RUST_LOG: debug - RUST_BACKTRACE: 1 - name: Run mock_server_logs test run: cargo nextest run -p pact_ffi returns_mock_server_logs -- --include-ignored working-directory: rust - env: - RUST_LOG: debug - RUST_BACKTRACE: 1 - name: Clippy if: runner.os == 'Linux' run: cargo clippy diff --git a/.github/workflows/compatability-suite.yml b/.github/workflows/compatability-suite.yml index aac4044a..eb4d6aa5 100644 --- a/.github/workflows/compatability-suite.yml +++ b/.github/workflows/compatability-suite.yml @@ -13,7 +13,10 @@ concurrency: cancel-in-progress: true env: - pact_do_not_track: true + RUST_BACKTRACE: "1" + RUST_LOG: "debug" + PACT_DO_NOT_TRACK: "true" + CARGO_TERM_COLOR: always jobs: compatibility-suite: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 25074dd5..5fa809da 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -18,6 +18,12 @@ concurrency: group: release-${{ github.ref }} cancel-in-progress: true +env: + RUST_BACKTRACE: "1" + RUST_LOG: "debug" + PACT_DO_NOT_TRACK: "true" + CARGO_TERM_COLOR: always + jobs: build-release: name: build-release (${{ matrix.targets }}) @@ -43,9 +49,6 @@ jobs: targets: aarch64-apple-darwin fail-fast: false - env: - pact_do_not_track: true - steps: - uses: actions/checkout@v4 From c459bd533b4a34c108b736969b04bae237bd95ef Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 11 Dec 2024 20:24:04 +1100 Subject: [PATCH 6/7] chore(ci): consoldate rust-toolchain calls Signed-off-by: JP-Ellis --- .github/workflows/build-ffi.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build-ffi.yml b/.github/workflows/build-ffi.yml index 444d6b16..2e9d5720 100644 --- a/.github/workflows/build-ffi.yml +++ b/.github/workflows/build-ffi.yml @@ -33,13 +33,10 @@ jobs: - uses: dtolnay/rust-toolchain@stable with: toolchain: stable + components: rustfmt - name: Install shared mime info DB if: runner.os == 'macOS' run: brew install shared-mime-info - - uses: dtolnay/rust-toolchain@nightly - with: - toolchain: nightly - components: rustfmt - name: Install doxygen if: runner.os == 'Linux' run: sudo apt-get install -y doxygen From f80cf9f791a3c0e9a68a48a6f2395fc693d27929 Mon Sep 17 00:00:00 2001 From: JP-Ellis Date: Wed, 11 Dec 2024 21:12:24 +1100 Subject: [PATCH 7/7] chore(ci): add rust caching Signed-off-by: JP-Ellis --- .github/workflows/build-ffi.yml | 4 ++++ .github/workflows/build.yml | 4 ++++ .github/workflows/compatability-suite.yml | 6 ++++++ .github/workflows/release.yml | 4 ++-- 4 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-ffi.yml b/.github/workflows/build-ffi.yml index 2e9d5720..042c5bc2 100644 --- a/.github/workflows/build-ffi.yml +++ b/.github/workflows/build-ffi.yml @@ -34,6 +34,10 @@ jobs: with: toolchain: stable components: rustfmt + - uses: Swatinem/rust-cache@v2 + with: + workspaces: rust + shared-key: ${{ runner.os }} - name: Install shared mime info DB if: runner.os == 'macOS' run: brew install shared-mime-info diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0f54038..68cafa64 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -62,6 +62,10 @@ jobs: - uses: taiki-e/install-action@v2 with: tool: cargo-nextest + - uses: Swatinem/rust-cache@v2 + with: + workspaces: rust + shared-key: ${{ runner.os }}-musl - name: Tests run: cargo nextest run working-directory: rust diff --git a/.github/workflows/compatability-suite.yml b/.github/workflows/compatability-suite.yml index eb4d6aa5..175d7ef2 100644 --- a/.github/workflows/compatability-suite.yml +++ b/.github/workflows/compatability-suite.yml @@ -31,6 +31,12 @@ jobs: - uses: taiki-e/install-action@v2 with: tool: cargo-nextest + - uses: Swatinem/rust-cache@v2 + with: + workspaces: | + rust + compatibility-suite + shared-key: ${{ runner.os }} - name: Run Cucumber # Note: cucumber's test executables are incompatible with nextest # See: https://github.com/nextest-rs/nextest/issues/1329 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5fa809da..fee21da6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -62,10 +62,10 @@ jobs: uses: Swatinem/rust-cache@v2 with: workspaces: rust - key: ${{ matrix.targets }} + shared-key: ${{ runner.os }} - name: Set up QEMU - if: runner.os == 'Linux' + if: runner.os == 'Linux' && startsWith(matrix.targets, 'aarch64') uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx