Skip to content

Commit ce340ea

Browse files
committed
Add CI for api surface area review verification
1 parent 9f2a559 commit ce340ea

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+
if: ${{ !contains(github.event.pull_request.labels.*.name, 'api-surface-area-approved-by-team') }}
16+
run: |
17+
git fetch origin ${{ github.base_ref }} --depth 1
18+
# Get the list of Java files changed, excluding test, codegen, and internal
19+
FILES=$(git diff remotes/origin/${{ github.base_ref }} --name-only | grep "\.java$" | grep -v -E "(^|/)(internal|test|codegen|v2-migration)/")
20+
echo "$FILES"
21+
# If there are any matching files, output them and set a flag
22+
if [ -n "$FILES" ]; then
23+
echo "::error::Changes around protected/public APIs found:"
24+
# echo "$FILES" | while read file; do
25+
# echo "::error::$file"
26+
# done
27+
echo "has_matches=true" >> $GITHUB_OUTPUT
28+
else
29+
echo "No changes around protected/public APIs found."
30+
echo "has_matches=false" >> $GITHUB_OUTPUT
31+
fi
32+
- name: Error message
33+
if: steps.api-surface-area-review-verification.outputs.has_matches == 'true'
34+
run: |
35+
echo "::error ::Change around public/protected APIs has been detected, please review it with the team and add the 'api-surface-area-reviewed' label to this PR afterwards"
36+
exit 1

0 commit comments

Comments
 (0)