Repository navigation
94 lines (79 loc) · 3.06 KB
/
Copy pathsemver-checks.yml
File metadata and controls
94 lines (79 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
name: Rust semver-checks
on:
pull_request:
branches:
- master
workflow_dispatch:
inputs:
base:
description: 'Base branch or tag to run the semver checks against.'
required: true
default: 'master'
permissions:
pull-requests: read
jobs:
semver-checks:
name: semver-checks 🦀
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v7
with:
ref: ${{ github.event.pull_request.head.sha || github.ref }}
path: PR_BRANCH
fetch-depth: 0
# Remove repo toolchain pin so we can specify toolchain manually
- name: Remove toolchain pin
run: rm -f rust-toolchain.toml rustup-toolchain.toml
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
- name: Build caching
uses: Swatinem/rust-cache@v2
# Run cargo-semver-checks against the PR's target branch.
- name: Check semver changes
id: semver
uses: obi1kenobi/cargo-semver-checks-action@v2
with:
feature-group: all-features
manifest-path: PR_BRANCH/Cargo.toml
baseline-rev: ${{ github.event.pull_request.base.sha || github.event.inputs.base }}
release-type: minor
continue-on-error: true
- name: Evaluate semver result
run: |
echo "=== cargo-semver-checks result ==="
if [ "${{ steps.semver.outcome }}" = "failure" ]; then
BREAKING=true
echo "❌ Breaking changes detected in public Rust API"
else
BREAKING=false
echo "✅ No breaking changes detected"
fi
echo
echo "=== cargo-semver-checks summary ==="
echo
printf "%s\n" "${{ steps.semver.outputs.semver-checks-output }}"
echo
# Check PR title for conventional-commit breaking marker
if [[ "${{ github.event.pull_request.title }}" =~ ^.*\!:.*$ ]]; then
DECLARED=true
echo "ℹ️ PR title declares a breaking change (!)"
else
DECLARED=false
echo "ℹ️ PR title does NOT declare a breaking change"
fi
echo
echo "=== Decision ==="
if [ "$BREAKING" = true ] && [ "$DECLARED" = false ]; then
echo "🚨 ERROR: Undeclared breaking changes detected."
echo "Hey there and thank you for opening this pull request! 👋 Please deprecate the old API instead (if possible), or mark the PR with a `!` following the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) format to indicate a breaking change."
exit 1
fi
if [ "$BREAKING" = true ] && [ "$DECLARED" = true ]; then
echo "⚠️ Breaking changes detected but correctly declared."
echo "Workflow will succeed."
fi
if [ "$BREAKING" = false ]; then
echo "✅ No breaking changes; workflow will succeed."
fi