ci: replace home-grow cargo semver-checks action

This PR replaces our home-grown `cargo semver-checks` action with the official one: https://github.com/obi1kenobi/cargo-semver-checks-action/issues/47.

This action has support for cargo workspaces and will automatically check all crates that have `publish` set to `true`. This removes a big time component for our CI checks and introduces one that runs in parallel with all others. I hope to reduce the effective CI time through that, plus it means we need to maintain less code.

The official action would download the latest release of cargo-semver-checks. This might result in a non-reproducible CI. To avoid this, we retain the one-line download statement from our home-grown action.

Pull-Request: #3923.
This commit is contained in:
Thomas Eizinger 2023-09-04 10:39:09 +10:00 committed by GitHub
parent 955da49f26
commit 51425d524b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 50 deletions

View File

@ -1,36 +0,0 @@
name: "Run cargo semver-checks"
description: "Install and run the cargo semver-checks tool"
inputs:
crate:
required: true
description: "The crate to run `cargo semver-checks` on."
runs:
using: "composite"
steps:
- run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.22.1/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
shell: bash
- name: Get released version
shell: bash
id: get-released-version
run: |
MAX_STABLE_VERSION=$(curl https://crates.io/api/v1/crates/${{ inputs.crate }} --silent | jq '.crate.max_stable_version')
echo "version=${MAX_STABLE_VERSION}" >> $GITHUB_OUTPUT
- shell: bash
run: |
rustc --version | tee .rustc-version
cargo semver-checks --version | tee .semver-checks-version
- uses: actions/cache@v3
with:
path: ${{ github.workspace }}/target/semver-checks/cache
key: semver-checks-cache-${{ hashFiles('.rustc-version') }}-${{ hashFiles('.semver-checks-version') }}-${{ inputs.crate }}-${{ steps.get-released-version.outputs.version }}
- run: cargo semver-checks check-release --package ${{ inputs.crate }} --verbose
shell: bash
env:
CARGO_TERM_VERBOSE: "true"
# debugging https://github.com/libp2p/rust-libp2p/pull/3782#issuecomment-1523346255
CARGO_HTTP_DEBUG: "true"
CARGO_LOG: "cargo::ops::registry=debug"

View File

@ -49,20 +49,6 @@ jobs:
- name: Check if we compile without any features activated
run: cargo build --package "$CRATE" --no-default-features
- run: cargo clean
- name: Check if crate has been released
id: check-released
run: |
RESPONSE_CODE=$(curl https://crates.io/api/v1/crates/"$CRATE" --silent --write-out "%{http_code}" --output /dev/null)
echo "code=${RESPONSE_CODE}"
echo "code=${RESPONSE_CODE}" >> $GITHUB_OUTPUT
- uses: ./.github/actions/cargo-semver-checks
if: steps.check-released.outputs.code == 200 && !contains(fromJSON('["libp2p-swarm-derive", "libp2p-server"]'), env.CRATE) # Workaround until https://github.com/obi1kenobi/cargo-semver-check/issues/146 is shipped.
with:
crate: ${{ env.CRATE }}
- name: Enforce no dependency on meta crate
if: env.CRATE != 'libp2p-server'
run: |
@ -273,6 +259,14 @@ jobs:
cargo check --manifest-path "$toml";
done
semver:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: wget -q -O- https://github.com/obi1kenobi/cargo-semver-checks/releases/download/v0.22.1/cargo-semver-checks-x86_64-unknown-linux-gnu.tar.gz | tar -xz -C ~/.cargo/bin
shell: bash
- uses: obi1kenobi/cargo-semver-checks-action@v2
rustfmt:
runs-on: ubuntu-latest
steps: