Skip to content
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

Use actions from vscode-github-triage-actions in all Python automations #21178

Merged
merged 21 commits into from
May 5, 2023
21 changes: 9 additions & 12 deletions .github/workflows/community-feedback-auto-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ 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

- name: Add Community Feedback Comment
if: steps.finder.outputs.comment-id == ''
uses: peter-evans/create-or-update-comment@v3
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 applicable
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
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.
64 changes: 13 additions & 51 deletions .github/workflows/issue-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,55 +18,17 @@ 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'))

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.')

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,
})
}
}
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions
- name: Install Actions
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
run: npm install --production --prefix ./actions
- name: "Add 'triage-needed' and remove unrecognizable labels & assignees"
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
uses: ./actions/python-issue-labels
with:
triagers: ${{ env.TRIAGERS }}
token: ${{secrets.GITHUB_TOKEN}}
repo_labels: ${{ env.REPO_LABELS }}
16 changes: 11 additions & 5 deletions .github/workflows/lock-issues.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,15 @@ 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 }}
34 changes: 9 additions & 25 deletions .github/workflows/pr-file-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,13 @@ jobs:
name: 'Check for changed files'
runs-on: ubuntu-latest
steps:
- name: 'package-lock.json matches package.json'
uses: brettcannon/check-for-changed-files@v1.1.0
- 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)'

- name: 'package.json matches package-lock.json'
uses: brettcannon/check-for-changed-files@v1.1.0
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: 'Tests'
uses: brettcannon/check-for-changed-files@v1.1.0
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)'
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions
- name: Install Actions
run: npm install --production --prefix ./actions
- name: Check for changed files
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
uses: ./actions/python-pr-file-check
14 changes: 9 additions & 5 deletions .github/workflows/pr-labels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,13 @@ 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
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
uses: ./actions/python-pr-labels
101 changes: 26 additions & 75 deletions .github/workflows/triage-info-needed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,86 +11,37 @@ 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);

const keywords = ${{ env.KEYWORDS }};
const isRequestForInfo = new RegExp(keywords.join('|'), 'i').test(commentBody);

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']
});
}
repository: 'microsoft/vscode-github-triage-actions'
ref: stable
path: ./actions
- name: Install Actions
run: npm install --production --prefix ./actions
- name: Add "info-needed" label
uses: ./actions/python-triage-info-needed
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
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
karrtikr marked this conversation as resolved.
Show resolved Hide resolved
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}}