Skip to content

Commit f0253e5

Browse files
author
Kartik Raj
authored
Use actions from vscode-github-triage-actions in all Python automations (#21178)
1 parent 678f70d commit f0253e5

7 files changed

+86
-166
lines changed

.github/workflows/community-feedback-auto-comment.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,17 @@ jobs:
1313
issues: write
1414

1515
steps:
16-
- name: Check For Existing Comment
17-
uses: peter-evans/find-comment@v2
18-
id: finder
16+
- name: Checkout Actions
17+
uses: actions/checkout@v3
1918
with:
20-
issue-number: ${{ github.event.issue.number }}
21-
comment-author: 'github-actions[bot]'
22-
body-includes: Thanks for the feature request! We are going to give the community
19+
repository: 'microsoft/vscode-github-triage-actions'
20+
ref: stable
21+
path: ./actions
22+
23+
- name: Install Actions
24+
run: npm install --production --prefix ./actions
2325

24-
- name: Add Community Feedback Comment
25-
if: steps.finder.outputs.comment-id == ''
26-
uses: peter-evans/create-or-update-comment@v3
26+
- name: Add Community Feedback Comment if applicable
27+
uses: ./actions/python-community-feedback-auto-comment
2728
with:
2829
issue-number: ${{ github.event.issue.number }}
29-
body: |
30-
Thanks for the feature request! We are going to give the community 60 days from when this issue was created to provide 7 👍 upvotes on the opening comment to gauge general interest in this idea. If there's enough upvotes then we will consider this feature request in our future planning. If there's unfortunately not enough upvotes then we will close this issue.

.github/workflows/issue-labels.yml

Lines changed: 13 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -18,55 +18,19 @@ jobs:
1818
name: "Add 'triage-needed' and remove unrecognizable labels & assignees"
1919
runs-on: ubuntu-latest
2020
steps:
21-
- uses: actions/github-script@v6
21+
- name: Checkout Actions
22+
uses: actions/checkout@v3
2223
with:
23-
github-token: ${{ secrets.GITHUB_TOKEN }}
24-
script: |
25-
const result = await github.rest.issues.listLabelsOnIssue({
26-
owner: context.repo.owner,
27-
repo: context.repo.repo,
28-
issue_number: context.issue.number,
29-
})
30-
const labels = result.data.map((label) => label.name)
31-
const hasNeedsOrTPI = labels.some((label) => (label.startsWith('needs') || label === 'testplan-item' || label.startsWith('iteration-plan') || label === 'release-plan'))
24+
repository: 'microsoft/vscode-github-triage-actions'
25+
ref: stable
26+
path: ./actions
3227

33-
if (!hasNeedsOrTPI) {
34-
console.log('This issue is not labeled with a "needs __", "iteration-plan", "release-plan", or the "testplan-item" label; add the "triage-needed" label.')
28+
- name: Install Actions
29+
run: npm install --production --prefix ./actions
3530

36-
github.rest.issues.addLabels({
37-
owner: context.repo.owner,
38-
repo: context.repo.repo,
39-
issue_number: context.issue.number,
40-
labels: ['triage-needed']
41-
})
42-
} else {
43-
console.log('This issue already has a "needs __", "iteration-plan", "release-plan", or the "testplan-item" label, do not add the "triage-needed" label.')
44-
}
45-
const knownTriagers = ${{ env.TRIAGERS }}
46-
const currentAssignees = await github.rest.issues
47-
.get({
48-
owner: context.repo.owner,
49-
repo: context.repo.repo,
50-
issue_number: context.issue.number,
51-
})
52-
.then((result) => result.data.assignees.map((a) => a.login));
53-
console.log('Known triagers:', JSON.stringify(knownTriagers));
54-
console.log('Current assignees:', JSON.stringify(currentAssignees));
55-
const assigneesToRemove = currentAssignees.filter(a => !knownTriagers.includes(a));
56-
console.log('Assignees to remove:', JSON.stringify(assigneesToRemove));
57-
github.rest.issues.removeAssignees({
58-
owner: context.repo.owner,
59-
repo: context.repo.repo,
60-
issue_number: context.issue.number,
61-
assignees: assigneesToRemove,
62-
});
63-
const knownLabels = ${{ env.REPO_LABELS }}
64-
for( const label of labels) {
65-
if (!knownLabels.includes(label)) {
66-
await github.rest.issues.deleteLabel({
67-
owner: context.repo.owner,
68-
repo: context.repo.repo,
69-
name: label,
70-
})
71-
}
72-
}
31+
- name: "Add 'triage-needed' and remove unrecognizable labels & assignees"
32+
uses: ./actions/python-issue-labels
33+
with:
34+
triagers: ${{ env.TRIAGERS }}
35+
token: ${{secrets.GITHUB_TOKEN}}
36+
repo_labels: ${{ env.REPO_LABELS }}

.github/workflows/lock-issues.yml

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@ jobs:
1515
lock-issues:
1616
runs-on: ubuntu-latest
1717
steps:
18-
- uses: dessant/lock-threads@v4
18+
- name: Checkout Actions
19+
uses: actions/checkout@v3
1920
with:
20-
github-token: ${{ github.token }}
21-
issue-inactive-days: '30'
22-
process-only: 'issues'
23-
log-output: true
21+
repository: 'microsoft/vscode-github-triage-actions'
22+
ref: stable
23+
path: ./actions
24+
25+
- name: Install Actions
26+
run: npm install --production --prefix ./actions
27+
28+
- name: 'Lock Issues'
29+
uses: ./actions/python-lock-issues
30+
with:
31+
token: ${{ github.token }}

.github/workflows/pr-file-check.yml

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,15 @@ jobs:
1515
name: 'Check for changed files'
1616
runs-on: ubuntu-latest
1717
steps:
18-
- name: 'package-lock.json matches package.json'
19-
uses: brettcannon/[email protected]
18+
- name: Checkout Actions
19+
uses: actions/checkout@v3
2020
with:
21-
prereq-pattern: 'package.json'
22-
file-pattern: 'package-lock.json'
23-
skip-label: 'skip package*.json'
24-
failure-message: '${prereq-pattern} was edited but ${file-pattern} was not (the ${skip-label} label can be used to pass this check)'
21+
repository: 'microsoft/vscode-github-triage-actions'
22+
ref: stable
23+
path: ./actions
2524

26-
- name: 'package.json matches package-lock.json'
27-
uses: brettcannon/[email protected]
28-
with:
29-
prereq-pattern: 'package-lock.json'
30-
file-pattern: 'package.json'
31-
skip-label: 'skip package*.json'
32-
failure-message: '${prereq-pattern} was edited but ${file-pattern} was not (the ${skip-label} label can be used to pass this check)'
25+
- name: Install Actions
26+
run: npm install --production --prefix ./actions
3327

34-
- name: 'Tests'
35-
uses: brettcannon/[email protected]
36-
with:
37-
prereq-pattern: src/**/*.ts
38-
file-pattern: |
39-
src/**/*.test.ts
40-
src/**/*.testvirtualenvs.ts
41-
.github/test_plan.md
42-
skip-label: 'skip tests'
43-
failure-message: 'TypeScript code was edited without also editing a ${file-pattern} file; see the Testing page in our wiki on testing guidelines (the ${skip-label} label can be used to pass this check)'
28+
- name: Check for changed files
29+
uses: ./actions/python-pr-file-check

.github/workflows/pr-labels.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,15 @@ jobs:
1313
name: 'Classify PR'
1414
runs-on: ubuntu-latest
1515
steps:
16-
- name: 'PR impact specified'
17-
uses: mheap/github-action-required-labels@v4
16+
- name: Checkout Actions
17+
uses: actions/checkout@v3
1818
with:
19-
mode: exactly
20-
count: 1
21-
labels: 'bug, debt, feature-request, no-changelog'
19+
repository: 'microsoft/vscode-github-triage-actions'
20+
ref: stable
21+
path: ./actions
22+
23+
- name: Install Actions
24+
run: npm install --production --prefix ./actions
25+
26+
- name: Classify PR
27+
uses: ./actions/python-pr-labels

.github/workflows/test-plan-item-validator.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,10 @@ jobs:
1717
repository: 'microsoft/vscode-github-triage-actions'
1818
path: ./actions
1919
ref: stable
20+
2021
- name: Install Actions
2122
run: npm install --production --prefix ./actions
23+
2224
- name: Run Test Plan Item Validator
2325
uses: ./actions/test-plan-item-validator
2426
with:

.github/workflows/triage-info-needed.yml

Lines changed: 28 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -11,86 +11,41 @@ jobs:
1111
add_label:
1212
runs-on: ubuntu-latest
1313
if: contains(github.event.issue.labels.*.name, 'triage-needed') && !contains(github.event.issue.labels.*.name, 'info-needed')
14-
env:
15-
KEYWORDS: '["\\?", "please", "kindly", "let me know", "try", "can you", "could you", "would you", "may I", "provide", "let us know", "tell me", "give me", "send me", "what", "when", "where", "why", "how"]'
1614
steps:
17-
- name: Check for author
18-
uses: actions/github-script@v6
15+
- name: Checkout Actions
16+
uses: actions/checkout@v3
1917
with:
20-
github-token: ${{ secrets.GITHUB_TOKEN }}
21-
script: |
22-
const issue = await github.rest.issues.get({
23-
owner: context.repo.owner,
24-
repo: context.repo.repo,
25-
issue_number: context.issue.number
26-
});
27-
const commentAuthor = context.payload.comment.user.login;
28-
const commentBody = context.payload.comment.body;
29-
const isTeamMember = ${{ env.TRIAGERS }}.includes(commentAuthor);
18+
repository: 'microsoft/vscode-github-triage-actions'
19+
ref: stable
20+
path: ./actions
3021

31-
const keywords = ${{ env.KEYWORDS }};
32-
const isRequestForInfo = new RegExp(keywords.join('|'), 'i').test(commentBody);
22+
- name: Install Actions
23+
run: npm install --production --prefix ./actions
3324

34-
const shouldAddLabel = isTeamMember && commentAuthor !== issue.data.user.login && isRequestForInfo;
35-
36-
if (shouldAddLabel) {
37-
await github.rest.issues.addLabels({
38-
owner: context.repo.owner,
39-
repo: context.repo.repo,
40-
issue_number: context.issue.number,
41-
labels: ['info-needed']
42-
});
43-
}
25+
- name: Add "info-needed" label
26+
uses: ./actions/python-triage-info-needed
27+
with:
28+
triagers: ${{ env.TRIAGERS }}
29+
action: 'add'
30+
token: ${{secrets.GITHUB_TOKEN}}
4431

4532
remove_label:
4633
if: contains(github.event.issue.labels.*.name, 'info-needed') && contains(github.event.issue.labels.*.name, 'triage-needed')
4734
runs-on: ubuntu-latest
4835
steps:
49-
- name: Check for author
50-
uses: actions/github-script@v6
36+
- name: Checkout Actions
37+
uses: actions/checkout@v3
38+
with:
39+
repository: 'microsoft/vscode-github-triage-actions'
40+
ref: stable
41+
path: ./actions
42+
43+
- name: Install Actions
44+
run: npm install --production --prefix ./actions
45+
46+
- name: Remove "info-needed" label
47+
uses: ./actions/python-triage-info-needed
5148
with:
52-
github-token: ${{ secrets.GITHUB_TOKEN }}
53-
script: |
54-
const issue = await github.rest.issues.get({
55-
owner: context.repo.owner,
56-
repo: context.repo.repo,
57-
issue_number: context.issue.number
58-
});
59-
const commentAuthor = context.payload.comment.user.login;
60-
const issueAuthor = issue.data.user.login;
61-
if (commentAuthor === issueAuthor) {
62-
await github.rest.issues.removeLabel({
63-
owner: context.repo.owner,
64-
repo: context.repo.repo,
65-
issue_number: context.issue.number,
66-
name: 'info-needed'
67-
});
68-
return;
69-
}
70-
if (${{ env.TRIAGERS }}.includes(commentAuthor)) {
71-
// If one of triagers made a comment, ignore it
72-
return;
73-
}
74-
// Loop through all the comments on the issue in reverse order and find the last username that a TRIAGER mentioned
75-
// If the comment author is the last mentioned username, remove the "info-needed" label
76-
const comments = await github.rest.issues.listComments({
77-
owner: context.repo.owner,
78-
repo: context.repo.repo,
79-
issue_number: context.issue.number
80-
});
81-
for (const comment of comments.data.slice().reverse()) {
82-
if (!${{ env.TRIAGERS }}.includes(comment.user.login)) {
83-
continue;
84-
}
85-
const matches = comment.body.match(/@\w+/g) || [];
86-
const mentionedUsernames = matches.map(match => match.replace('@', ''));
87-
if (mentionedUsernames.includes(commentAuthor)) {
88-
await github.rest.issues.removeLabel({
89-
owner: context.repo.owner,
90-
repo: context.repo.repo,
91-
issue_number: context.issue.number,
92-
name: 'info-needed'
93-
});
94-
break;
95-
}
96-
}
49+
triagers: ${{ env.TRIAGERS }}
50+
action: 'remove'
51+
token: ${{secrets.GITHUB_TOKEN}}

0 commit comments

Comments
 (0)