Skip to content

Commit 890899f

Browse files
authored
Add CI for api surface area review verification (#6099)
1 parent 15c635d commit 890899f

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: API Surface Area Review Verification
2+
3+
on:
4+
pull_request:
5+
types: [ opened, synchronize, reopened, labeled, unlabeled ]
6+
branches:
7+
- master
8+
9+
jobs:
10+
api-surface-area-review-verification:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Verifies updates to protected/public APIs have been reviewed and approved by the team, if any
15+
id: api-surface-area-review-verification
16+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-api-surface-area-change') }}
17+
run: |
18+
git fetch origin ${{ github.base_ref }} --depth 1
19+
FILES=$( git diff remotes/origin/${{ github.base_ref }} --name-only | grep "\.java$" | grep -v -E "(^|/)(internal|test|codegen|v2-migration)/" || true)
20+
if [ -n "$FILES" ]; then
21+
echo "::error::Changes around protected/public APIs found:"
22+
echo "$FILES" | while read file; do
23+
echo "::error::$file"
24+
done
25+
echo "has_matches=true" >> $GITHUB_OUTPUT
26+
else
27+
echo "No changes around protected/public APIs found."
28+
echo "has_matches=false" >> $GITHUB_OUTPUT
29+
fi
30+
- name: Fail if there are changes around protected/public APIs and there's no label
31+
if: ${{ steps.api-surface-area-review-verification.outputs.has_matches == 'true' && !contains(github.event.pull_request.labels.*.name, 'api-surface-area-approved-by-team') }}
32+
run: |
33+
echo "::error ::Change around public/protected APIs has been detected. Please either:"
34+
echo "::error ::* Review it with the team and add the 'api-surface-area-reviewed' label to this PR after approval –or–"
35+
echo "::error ::* Add the 'no-api-surface-area-change' label to this PR in case this is a false positive"
36+
exit 1

0 commit comments

Comments
 (0)