Skip to content

Commit

Permalink
Use actions from vscode-github-triage-actions in all Python automat…
Browse files Browse the repository at this point in the history
…ions (#21178)
  • Loading branch information
Kartik Raj authored May 5, 2023
1 parent 678f70d commit f0253e5
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 166 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/community-feedback-auto-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,17 @@ jobs:
issues: write

steps:
- name: Check For Existing Comment
uses: peter-evans/find-comment@v2
id: finder
- name: Checkout Actions
uses: actions/checkout@v3
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
body-includes: Thanks for the feature request! We are going to give the community
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions

- name: Install Actions
run: npm install --production --prefix ./actions

- name: Add Community Feedback Comment
if: steps.finder.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v3
- name: Add Community Feedback Comment if applicable
uses: ./actions/python-community-feedback-auto-comment
with:
issue-number: ${{ github.event.issue.number }}
body: |
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.
62 changes: 13 additions & 49 deletions .github/workflows/issue-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,19 @@ jobs:
name: "Add 'triage-needed' and remove unrecognizable labels & assignees"
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
- name: Checkout Actions
uses: actions/checkout@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const result = await github.rest.issues.listLabelsOnIssue({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
const labels = result.data.map((label) => label.name)
const hasNeedsOrTPI = labels.some((label) => (label.startsWith('needs') || label === 'testplan-item' || label.startsWith('iteration-plan') || label === 'release-plan'))
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions

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

github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['triage-needed']
})
} else {
console.log('This issue already has a "needs __", "iteration-plan", "release-plan", or the "testplan-item" label, do not add the "triage-needed" label.')
}
const knownTriagers = ${{ env.TRIAGERS }}
const currentAssignees = await github.rest.issues
.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
})
.then((result) => result.data.assignees.map((a) => a.login));
console.log('Known triagers:', JSON.stringify(knownTriagers));
console.log('Current assignees:', JSON.stringify(currentAssignees));
const assigneesToRemove = currentAssignees.filter(a => !knownTriagers.includes(a));
console.log('Assignees to remove:', JSON.stringify(assigneesToRemove));
github.rest.issues.removeAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
assignees: assigneesToRemove,
});
const knownLabels = ${{ env.REPO_LABELS }}
for( const label of labels) {
if (!knownLabels.includes(label)) {
await github.rest.issues.deleteLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: label,
})
}
}
- name: "Add 'triage-needed' and remove unrecognizable labels & assignees"
uses: ./actions/python-issue-labels
with:
triagers: ${{ env.TRIAGERS }}
token: ${{secrets.GITHUB_TOKEN}}
repo_labels: ${{ env.REPO_LABELS }}
18 changes: 13 additions & 5 deletions .github/workflows/lock-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ jobs:
lock-issues:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
- name: Checkout Actions
uses: actions/checkout@v3
with:
github-token: ${{ github.token }}
issue-inactive-days: '30'
process-only: 'issues'
log-output: true
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions

- name: Install Actions
run: npm install --production --prefix ./actions

- name: 'Lock Issues'
uses: ./actions/python-lock-issues
with:
token: ${{ github.token }}
32 changes: 9 additions & 23 deletions .github/workflows/pr-file-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,15 @@ jobs:
name: 'Check for changed files'
runs-on: ubuntu-latest
steps:
- name: 'package-lock.json matches package.json'
uses: brettcannon/[email protected]
- name: Checkout Actions
uses: actions/checkout@v3
with:
prereq-pattern: 'package.json'
file-pattern: 'package-lock.json'
skip-label: 'skip package*.json'
failure-message: '${prereq-pattern} was edited but ${file-pattern} was not (the ${skip-label} label can be used to pass this check)'
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions

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

- name: 'Tests'
uses: brettcannon/[email protected]
with:
prereq-pattern: src/**/*.ts
file-pattern: |
src/**/*.test.ts
src/**/*.testvirtualenvs.ts
.github/test_plan.md
skip-label: 'skip tests'
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)'
- name: Check for changed files
uses: ./actions/python-pr-file-check
16 changes: 11 additions & 5 deletions .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ jobs:
name: 'Classify PR'
runs-on: ubuntu-latest
steps:
- name: 'PR impact specified'
uses: mheap/github-action-required-labels@v4
- name: Checkout Actions
uses: actions/checkout@v3
with:
mode: exactly
count: 1
labels: 'bug, debt, feature-request, no-changelog'
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions

- name: Install Actions
run: npm install --production --prefix ./actions

- name: Classify PR
uses: ./actions/python-pr-labels
2 changes: 2 additions & 0 deletions .github/workflows/test-plan-item-validator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ jobs:
repository: 'microsoft/vscode-github-triage-actions'
path: ./actions
ref: stable

- name: Install Actions
run: npm install --production --prefix ./actions

- name: Run Test Plan Item Validator
uses: ./actions/test-plan-item-validator
with:
Expand Down
101 changes: 28 additions & 73 deletions .github/workflows/triage-info-needed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,86 +11,41 @@ jobs:
add_label:
runs-on: ubuntu-latest
if: contains(github.event.issue.labels.*.name, 'triage-needed') && !contains(github.event.issue.labels.*.name, 'info-needed')
env:
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"]'
steps:
- name: Check for author
uses: actions/github-script@v6
- name: Checkout Actions
uses: actions/checkout@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const commentAuthor = context.payload.comment.user.login;
const commentBody = context.payload.comment.body;
const isTeamMember = ${{ env.TRIAGERS }}.includes(commentAuthor);
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions

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

const shouldAddLabel = isTeamMember && commentAuthor !== issue.data.user.login && isRequestForInfo;
if (shouldAddLabel) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
labels: ['info-needed']
});
}
- name: Add "info-needed" label
uses: ./actions/python-triage-info-needed
with:
triagers: ${{ env.TRIAGERS }}
action: 'add'
token: ${{secrets.GITHUB_TOKEN}}

remove_label:
if: contains(github.event.issue.labels.*.name, 'info-needed') && contains(github.event.issue.labels.*.name, 'triage-needed')
runs-on: ubuntu-latest
steps:
- name: Check for author
uses: actions/github-script@v6
- name: Checkout Actions
uses: actions/checkout@v3
with:
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions

- name: Install Actions
run: npm install --production --prefix ./actions

- name: Remove "info-needed" label
uses: ./actions/python-triage-info-needed
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = await github.rest.issues.get({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const commentAuthor = context.payload.comment.user.login;
const issueAuthor = issue.data.user.login;
if (commentAuthor === issueAuthor) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'info-needed'
});
return;
}
if (${{ env.TRIAGERS }}.includes(commentAuthor)) {
// If one of triagers made a comment, ignore it
return;
}
// Loop through all the comments on the issue in reverse order and find the last username that a TRIAGER mentioned
// If the comment author is the last mentioned username, remove the "info-needed" label
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
for (const comment of comments.data.slice().reverse()) {
if (!${{ env.TRIAGERS }}.includes(comment.user.login)) {
continue;
}
const matches = comment.body.match(/@\w+/g) || [];
const mentionedUsernames = matches.map(match => match.replace('@', ''));
if (mentionedUsernames.includes(commentAuthor)) {
await github.rest.issues.removeLabel({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
name: 'info-needed'
});
break;
}
}
triagers: ${{ env.TRIAGERS }}
action: 'remove'
token: ${{secrets.GITHUB_TOKEN}}

0 comments on commit f0253e5

Please sign in to comment.