Skip to content

Commit 6af137a

Browse files
committed
Add api-compat-verification workflow
1 parent 7160baf commit 6af137a

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: API compatibility verification
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize, reopened, labeled, unlabeled ]
6+
branches:
7+
- main
8+
- '*-main'
9+
10+
jobs:
11+
api-compat-verification:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v2
15+
- name: Check for API compatibility
16+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'acknowledge-api-break') }}
17+
run: |
18+
git fetch origin ${{ github.base_ref }} --depth 1 && \
19+
git diff remotes/origin/${{ github.base_ref }} --numstat "*.api" | awk '
20+
BEGIN { s = 0 }
21+
22+
# git diff numstat shows lines deleted in field 2, hence sum up field 2 across all items
23+
{ s += $2 }
24+
25+
# exit with the number of lines deleted as the result code so that `if failure()` works below
26+
END { exit s }
27+
'
28+
- name: Error message
29+
if: ${{ failure() }}
30+
run: |
31+
echo "::error ::This change modifies the public API in a way that may be backwards-incompatible. Carefully review this pull request and either:"
32+
echo "::error ::* Revert the changes which caused the API incompatibility –or–"
33+
echo "::error ::* Add the 'acknowledge-api-break' label to this PR (in rare cases warranting an API breakage)"
34+
exit 1

0 commit comments

Comments
 (0)