-
Notifications
You must be signed in to change notification settings - Fork 3k
ci: auto-skip internal CI changes in release notes #7251
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2f20855
ci: auto-skip internal CI changes in release notes
yiliang114 88737b6
ci: harden release note classifier
yiliang114 766223f
fix(ci): close release note classifier review gaps
yiliang114 5c12d08
fix(ci): close release classifier review gaps
yiliang114 9f95bf3
fix(ci): avoid release classifier label loop
yiliang114 a239d38
Merge branch 'main' into codex/auto-skip-ci-release-notes
yiliang114 fbcfe8e
Merge branch 'main' into codex/auto-skip-ci-release-notes
yiliang114 5385613
test(ci): cover release classifier test path variants
yiliang114 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
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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| # Configuration for GitHub's automatic release notes generation | ||
| # PRs with 'skip-changelog' label will be excluded from release notes | ||
| # Manual and automatically classified internal PRs are excluded. | ||
| changelog: | ||
| exclude: | ||
| labels: | ||
| - 'skip-changelog' | ||
| - 'skip-changelog-auto' |
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,102 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import { execFileSync } from 'node:child_process'; | ||
| import path from 'node:path'; | ||
| import { fileURLToPath } from 'node:url'; | ||
|
|
||
| const INTERNAL_LABELS = new Set([ | ||
| 'category/development', | ||
| 'scope/build-system', | ||
| 'scope/ci-cd', | ||
| 'scope/github-actions', | ||
| 'scope/testing', | ||
| ]); | ||
| const AUTO_LABEL = 'skip-changelog-auto'; | ||
| const RELEASE_AUTOMATION_RE = | ||
| /^\.github\/.*(?:changelog|release|publish|deploy|sync|prebuild|package|installer|artifact|image|cd-)/i; | ||
| const TEST_FILE_RE = | ||
| /(?:^|\/)(?:__tests__\/|[^/]+\.(?:test|spec)\.[^/]+$|(?:vitest|playwright)(?:\.[^/]+)?\.config\.[^/]+$)/; | ||
|
|
||
| export function shouldAutoSkipChangelog({ title, labels = [], files = [] }) { | ||
| const names = labels | ||
| .map((label) => | ||
| (typeof label === 'string' ? label : label.name).toLowerCase(), | ||
| ) | ||
| .filter((name) => name !== AUTO_LABEL); | ||
| if (names.includes('skip-changelog')) return false; | ||
|
|
||
| const subject = /^(\w+)(?:\([^)]*\))?(!)?:/.exec(title.trim()); | ||
| const type = subject?.[1].toLowerCase(); | ||
| if ( | ||
| subject?.[2] || | ||
| (type | ||
| ? type !== 'ci' | ||
| : !names.some((label) => | ||
| ['scope/ci-cd', 'scope/github-actions'].includes(label), | ||
| )) || | ||
| names.includes('bug') || | ||
| names.includes('breaking-change') || | ||
| names.some( | ||
| (label) => | ||
| /^(?:type|category|scope)\//.test(label) && !INTERNAL_LABELS.has(label), | ||
| ) | ||
|
yiliang114 marked this conversation as resolved.
|
||
| ) { | ||
| return false; | ||
| } | ||
|
|
||
| return ( | ||
| files.length > 0 && | ||
| files.every( | ||
|
yiliang114 marked this conversation as resolved.
|
||
| (file) => | ||
| TEST_FILE_RE.test(file) || | ||
| (!RELEASE_AUTOMATION_RE.test(file) && | ||
| (file.startsWith('.github/') || file.startsWith('.qwen/'))), | ||
| ) | ||
| ); | ||
| } | ||
|
|
||
| function main() { | ||
| const repo = process.env.GITHUB_REPOSITORY || ''; | ||
| const number = process.env.PR_NUMBER || ''; | ||
| if ( | ||
| !/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo) || | ||
| !/^[1-9]\d*$/.test(number) | ||
| ) { | ||
|
yiliang114 marked this conversation as resolved.
|
||
| throw new Error( | ||
| 'GITHUB_REPOSITORY and PR_NUMBER must identify a pull request.', | ||
| ); | ||
| } | ||
|
|
||
| const metadata = JSON.parse( | ||
| execFileSync( | ||
| 'gh', | ||
| ['pr', 'view', number, '--repo', repo, '--json', 'title,labels'], | ||
| { | ||
| encoding: 'utf8', | ||
| }, | ||
| ), | ||
| ); | ||
| const files = execFileSync( | ||
| 'gh', | ||
| [ | ||
| 'api', | ||
| '--paginate', | ||
| `repos/${repo}/pulls/${number}/files`, | ||
| '--jq', | ||
| '.[] | .filename, (.previous_filename // empty)', | ||
| ], | ||
| { encoding: 'utf8', maxBuffer: 16 * 1024 * 1024 }, | ||
| ) | ||
| .split(/\r?\n/) | ||
| .filter(Boolean); | ||
| process.stdout.write( | ||
| `${shouldAutoSkipChangelog({ ...metadata, files }) ? 'skip' : 'include'}\n`, | ||
| ); | ||
|
yiliang114 marked this conversation as resolved.
|
||
| } | ||
|
|
||
| if ( | ||
| process.argv[1] && | ||
| path.resolve(process.argv[1]) === fileURLToPath(import.meta.url) | ||
| ) { | ||
| main(); | ||
| } | ||
Oops, something went wrong.
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.