From 93d828cec7dcf0e787806d3be3be1f1f94155d1b Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 8 Aug 2022 21:00:14 +0000 Subject: [PATCH 1/6] Ensure any labels or assignees do not carry over when transferring issues to repo --- .github/workflows/getLabels.js | 18 +++++++++++++++++ .github/workflows/issue-labels.yml | 32 +++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/getLabels.js diff --git a/.github/workflows/getLabels.js b/.github/workflows/getLabels.js new file mode 100644 index 000000000000..a703c86be9fb --- /dev/null +++ b/.github/workflows/getLabels.js @@ -0,0 +1,18 @@ +/** + * To run this file: + * * npm install @octokit/rest + * * node .github/workflows/getLabels.js + */ + + const { Octokit } = require('@octokit/rest'); + const octokit = new Octokit(); + octokit.rest.issues + .listLabelsForRepo({ + owner: 'microsoft', + repo: 'vscode-python', + }) + .then((result) => { + const labels = result.data.map((label) => label.name); + console.log(JSON.stringify(labels)); + }); + \ No newline at end of file diff --git a/.github/workflows/issue-labels.yml b/.github/workflows/issue-labels.yml index d743d437428a..adcf6ee61bf8 100644 --- a/.github/workflows/issue-labels.yml +++ b/.github/workflows/issue-labels.yml @@ -10,7 +10,11 @@ permissions: jobs: # From https://github.com/marketplace/actions/github-script#apply-a-label-to-an-issue. add-classify-label: - name: "Add 'triage-needed'" + name: "Add 'triage-needed' and remove unrecognizable labels and assignees" + env: + # To update the list of labels, see `getLabels.js`. + REPO_LABELS: '["area-data science","area-debugging","area-diagnostics","area-editor-*","area-environments","area-formatting","area-intellisense","area-internal","area-linting","area-terminal","area-testing","author-verification-requested","bug","community ask","debt","dependencies","documentation","experimenting","feature-request","good first issue","help wanted","important","info-needed","invalid-testplan-item","investigating","iteration-candidate","iteration-plan","iteration-plan-draft","javascript","linux"]' + TRIAGERS: '["karrtikr","karthiknadig","paulacamargo25"]' runs-on: ubuntu-latest steps: - uses: actions/github-script@v6 @@ -37,3 +41,29 @@ jobs: } 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 knownLabels = ${{ env.REPO_LABELS }} + const knownTriagers = ${{ env.TRIAGERS }} + for( const label of labels) { + if (!knownLabels.includes(label)) { + await github.rest.issues.deleteLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + name: label, + }) + } + } + 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)); + const assigneesToRemove = currentAssignees.filter(a => !knownTriagers.includes(a)); + github.rest.issues.removeAssignees({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + assignees: assigneesToRemove, + }); + From 2e17fabefe8055adb43f31705770238cea452b26 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 8 Aug 2022 21:04:42 +0000 Subject: [PATCH 2/6] Fix indent --- .github/workflows/getLabels.js | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/getLabels.js b/.github/workflows/getLabels.js index a703c86be9fb..2f8a21bae6fa 100644 --- a/.github/workflows/getLabels.js +++ b/.github/workflows/getLabels.js @@ -4,15 +4,14 @@ * * node .github/workflows/getLabels.js */ - const { Octokit } = require('@octokit/rest'); - const octokit = new Octokit(); - octokit.rest.issues - .listLabelsForRepo({ - owner: 'microsoft', - repo: 'vscode-python', - }) - .then((result) => { - const labels = result.data.map((label) => label.name); - console.log(JSON.stringify(labels)); - }); - \ No newline at end of file +const { Octokit } = require('@octokit/rest'); +const github = new Octokit(); +github.rest.issues + .listLabelsForRepo({ + owner: 'microsoft', + repo: 'vscode-python', + }) + .then((result) => { + const labels = result.data.map((label) => label.name); + console.log(JSON.stringify(labels)); + }); From 0d3893e99a4661d4e60269ee36f037c47633623a Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 8 Aug 2022 21:07:49 +0000 Subject: [PATCH 3/6] Make list of envs global --- .github/workflows/issue-labels.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/issue-labels.yml b/.github/workflows/issue-labels.yml index adcf6ee61bf8..5729e5702f3d 100644 --- a/.github/workflows/issue-labels.yml +++ b/.github/workflows/issue-labels.yml @@ -4,6 +4,11 @@ on: issues: types: [opened, reopened] +env: + # To update the list of labels, see `getLabels.js`. + REPO_LABELS: '["area-data science","area-debugging","area-diagnostics","area-editor-*","area-environments","area-formatting","area-intellisense","area-internal","area-linting","area-terminal","area-testing","author-verification-requested","bug","community ask","debt","dependencies","documentation","experimenting","feature-request","good first issue","help wanted","important","info-needed","invalid-testplan-item","investigating","iteration-candidate","iteration-plan","iteration-plan-draft","javascript","linux"]' + TRIAGERS: '["karrtikr","karthiknadig","paulacamargo25"]' + permissions: issues: write @@ -11,10 +16,6 @@ jobs: # From https://github.com/marketplace/actions/github-script#apply-a-label-to-an-issue. add-classify-label: name: "Add 'triage-needed' and remove unrecognizable labels and assignees" - env: - # To update the list of labels, see `getLabels.js`. - REPO_LABELS: '["area-data science","area-debugging","area-diagnostics","area-editor-*","area-environments","area-formatting","area-intellisense","area-internal","area-linting","area-terminal","area-testing","author-verification-requested","bug","community ask","debt","dependencies","documentation","experimenting","feature-request","good first issue","help wanted","important","info-needed","invalid-testplan-item","investigating","iteration-candidate","iteration-plan","iteration-plan-draft","javascript","linux"]' - TRIAGERS: '["karrtikr","karthiknadig","paulacamargo25"]' runs-on: ubuntu-latest steps: - uses: actions/github-script@v6 From 35f75fc76812721f1bf33e08e8d35b7769eee78e Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 8 Aug 2022 21:08:28 +0000 Subject: [PATCH 4/6] Minor edit --- .github/workflows/issue-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-labels.yml b/.github/workflows/issue-labels.yml index 5729e5702f3d..6a25b1b50dd9 100644 --- a/.github/workflows/issue-labels.yml +++ b/.github/workflows/issue-labels.yml @@ -15,7 +15,7 @@ permissions: jobs: # From https://github.com/marketplace/actions/github-script#apply-a-label-to-an-issue. add-classify-label: - name: "Add 'triage-needed' and remove unrecognizable labels and assignees" + name: "Add 'triage-needed' and remove unrecognizable labels & assignees" runs-on: ubuntu-latest steps: - uses: actions/github-script@v6 From 16db7010cf4239a4018a49c23bece854dd4a4349 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 8 Aug 2022 21:13:12 +0000 Subject: [PATCH 5/6] Run prettier --- .github/workflows/issue-labels.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/issue-labels.yml b/.github/workflows/issue-labels.yml index 6a25b1b50dd9..642b4518b7f6 100644 --- a/.github/workflows/issue-labels.yml +++ b/.github/workflows/issue-labels.yml @@ -67,4 +67,3 @@ jobs: issue_number: context.issue.number, assignees: assigneesToRemove, }); - From 07c76194cc907e45999be8c9fc9361fdd1f9f6d7 Mon Sep 17 00:00:00 2001 From: Kartik Raj Date: Mon, 8 Aug 2022 15:36:24 -0700 Subject: [PATCH 6/6] Add Eleanor to triage flow Co-authored-by: Karthik Nadig --- .github/workflows/issue-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/issue-labels.yml b/.github/workflows/issue-labels.yml index 642b4518b7f6..20f061828cbe 100644 --- a/.github/workflows/issue-labels.yml +++ b/.github/workflows/issue-labels.yml @@ -7,7 +7,7 @@ on: env: # To update the list of labels, see `getLabels.js`. REPO_LABELS: '["area-data science","area-debugging","area-diagnostics","area-editor-*","area-environments","area-formatting","area-intellisense","area-internal","area-linting","area-terminal","area-testing","author-verification-requested","bug","community ask","debt","dependencies","documentation","experimenting","feature-request","good first issue","help wanted","important","info-needed","invalid-testplan-item","investigating","iteration-candidate","iteration-plan","iteration-plan-draft","javascript","linux"]' - TRIAGERS: '["karrtikr","karthiknadig","paulacamargo25"]' + TRIAGERS: '["karrtikr","karthiknadig","paulacamargo25","eleanorjboyd"]' permissions: issues: write