Skip to content

Commit

Permalink
Adding cargo semver checks (#369)
Browse files Browse the repository at this point in the history
Adding a check that will run `cargo semver-checks` against each PR. 

This implements a check for PRs that don't bump the crate version. The
check will be run between the `HEAD` of the PR and `main`. So any
changes introduced in the PR vs main that break semver are picked up,
and the PR will be labeled with `breaking-change`.

Currently can't test the actual adding of a label because (probably) the
check needs to be in the main repo, rather than in a PR branch, to be
allowed to get write access to the repo.

So sadly to actually test this we'll need to merge and see if it works.
(hooray github actions dev workflow)
  • Loading branch information
nicklan authored Oct 9, 2024
1 parent 1e19980 commit 340c5e4
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/semver-checks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: semver-checks

on: [pull_request]

env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1

jobs:
check_if_pr_breaks_semver:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
name: checkout full rep
with:
fetch-depth: 0
- name: Install minimal stable
uses: actions-rs/toolchain@v1
with:
profile: default
toolchain: stable
override: true
- uses: Swatinem/rust-cache@v2
- name: Install cargo-semver-checks
shell: bash
run: |
cargo install cargo-semver-checks --locked
- name: Run check
shell: bash
run: |
cargo semver-checks --all-features --baseline-rev ${{ github.event.pull_request.base.sha }}
- name: On Failure
if: failure()
uses: actions-ecosystem/action-add-labels@v1
with:
labels: breaking-change
- name: On Success
if: success()
shell: bash
run: |
echo "Checks succeed"

0 comments on commit 340c5e4

Please sign in to comment.