-
Notifications
You must be signed in to change notification settings - Fork 910
Add CI for api surface area review verification #6099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
.github/workflows/api-surface-area-review-verification.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
name: API Surface Area Review Verification | ||
|
||
on: | ||
pull_request: | ||
types: [ opened, synchronize, reopened, labeled, unlabeled ] | ||
branches: | ||
- master | ||
|
||
jobs: | ||
api-surface-area-review-verification: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Verifies updates to protected/public APIs have been reviewed and approved by the team, if any | ||
id: api-surface-area-review-verification | ||
if: ${{ !contains(github.event.pull_request.labels.*.name, 'no-api-surface-area-change') }} | ||
run: | | ||
git fetch origin ${{ github.base_ref }} --depth 1 | ||
FILES=$( git diff remotes/origin/${{ github.base_ref }} --name-only | grep "\.java$" | grep -v -E "(^|/)(internal|test|codegen|v2-migration)/" || true) | ||
if [ -n "$FILES" ]; then | ||
echo "::error::Changes around protected/public APIs found:" | ||
echo "$FILES" | while read file; do | ||
echo "::error::$file" | ||
done | ||
echo "has_matches=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "No changes around protected/public APIs found." | ||
echo "has_matches=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Fail if there are changes around protected/public APIs and there's no label | ||
if: ${{ steps.api-surface-area-review-verification.outputs.has_matches == 'true' && !contains(github.event.pull_request.labels.*.name, 'api-surface-area-approved-by-team') }} | ||
run: | | ||
echo "::error ::Change around public/protected APIs has been detected. Please either:" | ||
echo "::error ::* Review it with the team and add the 'api-surface-area-reviewed' label to this PR after approval –or–" | ||
echo "::error ::* Add the 'no-api-surface-area-change' label to this PR in case this is a false positive" | ||
exit 1 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice CI action +1
I had below suggestions
github.rest.issues.addLabels
? This way we can mark it as 'api-surface-area-review-required'Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
internal|test|codegen|v2-migration
since this repo is already huge, so I'm not sure if the effort it worth it.api-surface-area-review-required
(it's not straightforward to tell it to not re-add the label for new revision if the label was removed previously) and having bothapi-surface-area-review-required
andno-api-surface-area-change
is a bit confusing