Skip to content

Commit 340c5e4

Browse files
authored
Adding cargo semver checks (#369)
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)
1 parent 1e19980 commit 340c5e4

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

.github/workflows/semver-checks.yml

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: semver-checks
2+
3+
on: [pull_request]
4+
5+
env:
6+
CARGO_TERM_COLOR: always
7+
RUST_BACKTRACE: 1
8+
9+
jobs:
10+
check_if_pr_breaks_semver:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
name: checkout full rep
17+
with:
18+
fetch-depth: 0
19+
- name: Install minimal stable
20+
uses: actions-rs/toolchain@v1
21+
with:
22+
profile: default
23+
toolchain: stable
24+
override: true
25+
- uses: Swatinem/rust-cache@v2
26+
- name: Install cargo-semver-checks
27+
shell: bash
28+
run: |
29+
cargo install cargo-semver-checks --locked
30+
- name: Run check
31+
shell: bash
32+
run: |
33+
cargo semver-checks --all-features --baseline-rev ${{ github.event.pull_request.base.sha }}
34+
- name: On Failure
35+
if: failure()
36+
uses: actions-ecosystem/action-add-labels@v1
37+
with:
38+
labels: breaking-change
39+
- name: On Success
40+
if: success()
41+
shell: bash
42+
run: |
43+
echo "Checks succeed"

0 commit comments

Comments
 (0)