diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 414e61c6..35ad79c6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -117,10 +117,40 @@ jobs: cd semver cargo test - - name: build + build-binary: + name: Build binary + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + persist-credentials: false + path: 'semver' + + - name: Install rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + + - uses: Swatinem/rust-cache@v2 + with: + shared-key: 'semver' + workspaces: 'semver' + + - name: build and cache run: | cd semver cargo build + mkdir ../bins + mv target/debug/cargo-semver-checks ../bins/cargo-semver-checks + + - name: cache binary + uses: actions/cache/save@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} run-on-rust-libp2p: # Run cargo-semver-checks on a crate with no semver violations, @@ -131,6 +161,8 @@ jobs: # https://github.com/obi1kenobi/cargo-semver-check/issues/147 name: Run cargo-semver-checks on rust-libp2p 0.47.0 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -157,11 +189,19 @@ jobs: - name: Install protobuf-compiler run: sudo apt install protobuf-compiler - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -177,7 +217,7 @@ jobs: - name: Run semver-checks run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/core/Cargo.toml" --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/core/Cargo.toml" --verbose # Test passing package name explicitly. # It was previously possible to make the command above work while the one here failed. @@ -185,7 +225,7 @@ jobs: - name: Run semver-checks (alternative command) run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/core/Cargo.toml" --package="libp2p-core" --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/core/Cargo.toml" --package="libp2p-core" --verbose - name: Save rustdoc uses: actions/cache/save@v3 @@ -204,6 +244,8 @@ jobs: # https://github.com/libp2p/rust-libp2p/pull/2647#issuecomment-1340254920 name: Run cargo-semver-checks on libp2p-dcutr 1.62.0 and libp2p-relay 0.14.0 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -230,11 +272,19 @@ jobs: - name: Install protobuf-compiler run: sudo apt install protobuf-compiler - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -250,12 +300,12 @@ jobs: - name: Run semver-checks on libp2p-dcutr run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/protocols/dcutr/Cargo.toml" --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/protocols/dcutr/Cargo.toml" --verbose - name: Run semver-checks on libp2p-relay run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/protocols/relay/Cargo.toml" --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/protocols/relay/Cargo.toml" --verbose - name: Save rustdoc uses: actions/cache/save@v3 @@ -271,6 +321,8 @@ jobs: # https://github.com/libp2p/rust-libp2p/pull/3401#issuecomment-1409381365 name: Run cargo-semver-checks on libp2p-gossipsub 0.44.0 and libp2p-request-response 0.23.0 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -297,11 +349,19 @@ jobs: - name: Install protobuf-compiler run: sudo apt install protobuf-compiler - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -317,12 +377,12 @@ jobs: - name: Run semver-checks on libp2p-gossipsub run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/protocols/gossipsub/Cargo.toml" --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/protocols/gossipsub/Cargo.toml" --verbose - name: Run semver-checks on libp2p-request-response run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/protocols/request-response/Cargo.toml" --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/protocols/request-response/Cargo.toml" --verbose - name: Save rustdoc uses: actions/cache/save@v3 @@ -336,6 +396,8 @@ jobs: # https://github.com/obi1kenobi/cargo-semver-checks/issues/369 name: Run cargo-semver-checks on libp2p-uds 0.37.0 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -362,11 +424,19 @@ jobs: - name: Install protobuf-compiler run: sudo apt install protobuf-compiler - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -382,7 +452,7 @@ jobs: - name: Run semver-checks on libp2p-uds run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/transports/uds/Cargo.toml" --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/transports/uds/Cargo.toml" --verbose - name: Save rustdoc uses: actions/cache/save@v3 @@ -458,6 +528,8 @@ jobs: # https://github.com/obi1kenobi/cargo-semver-checks/issues/261 name: Run cargo-semver-checks on bevy_core v0.9.0 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -480,11 +552,19 @@ jobs: profile: minimal override: true - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -500,7 +580,7 @@ jobs: - name: Run semver-checks run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/crates/bevy_core/Cargo.toml" --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/crates/bevy_core/Cargo.toml" --verbose - name: Save rustdoc uses: actions/cache/save@v3 @@ -515,6 +595,8 @@ jobs: # https://github.com/obi1kenobi/cargo-semver-checks/issues/265 name: Run cargo-semver-checks on bevy_gltf v0.9.1 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -537,11 +619,19 @@ jobs: profile: minimal override: true - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -557,7 +647,7 @@ jobs: - name: Run semver-checks run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/crates/bevy_gltf/Cargo.toml" --baseline-version 0.9.0 --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/crates/bevy_gltf/Cargo.toml" --baseline-version 0.9.0 --verbose - name: Save rustdoc uses: actions/cache/save@v3 @@ -571,6 +661,8 @@ jobs: # https://github.com/obi1kenobi/cargo-semver-checks/issues/370 name: Run cargo-semver-checks on sqllogictest v0.13.0 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -593,11 +685,19 @@ jobs: profile: minimal override: true - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -613,12 +713,12 @@ jobs: - name: Run via workspace Cargo.toml run: | cd semver - cargo run semver-checks check-release --manifest-path ../subject/Cargo.toml -p sqllogictest --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path ../subject/Cargo.toml -p sqllogictest --verbose - name: Run via package Cargo.toml run: | cd semver - cargo run semver-checks check-release --manifest-path ../subject/sqllogictest/Cargo.toml --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path ../subject/sqllogictest/Cargo.toml --verbose - name: Save rustdoc uses: actions/cache/save@v3 @@ -632,6 +732,8 @@ jobs: # https://github.com/obi1kenobi/cargo-semver-checks/issues/380 name: Run cargo-semver-checks on tokio ~v1.25.0 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -654,11 +756,19 @@ jobs: profile: minimal override: true - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -679,21 +789,21 @@ jobs: - name: Run semver-checks on tokio-stream crate manifest only run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/tokio-stream/Cargo.toml" --release-type minor --exclude benches --exclude examples --exclude stress-test --exclude tests-build --exclude tests-integration --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/tokio-stream/Cargo.toml" --release-type minor --exclude benches --exclude examples --exclude stress-test --exclude tests-build --exclude tests-integration --verbose # This test caught a bug where `--exclude` was silently ignored # if `--workspace` wasn't set at the same time. - name: Run semver-checks on workspace manifest with explicit exclusions run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/Cargo.toml" --release-type minor --exclude examples --exclude stress-test --exclude tests-build --exclude tests-integration --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/Cargo.toml" --release-type minor --exclude examples --exclude stress-test --exclude tests-build --exclude tests-integration --verbose # This test caught a bug where `publish = false` items in a workspace were semver-checked # unless either explicit `--workspace` was present or was implied e.g. via `--exclude`. - name: Run semver-checks on workspace manifest with implicit exclusions run: | cd semver - cargo run semver-checks check-release --manifest-path="../subject/Cargo.toml" --release-type minor --verbose + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/Cargo.toml" --release-type minor --verbose - name: Save rustdoc uses: actions/cache/save@v3 @@ -708,6 +818,8 @@ jobs: # https://github.com/clap-rs/clap/issues/3876 name: Run cargo-semver-checks on clap v3.2.0 runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -738,11 +850,19 @@ jobs: profile: minimal override: true - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -760,7 +880,7 @@ jobs: run: | cd semver set -euo pipefail - cargo run semver-checks check-release --manifest-path="../subject-current/Cargo.toml" --baseline-root="../subject-baseline/Cargo.toml" --verbose | tee output + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject-current/Cargo.toml" --baseline-root="../subject-baseline/Cargo.toml" --verbose | tee output touch unexpectedly_did_not_fail - name: Check whether it failed @@ -792,7 +912,7 @@ jobs: run: | cd semver set -euo pipefail - cargo run semver-checks check-release --manifest-path="../subject-current/Cargo.toml" --baseline-rev=524e36cf1a67ee6a447d3615a70b065d2b4f5e60 --verbose | tee output + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject-current/Cargo.toml" --baseline-rev=524e36cf1a67ee6a447d3615a70b065d2b4f5e60 --verbose | tee output touch unexpectedly_did_not_fail - name: Check whether it failed @@ -826,6 +946,8 @@ jobs: # - cargo-semver-checks detects the semver break we've manufactured. name: Run cargo-semver-checks on ref-slice fork runs-on: ubuntu-latest + needs: + - build-binary steps: - name: Checkout cargo-semver-checks uses: actions/checkout@v3 @@ -848,11 +970,19 @@ jobs: profile: minimal override: true - - uses: Swatinem/rust-cache@v2 + - name: Restore cargo index + uses: Swatinem/rust-cache@v2 with: - shared-key: 'semver' - workspaces: 'semver' - save-if: false + shared-key: 'cargo-registry' + cache-targets: false + + - name: Restore binary + id: cache-binary + uses: actions/cache/restore@v3 + with: + path: bins/ + key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} + fail-on-cache-miss: true - shell: bash run: | @@ -870,7 +1000,7 @@ jobs: run: | cd semver set -euo pipefail - cargo run semver-checks check-release --manifest-path="../subject/Cargo.toml" --verbose 2>&1 | tee output + ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/Cargo.toml" --verbose 2>&1 | tee output touch unexpectedly_did_not_fail - name: Check whether it failed