-
Notifications
You must be signed in to change notification settings - Fork 278
Add automation to flag PRs on areas without an active SIG/project #2835
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
joaopgrassi
merged 14 commits into
open-telemetry:main
from
dynatrace-oss-contrib:feat/triage-automation
Oct 21, 2025
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
d4c897b
Add custom script
joaopgrassi c0c9f54
simulate changes to areas without an active SIG
joaopgrassi 31d83a4
try expand token permissions to also write issues
joaopgrassi 1168244
Move to its own action
joaopgrassi 232c33d
Convert to TS
joaopgrassi c428fb7
Allow skipping check based on labels
joaopgrassi e9f89d6
Merge branch 'main' into feat/triage-automation
joaopgrassi f46e1ac
Adapt triage document to reflect new automation
joaopgrassi 4f97471
revert simulated change
joaopgrassi 6e03e8f
revert simulated change
joaopgrassi 1c19595
Revert permissions on checks workflow
joaopgrassi 26992c4
Fix typo in .github/scripts/triage/check-changes-ownership.ts comment…
arminru afcf22b
Fix if condition
joaopgrassi f28d66d
PR suggestions
joaopgrassi 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 |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| import * as utils from './utils.ts'; | ||
| import { Octokit } from "@octokit/action"; | ||
|
|
||
| const octokit = new Octokit(); | ||
|
|
||
| const [owner, repo] = process.env.GITHUB_REPOSITORY!.split("/"); | ||
| const prNumber: number = +process.env.PR_NUMBER!; | ||
| const changes: string[] = process.env.CHANGED_FILES!.split(','); | ||
|
|
||
| /** | ||
| * Checks if the PR already has the 'triage:accepted:ready' label, meaning the triage checks should be skipped. | ||
| * @returns true if the PR has the 'triage:accepted:ready' assigned to it, false otherwise. | ||
| */ | ||
| async function shouldSkipCheck() { | ||
| const result = await octokit.request("GET /repos/{owner}/{repo}/issues/{issue_number}/labels", { | ||
| owner: owner, | ||
| repo: repo, | ||
| issue_number: prNumber | ||
| }); | ||
|
|
||
| return result.data.some(l => l.name === "triage:accepted:ready"); | ||
| } | ||
|
|
||
| function getCommentText(changesWithoutOwners: string[]): string { | ||
| return ` | ||
| This PR contains changes to area(s) that do not have an active SIG/project and will be auto-closed: | ||
|
|
||
| - ${changesWithoutOwners.join('\n- ')} | ||
|
|
||
| Such changes may be rejected or put on hold until a new SIG/project is established. | ||
|
|
||
| Please refer to the [Semantic Convention Areas](https://github.com/open-telemetry/semantic-conventions/blob/main/AREAS.md) | ||
| document to see the current active SIGs and also to learn how to kick start a new one.`; | ||
| } | ||
|
|
||
| async function changesInInactiveAreas(): Promise<boolean> { | ||
| // skips enforcing the triage process if the PR has the 'triage:accepted:ready' label on it | ||
| // this means maintainers/approvers decided to bypass it for good reasons. | ||
| if (await shouldSkipCheck()) { | ||
| return false; | ||
| } | ||
|
|
||
| const areas = utils.getAllAreasMetadata(); | ||
| const areaOwnersMap = utils.getActiveAreasWithCodeOwners(areas); | ||
|
|
||
| // extract only the name after model/ which is the actual area name | ||
| const changedAreas = changes.map(folder => folder.split('/')[1]); | ||
|
|
||
| let changesWithoutOwners: string[] = []; | ||
| changedAreas.forEach(ca => { | ||
| if (!areaOwnersMap.has(ca)) { | ||
| changesWithoutOwners.push(ca); | ||
| } | ||
| }); | ||
|
|
||
| if (changesWithoutOwners.length > 0) { | ||
| await octokit.request("POST /repos/{owner}/{repo}/issues/{issue_number}/labels", { | ||
| owner: owner, | ||
| repo: repo, | ||
| issue_number: prNumber, | ||
| labels: ['triage:rejected:declined'] | ||
| }); | ||
| await octokit.request("POST /repos/{owner}/{repo}/issues/{issue_number}/comments", { | ||
| owner: owner, | ||
| repo: repo, | ||
| issue_number: prNumber, | ||
| body: getCommentText(changesWithoutOwners) | ||
| }); | ||
| await octokit.request("PATCH /repos/{owner}/{repo}/issues/{issue_number}", { | ||
| owner: owner, | ||
| repo: repo, | ||
| issue_number: prNumber, | ||
| state: 'closed', | ||
| state_reason: 'not_planned' | ||
| }); | ||
|
|
||
| return true | ||
| } | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| (async () => { | ||
| const result = await changesInInactiveAreas(); | ||
| if (result) { | ||
| process.exit(1); | ||
| } | ||
| })(); | ||
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.