Draft: refactor cli with annotate-snippets
#2841
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '17 7 * * 1-5' # run once per day Monday-Friday at 7:17am | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
env: | |
RUST_BACKTRACE: 1 | |
CARGO_TERM_COLOR: always | |
CARGO_TERM_VERBOSE: 'true' | |
jobs: | |
ci-everything: | |
name: All CI stages | |
runs-on: ubuntu-latest | |
needs: | |
- lint | |
- rust-tests | |
- cross-version-caching | |
- cross-feature-caching | |
- run-on-rust-libp2p | |
- run-on-libp2p-dcutr-relay | |
- run-on-libp2p-gossipsub-request-response | |
- run-on-libp2p-uds | |
- run-on-libp2p-whose-dependency-has-warnings | |
- run-on-core-graphics | |
- run-on-bevy-core | |
- run-on-bevy-gltf | |
- run-on-clap | |
- run-on-sqllogictest | |
- run-on-ref-slice-fork | |
- run-on-ref-slice-fork-windows | |
- run-on-tokio-explicit | |
- run-on-tokio-implicit | |
- run-on-perf-event-open-sys2 | |
- fails-on-too-old-rustc | |
if: ${{ success() || failure() }} # Run this job even if a dependency has failed. | |
steps: | |
- name: Job outcomes | |
run: | | |
echo "lint: ${{ needs.lint.result }}" | |
echo "rust-tests: ${{ needs.rust-tests.result }}" | |
echo "cross-version-caching: ${{ needs.cross-version-caching.result }}" | |
echo "cross-feature-caching: ${{ needs.cross-feature-caching.result }}" | |
echo "run-on-rust-libp2p: ${{ needs.run-on-rust-libp2p.result }}" | |
echo "run-on-libp2p-dcutr-relay: ${{ needs.run-on-libp2p-dcutr-relay.result }}" | |
echo "run-on-libp2p-gossipsub-request-response: ${{ needs.run-on-libp2p-gossipsub-request-response.result }}" | |
echo "run-on-libp2p-uds: ${{ needs.run-on-libp2p-uds.result }}" | |
echo "run-on-libp2p-whose-dependency-has-warnings: ${{ needs.run-on-libp2p-whose-dependency-has-warnings.result }}" | |
echo "run-on-core-graphics: ${{ needs.run-on-core-graphics.result }}" | |
echo "run-on-bevy-core: ${{ needs.run-on-bevy-core.result }}" | |
echo "run-on-bevy-gltf: ${{ needs.run-on-bevy-gltf.result }}" | |
echo "run-on-clap: ${{ needs.run-on-clap.result }}" | |
echo "run-on-sqllogictest: ${{ needs.run-on-sqllogictest.result }}" | |
echo "run-on-ref-slice-fork: ${{ needs.run-on-ref-slice-fork.result }}" | |
echo "run-on-ref-slice-fork-windows: ${{ needs.run-on-ref-slice-fork-windows.result }}" | |
echo "run-on-tokio-explicit: ${{ needs.run-on-tokio-explicit.result }}" | |
echo "run-on-tokio-implicit: ${{ needs.run-on-tokio-implicit.result }}" | |
echo "run-on-perf-event-open-sys2: ${{ needs.run-on-perf-event-open-sys2.result }}" | |
echo "fails-on-too-old-rustc: ${{ needs.fails-on-too-old-rustc.result }}" | |
# Fail this required job if any of its dependent jobs have failed. | |
# | |
# Do not attempt to consolidate these steps into one step, it won't work. | |
# Multi-line `if` clauses are not evaluated properly: see the intermediate commits in | |
# https://github.com/obi1kenobi/cargo-semver-checks/pull/405 | |
- if: ${{ needs.lint.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.rust-tests.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.cross-version-caching.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.cross-feature-caching.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-rust-libp2p.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-libp2p-dcutr-relay.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-libp2p-gossipsub-request-response.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-libp2p-uds.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-libp2p-whose-dependency-has-warnings.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-core-graphics.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-bevy-core.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-bevy-gltf.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-clap.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-sqllogictest.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-ref-slice-fork.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-ref-slice-fork-windows.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-tokio-explicit.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-tokio-implicit.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.run-on-perf-event-open-sys2.result != 'success' }} | |
run: exit 1 | |
- if: ${{ needs.fails-on-too-old-rustc.result != 'success' }} | |
run: exit 1 | |
lint: | |
name: Check lint and rustfmt | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Install rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
components: rustfmt, clippy | |
cache: false | |
rustflags: "" | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: 'semver' | |
# Ensure we include all new non-default features here explicitly, except for | |
# pass-through mutually-exclusive features from our dependencies such as: | |
# https://github.com/obi1kenobi/cargo-semver-checks/pull/824 | |
# | |
# Ideally, one day we'd be able to do something like "`--all-features` except feature X": | |
# https://github.com/rust-lang/cargo/issues/3126 | |
- name: cargo clippy | |
run: cargo clippy --manifest-path semver/Cargo.toml --workspace --all-targets --no-deps -- -D warnings --allow deprecated | |
- name: cargo fmt | |
run: cargo fmt --manifest-path semver/Cargo.toml -- --check | |
# Ensure we include all new non-default features here explicitly, except for | |
# pass-through mutually-exclusive features from our dependencies such as: | |
# https://github.com/obi1kenobi/cargo-semver-checks/pull/824 | |
# | |
# Ideally, one day we'd be able to do something like "`--all-features` except feature X": | |
# https://github.com/rust-lang/cargo/issues/3126 | |
- name: cargo doc | |
env: | |
RUSTDOCFLAGS: -D warnings | |
run: cargo doc --manifest-path semver/Cargo.toml --workspace --no-deps --document-private-items | |
rust-tests: | |
name: Run tests | |
runs-on: ubuntu-latest | |
continue-on-error: ${{ matrix.experimental }} | |
strategy: | |
matrix: | |
# IMPORTANT: When updating the versions here, make sure you also update | |
# the `fails-on-too-old-rustc` job and its error message to | |
# to account for the raised minimum required version. | |
# | |
# Also make sure to update the MSRV in the cargo-semver-checks-action CI: | |
# https://github.com/obi1kenobi/cargo-semver-checks-action/blob/main/.github/workflows/test-action.yml#L18 | |
toolchain: ["1.77", "1.78", "1.79", "1.80", "stable", "beta"] | |
experimental: [false] | |
include: | |
- toolchain: "nightly" | |
experimental: true | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ matrix.toolchain }} | |
rustflags: "" | |
cache: false | |
- name: restore test rustdocs | |
id: cache-test-rustdocs | |
uses: actions/cache@v4 | |
with: | |
path: semver/localdata/test_data/ | |
key: test-rustdocs-${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/test_crates/**/*.rs') }} | |
- name: Regenerate test data | |
if: steps.cache-test-rustdocs.outputs.cache-hit != 'true' | |
run: | | |
cd semver | |
./scripts/regenerate_test_rustdocs.sh +${{ matrix.toolchain }} | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: 'semver' | |
- name: compile | |
run: | | |
cd semver | |
cargo test --no-run | |
- name: test | |
run: | | |
cd semver | |
cargo test | |
build-binary: | |
name: Build binary | |
runs-on: ubuntu-latest | |
env: | |
CARGO_INCREMENTAL: 0 | |
SCCACHE_GHA_ENABLED: "true" | |
RUSTC_WRAPPER: "sccache" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Install rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
rustflags: "" | |
cache: false | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: 'semver' | |
- name: Set up sccache | |
uses: mozilla-actions/[email protected] | |
- name: build and cache | |
run: | | |
cd semver | |
sccache --zero-stats | |
cargo build | |
sccache --show-stats | |
mkdir ../bins | |
mv target/debug/cargo-semver-checks ../bins/cargo-semver-checks | |
- name: cache binary | |
uses: actions/cache/save@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
build-binary-windows: | |
# It could be easily combined into a single job with build-binary using the | |
# matrix strategy, but it is not a good idea. Building the tool on Windows | |
# is much slower and if the matrix strategy is used, there is currently no | |
# supported by GitHub Actions way to depend only on a single case. It means | |
# all semver checks below would have to wait before both binaries are built, | |
# which would make whole CI last longer. | |
name: Build binary (Windows) | |
runs-on: windows-latest | |
env: | |
CARGO_INCREMENTAL: 0 | |
SCCACHE_GHA_ENABLED: "true" | |
RUSTC_WRAPPER: "sccache" | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Install rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
rustflags: "" | |
cache: false | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: 'semver' | |
- name: Set up sccache | |
uses: mozilla-actions/[email protected] | |
- name: build and cache | |
run: | | |
cd semver | |
sccache --zero-stats | |
cargo build | |
sccache --show-stats | |
mkdir ..\bins | |
mv target\debug\cargo-semver-checks.exe ..\bins\cargo-semver-checks.exe | |
- name: cache binary | |
uses: actions/cache/save@v4 | |
with: | |
path: bins\ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
cross-version-caching: | |
# Ensure that cached rustdoc JSON files from an mismatched rustdoc version | |
# are transparently cleared and overwritten with the rustdoc version from the current toolchain. | |
# Fixes: https://github.com/obi1kenobi/cargo-semver-checks/issues/415 | |
name: 'Caching across rustdoc versions' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
env: | |
OLDER_RUST: "1.77" # Rust 1.77 uses rustdoc v28 | |
NEWER_RUST: "1.80" # Rust 1.80 uses rustdoc v30 | |
steps: | |
- name: Put env vars in outputs | |
id: vars | |
run: | | |
echo "older-rust=$OLDER_RUST" >> $GITHUB_OUTPUT | |
echo "newer-rust=$NEWER_RUST" >> $GITHUB_OUTPUT | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout rust-libp2p | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'libp2p/rust-libp2p' | |
ref: '3371d7ceab242440216ae9ab99829631fa418f3b' | |
path: 'subject' | |
# rust-libp2p requires protobuf-compiler. | |
- name: Install protobuf-compiler | |
run: sudo apt install protobuf-compiler | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ steps.vars.outputs.older-rust }} | |
rustflags: "" | |
cache: false | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: cross-version-caching-${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-libp2p_core-0_37_0 | |
# If we failed to set up the cache, set it up now. | |
- name: Run semver-checks | |
if: steps.cache.outputs.cache-hit != 'true' | |
run: | | |
cd semver | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/core/Cargo.toml" --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: cross-version-caching-${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Install newer rust | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: ${{ steps.vars.outputs.newer-rust }} | |
rustflags: "" | |
cache: false | |
- name: Check with older rustdoc version cached | |
run: | | |
# Echo commands to make debugging this script easier. | |
set -x | |
# Use a separate workspace, to avoid contaminating the cache for Swatinem/rust-cache@v2 | |
cp -R subject subject-new | |
# Show what's in the cache. | |
ls subject-new/target/semver-checks/cache/ | |
# Ensure the previous cached rustdoc file still exists. | |
[ -f "subject-new/target/semver-checks/cache/registry-libp2p_core-0_37_0.json" ] || { \ | |
echo "could not find libp2p-core cache file"; \ | |
exit 1; | |
} | |
export OLD_RUSTDOC_VERSION="$(jq .format_version subject-new/target/semver-checks/cache/registry-libp2p_core-0_37_0.json)" | |
# Run cargo-semver-checks with the older cached file. | |
# In a prior step, we installed a newer Rust, so we'll set that as the default | |
# for cargo-semver-checks to invoke here. | |
rustup override set "$NEWER_RUST" | |
bins/cargo-semver-checks semver-checks check-release --manifest-path="subject-new/core/Cargo.toml" --verbose | |
export NEW_RUSTDOC_VERSION="$(jq .format_version subject-new/target/semver-checks/cache/registry-libp2p_core-0_37_0.json)" | |
# Ensure the cached rustdoc versions were indeed different before and after. | |
[ "$OLD_RUSTDOC_VERSION" != "$NEW_RUSTDOC_VERSION" ] || exit 1 | |
cross-feature-caching: | |
# Ensure that cached rustdoc JSON files created with mismatched feature config is not used. | |
name: 'Caching with feature config changed' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
# This is a fork of serde, modified to make feature `unstable` break semver. | |
- name: Checkout fork of serde | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'staniewzki/serde' | |
ref: 'c479da812fd421260667c02049e6d11edd82c2dc' | |
path: 'subject' | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: cross-feature-caching-${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-serde-1_0_162 | |
# Run even if there was a cache hit, to make sure the check passes. | |
- name: Run semver-checks | |
run: | | |
cd semver | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/serde/Cargo.toml" --verbose | |
# Run cargo-semver-checks, enabling feature `unstable` this time. | |
# We expect this to fail. | |
# This run must not use the `serde` rustdoc without this feature as a baseline. | |
# If that happens, this check will unexpectedly pass -- and the test will fail. | |
- name: Check with rustdoc for mismatching feature config cached | |
continue-on-error: true | |
run: | | |
cd semver | |
set -euo pipefail | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/serde/Cargo.toml" --verbose --features unstable | tee output | |
touch unexpectedly_did_not_fail | |
- name: Check whether it failed | |
run: | | |
cd semver | |
if [ -f unexpectedly_did_not_fail ]; then exit 1; else exit 0; fi | |
- name: Check output | |
run: | | |
cd semver | |
EXPECTED="$(echo -e "--- failure struct_missing: pub struct removed or renamed ---")" | |
RESULT="$(cat output | grep failure)" | |
diff <(echo "$RESULT") <(echo "$EXPECTED") | |
- name: Verify cached rustdoc's hash | |
run: | | |
if [ -f subject/target/semver-checks/cache/registry-serde-1_0_162-f0dcb72a80405fd6.json ]; then exit 0; else exit 1; fi | |
- name: Cleanup | |
run: | | |
cd semver | |
rm output | |
rm -f unexpectedly_did_not_fail | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: cross-feature-caching-${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-rust-libp2p: | |
# Run cargo-semver-checks on a crate with no semver violations, | |
# to make sure there are no false-positives. | |
# | |
# cargo-semver-checks previously reported a false-positive here, | |
# since an enum variant in the crate was included by a feature: | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/147 | |
name: 'Semver: libp2p-core 0.37.0' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout rust-libp2p | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'libp2p/rust-libp2p' | |
ref: '3371d7ceab242440216ae9ab99829631fa418f3b' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
# rust-libp2p requires protobuf-compiler. | |
- name: Install protobuf-compiler | |
run: sudo apt install protobuf-compiler | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-libp2p_core-0_37_0 | |
- name: Run semver-checks | |
run: | | |
cd semver | |
../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. | |
# Reference: https://github.com/obi1kenobi/cargo-semver-checks/issues/174 | |
- name: Run semver-checks (alternative command) | |
run: | | |
cd semver | |
../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@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-libp2p-dcutr-relay: | |
# Run cargo-semver-checks on a crate with no semver violations, | |
# to make sure there are no false-positives. | |
# | |
# cargo-semver-checks previously reported false-positives here | |
# due to renaming re-exports causing confusion about which types match each other: | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/202 | |
# https://github.com/libp2p/rust-libp2p/pull/2647#issuecomment-1340254920 | |
name: 'Semver: 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@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout rust-libp2p | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'libp2p/rust-libp2p' | |
ref: 'be0b62a78fe9d72811b9eda742137cc8ddc4da35' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
# rust-libp2p requires protobuf-compiler. | |
- name: Install protobuf-compiler | |
run: sudo apt install protobuf-compiler | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-libp2p_dcutr-1_62_0 | |
subject/target/semver-checks/local-libp2p_relay-0_14_0 | |
- name: Run semver-checks on libp2p-dcutr | |
run: | | |
cd semver | |
../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 | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/protocols/relay/Cargo.toml" --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-libp2p-gossipsub-request-response: | |
# Run cargo-semver-checks on two crates that used to trip an assert and cause a crash, | |
# due to re-exports that omit generic parameters because the underlying generic type supplies | |
# default values for those generics. | |
# https://github.com/libp2p/rust-libp2p/pull/3401#issuecomment-1409381365 | |
name: 'Semver: libp2p-gossipsub ~0.44.0 + libp2p-request-response ~0.24.0' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout rust-libp2p | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'libp2p/rust-libp2p' | |
ref: '8b8dc26e0601433f5675430b29b50687a37d4cd8' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
# rust-libp2p requires protobuf-compiler. | |
- name: Install protobuf-compiler | |
run: sudo apt install protobuf-compiler | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-libp2p_gossipsub-0_44_0 | |
subject/target/semver-checks/local-libp2p_request_response-0_23_0 | |
- name: Run semver-checks on libp2p-gossipsub | |
run: | | |
cd semver | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/protocols/gossipsub/Cargo.toml" --baseline-version 0.43.0 --verbose | |
- name: Run semver-checks on libp2p-request-response | |
run: | | |
cd semver | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/protocols/request-response/Cargo.toml" --baseline-version 0.23.0 --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-libp2p-uds: | |
# Run cargo-semver-checks on a crate that has dependencies in a custom target | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/369 | |
name: 'Semver: libp2p-uds 0.37.0' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout rust-libp2p | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'libp2p/rust-libp2p' | |
ref: '5b4eab7bafe6cba8fea6c806027ea680662b7cc6' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
# rust-libp2p requires protobuf-compiler. | |
- name: Install protobuf-compiler | |
run: sudo apt install protobuf-compiler | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-libp2p_uds-0_37_0 | |
- name: Run semver-checks on libp2p-uds | |
run: | | |
cd semver | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/transports/uds/Cargo.toml" --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-core-graphics: | |
# Run cargo-semver-checks on a crate with no semver violations, | |
# to make sure there are no false-positives. | |
# | |
# cargo-semver-checks previously reported a false-positive here, | |
# due to multiple methods by the same name being defined on the same type. | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/193 | |
name: 'Semver: core-graphics' | |
runs-on: macos-latest | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout rust-libp2p | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'servo/core-foundation-rs' | |
ref: '786895643140fa0ee4f913d7b4aeb0c4626b2085' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
# This job runs on macOS, not Linux like the rest. | |
# It should save its cache, because no other job will save it in its place. | |
- uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: 'semver' | |
workspaces: | | |
semver | |
subject/target/semver-checks/local-core_graphics-0_22_3 | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Run semver-checks | |
run: | | |
cd semver | |
cargo run semver-checks check-release --manifest-path="../subject/core-graphics/Cargo.toml" --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-bevy-core: | |
# cargo-semver-checks previously crashed here due to | |
# a bug in the generated Cargo.toml when generating a registry baseline: | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/261 | |
name: 'Semver: bevy_core v0.9.0' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout bevy | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'bevyengine/bevy' | |
ref: 'v0.9.0' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-bevy_core-0_9_0 | |
- name: Run semver-checks | |
run: | | |
cd semver | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/crates/bevy_core/Cargo.toml" --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-bevy-gltf: | |
# cargo-semver-checks reported false-positives since it did not include | |
# features defined implicitly via optional dependencies: | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/265 | |
name: 'Semver: bevy_gltf v0.9.1' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout bevy | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'bevyengine/bevy' | |
ref: 'v0.9.1' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-bevy_gltf-0_9_1 | |
- name: Run semver-checks | |
run: | | |
cd semver | |
../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@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-sqllogictest: | |
# cargo-semver-checks failed to run here due to workspace manifest-parsing issues: | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/370 | |
name: 'Semver: sqllogictest v0.13.0' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout sqllogictest | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'risinglightdb/sqllogictest-rs' | |
ref: 'v0.13.0' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-sqllogictest-0_13_0 | |
- name: Run via workspace Cargo.toml | |
run: | | |
cd semver | |
../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 | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path ../subject/sqllogictest/Cargo.toml --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-tokio-explicit: | |
# cargo-semver-checks crashed here due to improper CLI argument handling: | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/380 | |
name: 'Semver: tokio ~v1.25.0 (explicit)' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Disabled due to \#902 | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
cd semver | |
STATE="$(gh issue view 902 --json state --jq .state)" | |
if [[ "$STATE" == 'OPEN' ]]; then | |
echo 'Test disabled due to https://github.com/obi1kenobi/cargo-semver-checks/issues/902' | |
elif [[ "$STATE" == 'CLOSED' ]]; then | |
echo 'Please re-enable this test since the underlying issue has been closed' | |
exit 1 | |
else | |
echo 'Unknown state for issue #902:' | |
echo "$STATE" | |
exit 1 | |
fi | |
# - name: Checkout tokio | |
# uses: actions/checkout@v4 | |
# with: | |
# persist-credentials: false | |
# repository: 'tokio-rs/tokio' | |
# ref: 'd7b7c6131774ab631be6529fef3680abfeeb4781' | |
# path: 'subject' | |
# - name: Install rust | |
# id: toolchain | |
# uses: actions-rust-lang/setup-rust-toolchain@v1 | |
# with: | |
# cache: false | |
# rustflags: "" | |
# - name: Restore cargo index and rustdoc target dir | |
# uses: Swatinem/rust-cache@v2 | |
# with: | |
# workspaces: | | |
# subject/target/semver-checks/local-tokio-1_25_0 | |
# subject/target/semver-checks/local-tokio_macros-1_8_2 | |
# subject/target/semver-checks/local-tokio_stream-0_1_12 | |
# subject/target/semver-checks/local-tokio_test-0_4_2 | |
# subject/target/semver-checks/local-tokio_util-0_7_7 | |
# - name: Restore binary | |
# id: cache-binary | |
# uses: actions/cache/restore@v4 | |
# with: | |
# path: bins/ | |
# key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
# fail-on-cache-miss: true | |
# - name: Restore rustdoc | |
# id: cache | |
# uses: actions/cache/restore@v4 | |
# with: | |
# key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
# path: subject/target/semver-checks/cache | |
# # This test caught two bugs: | |
# # - The default baseline was set to the current path instead of the default registry version. | |
# # - Specifying `--exclude` together with a crate manifest that is within a workspace | |
# # (but doesn't *itself* define the workspace) would cause the entire workspace to | |
# # get tested, even though only a single crate's manifest was specified. | |
# - name: Run semver-checks on tokio-stream crate manifest only | |
# run: | | |
# cd semver | |
# ../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 | |
# ../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 | |
# - name: Save rustdoc | |
# uses: actions/cache/save@v4 | |
# if: steps.cache.outputs.cache-hit != 'true' | |
# with: | |
# key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
# path: subject/target/semver-checks/cache | |
run-on-tokio-implicit: | |
# cargo-semver-checks crashed here due to improper CLI argument handling: | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/380 | |
name: 'Semver: tokio ~v1.25.0 (implicit)' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Disabled due to \#902 | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
cd semver | |
STATE="$(gh issue view 902 --json state --jq .state)" | |
if [[ "$STATE" == 'OPEN' ]]; then | |
echo 'Test disabled due to https://github.com/obi1kenobi/cargo-semver-checks/issues/902' | |
elif [[ "$STATE" == 'CLOSED' ]]; then | |
echo 'Please re-enable this test since the underlying issue has been closed' | |
exit 1 | |
else | |
echo 'Unknown state for issue #902:' | |
echo "$STATE" | |
exit 1 | |
fi | |
# - name: Checkout tokio | |
# uses: actions/checkout@v4 | |
# with: | |
# persist-credentials: false | |
# repository: 'tokio-rs/tokio' | |
# ref: 'd7b7c6131774ab631be6529fef3680abfeeb4781' | |
# path: 'subject' | |
# - name: Install rust | |
# id: toolchain | |
# uses: actions-rust-lang/setup-rust-toolchain@v1 | |
# with: | |
# cache: false | |
# rustflags: "" | |
# - name: Restore cargo index and rustdoc target dir | |
# uses: Swatinem/rust-cache@v2 | |
# with: | |
# workspaces: | | |
# subject/target/semver-checks/local-tokio-1_25_0 | |
# subject/target/semver-checks/local-tokio_macros-1_8_2 | |
# subject/target/semver-checks/local-tokio_stream-0_1_12 | |
# subject/target/semver-checks/local-tokio_test-0_4_2 | |
# subject/target/semver-checks/local-tokio_util-0_7_7 | |
# - name: Restore binary | |
# id: cache-binary | |
# uses: actions/cache/restore@v4 | |
# with: | |
# path: bins/ | |
# key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
# fail-on-cache-miss: true | |
# - name: Restore rustdoc | |
# id: cache | |
# uses: actions/cache/restore@v4 | |
# with: | |
# key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
# path: subject/target/semver-checks/cache | |
# # 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 | |
# ../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/Cargo.toml" --release-type minor --verbose | |
# - name: Save rustdoc | |
# uses: actions/cache/save@v4 | |
# if: steps.cache.outputs.cache-hit != 'true' | |
# with: | |
# key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
# path: subject/target/semver-checks/cache | |
run-on-clap: | |
# clap v3.2.0 added a semver violation | |
# check whether cargo-semver-checks detects the issue | |
# https://github.com/clap-rs/clap/issues/3876 | |
name: 'Semver: clap v3.2.0' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout clap v3.2.0 | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'clap-rs/clap' | |
ref: 'v3.2.0' | |
path: 'subject-current' | |
- name: Checkout clap v3.1.18 | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'clap-rs/clap' | |
ref: 'v3.1.18' | |
path: 'subject-baseline' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject-current/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject-current/target/semver-checks/local-clap-3_2_0/ | |
subject-current/target/semver-checks/git-524e36cf1a67ee6a447d3615a70b065d2b4f5e60/local-clap-3_1_18/ | |
subject-baseline/target/semver-checks/local-clap-3_1_18/ | |
- name: Run semver-checks with --baseline-root | |
continue-on-error: true | |
run: | | |
cd semver | |
set -euo pipefail | |
../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 | |
run: | | |
cd semver | |
if [ -f unexpectedly_did_not_fail ]; then exit 1; else exit 0; fi | |
- name: Check output | |
run: | | |
cd semver | |
EXPECTED="$(echo -e "--- failure auto_trait_impl_removed: auto trait no longer implemented ---\n--- failure enum_no_repr_variant_discriminant_changed: enum variant had its discriminant change value ---")" | |
RESULT="$(cat output | grep failure | sort)" | |
diff <(echo "$RESULT") <(echo "$EXPECTED") | |
- name: Cleanup | |
run: | | |
cd semver | |
rm output | |
rm -f unexpectedly_did_not_fail | |
- name: Fetch v3.1.18 in subject-current | |
run: | | |
pushd subject-current | |
git fetch origin 524e36cf1a67ee6a447d3615a70b065d2b4f5e60 | |
popd | |
- name: Run semver-checks with --baseline-rev | |
continue-on-error: true | |
run: | | |
cd semver | |
set -euo pipefail | |
../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 | |
run: | | |
cd semver | |
if [ -f unexpectedly_did_not_fail ]; then exit 1; else exit 0; fi | |
- name: Check output | |
run: | | |
cd semver | |
EXPECTED="$(echo -e "--- failure auto_trait_impl_removed: auto trait no longer implemented ---\n--- failure enum_no_repr_variant_discriminant_changed: enum variant had its discriminant change value ---")" | |
RESULT="$(cat output | grep failure | sort)" | |
diff <(echo "$RESULT") <(echo "$EXPECTED") | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject-current/target/semver-checks/cache | |
run-on-ref-slice-fork: | |
# Simulate testing an as-yet-unreleased crate version without an explicit baseline, | |
# i.e. with the expectation that the largest crates.io version is used as a baseline. | |
# This broke when a PR accidentally changed the default baseline behavior. | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/382 | |
# | |
# To perform this test, we forked a stable crate and made a semver-major break | |
# with no version change (v1.2.1). In this test, we make sure that: | |
# - v1.2.1 is chosen as the baseline, as the largest crates.io version, | |
# - cargo-semver-checks detects the semver break we've manufactured. | |
name: 'Semver: ref-slice fork' | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
protocol: ["git", "sparse"] | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: true | |
path: 'semver' | |
- name: Checkout ref-slice fork semver break | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'mgr0dzicki/cargo-semver-action-ref-slice' | |
ref: '4d64380252c8fbda023cca58406fa40a27ad1177' # branch major_change | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
env: | |
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: ${{ matrix.protocol }} | |
with: | |
cache: false | |
rustflags: "" | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-ref_slice-1_2_1/ | |
- name: Run semver-checks | |
continue-on-error: true | |
env: | |
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: ${{ matrix.protocol }} | |
run: | | |
cd semver | |
set -euo pipefail | |
../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 | |
run: | | |
cd semver | |
if [ -f unexpectedly_did_not_fail ]; then exit 1; else exit 0; fi | |
- name: Baseline is correct | |
run: | | |
cd semver | |
EXPECTED="$(echo -e " Checking ref_slice v1.2.1 -> v1.2.1 (no change)")" | |
# Strip ANSI escapes for colors and bold text before comparing. | |
RESULT="$(cat output | grep ' -> v1.' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g")" | |
diff <(echo "$RESULT") <(echo "$EXPECTED") | |
- name: Semver break found | |
run: | | |
cd semver | |
EXPECTED="$(echo -e "--- failure function_missing: pub fn removed or renamed ---")" | |
RESULT="$(cat output | grep failure)" | |
diff <(echo "$RESULT") <(echo "$EXPECTED") | |
# Ensure the following fragment (not full line!) is in the output file: | |
grep ' function ref_slice::ref_slice, previously in file' output | |
- name: Cleanup | |
run: | | |
cd semver | |
rm output | |
rm -f unexpectedly_did_not_fail | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-ref-slice-fork-windows: | |
# Same as above, but run on a Windows machine. | |
# This broke in a workflow of the GitHub Action using a precompiled binary | |
# after a fresh Rust installation, when the registry index does not exist yet | |
# (see https://github.com/frewsxcv/rust-crates-index/issues/97). | |
name: 'Semver: ref-slice fork (Windows)' | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
protocol: ["git", "sparse"] | |
needs: | |
- build-binary-windows | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: true | |
path: semver | |
- name: Checkout ref-slice fork semver break | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'mgr0dzicki/cargo-semver-action-ref-slice' | |
ref: '4d64380252c8fbda023cca58406fa40a27ad1177' # branch major_change | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins\ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver\**\Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject\target\semver-checks\cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject\target\semver-checks\local-ref_slice-1_2_1\ | |
- name: Run cargo-semver-checks | |
continue-on-error: true | |
id: semver_checks | |
env: | |
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: ${{ matrix.protocol }} | |
run: | | |
cd semver | |
..\bins\cargo-semver-checks.exe semver-checks check-release --manifest-path="..\subject\Cargo.toml" 2>&1 | tee output | |
- name: Check whether it failed | |
if: steps.semver_checks.outcome != 'failure' | |
run: | | |
echo "Error! check-release should have failed because of the breaking change, but it has not." | |
exit 1 | |
- name: Baseline is correct | |
run: | | |
cd semver | |
$EXPECTED = " Checking ref_slice v1.2.1 -> v1.2.1 (no change)" | |
# Strip ANSI escapes for colors and bold text before comparing. | |
cat output | grep ' -> v1.' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | Out-File -FilePath check_line | |
cat check_line | |
grep "$EXPECTED" check_line | |
- name: Semver break found | |
run: | | |
cd semver | |
$EXPECTED = "--- failure function_missing: pub fn removed or renamed ---" | |
cat output | grep failure | Out-File -FilePath failure_line | |
cat failure_line | |
grep "$EXPECTED" failure_line | |
# Ensure the following fragment (not full line!) is in the output file: | |
grep ' function ref_slice::ref_slice, previously in file' output | |
- name: Cleanup | |
run: | | |
cd semver | |
rm output | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver\**\Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject\target\semver-checks\cache | |
run-on-libp2p-whose-dependency-has-warnings: | |
# cargo-semver-checks failed to generate rustdoc JSON for a commit near libp2p v0.53.1 because: | |
# - RUSTFLAGS was set to "-Dwarning" by default by a GitHub Action | |
# - libp2p has a dependency (libp2p-yamux) whose dependency (yamux) released a newer version, | |
# which deprecated an item that libp2p-yamux uses | |
# - cargo-semver-checks added "--cap-lints" to RUSTDOCFLAGS but not RUSTFLAGS | |
# - generating rustdoc JSON for libp2p involves a rustc check of its dependency, and that | |
# check obeys RUSTFLAGS, not RUSTDOCFLAGS | |
# | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/589 | |
name: 'Semver: dependency has warnings with "-Dwarnings" (libp2p v0.53.1)' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout libp2p | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'libp2p/rust-libp2p' | |
ref: '4759ba8244242628164b7ec9e7dc99d67269e39f' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "-Dwarnings" # set explicitly, to ensure we trigger the bug described above | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-libp2p-0_53_1 | |
- name: Run semver-checks | |
run: | | |
cd semver | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/Cargo.toml" -p libp2p --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
run-on-perf-event-open-sys2: | |
# cargo-semver-checks failed to find the generated rustdoc JSON | |
# because the crate used a lib name different from the crate name. | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/432 | |
name: 'Semver: perf-event-open-sys2 v5.0.0' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
- name: Checkout phantomical/perf-event | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: 'phantomical/perf-event' | |
ref: '47dc882dbfb44b86584540a6e4f2815caaf72c10' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
rustflags: "" | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-perf-event-open-sys2-5_0_0 | |
- name: Run semver-checks | |
run: | | |
cd semver | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/perf-event-open-sys/Cargo.toml" --baseline-version 5.0.0 --verbose | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
fails-on-too-old-rustc: | |
# cargo-semver-checks fails if the rustc version is not high enough | |
# because of rustdoc format incompatibilities. This test ensures that | |
# we have a good error message. | |
# https://github.com/obi1kenobi/cargo-semver-checks/issues/444 | |
name: 'Check failure when installed rustc is too old' | |
runs-on: ubuntu-latest | |
needs: | |
- build-binary | |
steps: | |
- name: Checkout cargo-semver-checks | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
path: 'semver' | |
# rust-fnv is very lightweight and quite stable. | |
- name: Checkout rust-fnv | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
repository: "servo/rust-fnv" | |
ref: '94334357754a82f3ffb705dc387bd5f4c921e954' | |
path: 'subject' | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
toolchain: "1.76" | |
rustflags: "" | |
cache: false | |
- name: Restore binary | |
id: cache-binary | |
uses: actions/cache/restore@v4 | |
with: | |
path: bins/ | |
key: bins-${{ runner.os }}-${{ github.run_id }}-${{ github.run_attempt }} | |
fail-on-cache-miss: true | |
- name: Restore rustdoc | |
id: cache | |
uses: actions/cache/restore@v4 | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
- name: Restore cargo index and rustdoc target dir | |
uses: Swatinem/rust-cache@v2 | |
with: | |
workspaces: | | |
subject/target/semver-checks/local-fnv-1_0_7/ | |
- name: Run semver-checks | |
continue-on-error: true | |
id: semver_checks | |
run: | | |
cd semver | |
set -euo pipefail | |
../bins/cargo-semver-checks semver-checks check-release --manifest-path="../subject/Cargo.toml" 2>&1 | tee output | |
touch unexpectedly_did_not_fail | |
- name: Check whether it failed | |
if: steps.semver_checks.outcome != 'failure' | |
run: | | |
echo "Error! check-release should have failed because the rustc version is too old, but it has not." | |
exit 1 | |
- name: Check output | |
run: | | |
cd semver | |
EXPECTED="$(echo -e "error: rustc version is not high enough: >=1.77.0 needed, got 1.76.0")" | |
RESULT="$(cat output | grep 'error: rustc version')" | |
diff <(echo "$RESULT") <(echo "$EXPECTED") | |
- name: Cleanup | |
run: | | |
cd semver | |
rm output | |
rm -f unexpectedly_did_not_fail | |
- name: Save rustdoc | |
uses: actions/cache/save@v4 | |
if: steps.cache.outputs.cache-hit != 'true' | |
with: | |
key: ${{ runner.os }}-${{ steps.toolchain.outputs.cachekey }}-${{ hashFiles('semver/**/Cargo.lock') }}-${{ github.job }}-rustdoc | |
path: subject/target/semver-checks/cache | |
init-release: | |
name: Run the release workflow | |
needs: | |
- should-publish | |
- ci-everything | |
- pre-publish-checks | |
if: needs.should-publish.outputs.is_new_version == 'yes' && github.ref == 'refs/heads/main' | |
uses: ./.github/workflows/release.yml | |
with: | |
publish-tag: ${{ needs.should-publish.outputs.publish-tag }} | |
secrets: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
TAGGER_GITHUB_TOKEN: ${{ secrets.TAGGER_GITHUB_TOKEN }} | |
should-publish: | |
name: Check if version changed | |
runs-on: ubuntu-latest | |
outputs: | |
is_new_version: ${{ steps.check.outputs.is_new_version }} | |
publish-tag: ${{ steps.tag.outputs.tag }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Install rust | |
id: toolchain | |
uses: actions-rust-lang/setup-rust-toolchain@v1 | |
with: | |
cache: false | |
- uses: Swatinem/rust-cache@v2 | |
- id: check | |
run: | | |
set +e | |
./scripts/is_version_already_uploaded.sh cargo-semver-checks | |
export EXIT_CODE="$?" | |
set -e | |
if [[ "$EXIT_CODE" == "7" ]]; then | |
echo 'is_new_version=no' >> $GITHUB_OUTPUT | |
elif [[ "$EXIT_CODE" == "0" ]]; then | |
echo 'is_new_version=yes' >> $GITHUB_OUTPUT | |
else | |
# Unexpected outcome, indicates a bug. | |
exit "$EXIT_CODE" | |
fi | |
- name: Determine the tag name | |
id: tag | |
run: | | |
export TAG_NAME="v$(./scripts/get_current_version.sh cargo-semver-checks)" | |
echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT | |
pre-publish-checks: | |
name: Check for semver compliance | |
runs-on: ubuntu-latest | |
needs: | |
- ci-everything | |
- should-publish | |
if: needs.should-publish.outputs.is_new_version == 'yes' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Check semver | |
uses: obi1kenobi/cargo-semver-checks-action@v2 | |
with: | |
# Ensure we include all new non-default features here explicitly, except for | |
# pass-through mutually-exclusive features from our dependencies such as: | |
# https://github.com/obi1kenobi/cargo-semver-checks/pull/824 | |
feature-group: default-features |