diff --git a/.github/workflows/community-feedback-auto-comment.yml b/.github/workflows/community-feedback-auto-comment.yml index cbba6db30b50..57bbd97bf430 100644 --- a/.github/workflows/community-feedback-auto-comment.yml +++ b/.github/workflows/community-feedback-auto-comment.yml @@ -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. diff --git a/.github/workflows/issue-labels.yml b/.github/workflows/issue-labels.yml index 520592be2fce..98ac4eaca81d 100644 --- a/.github/workflows/issue-labels.yml +++ b/.github/workflows/issue-labels.yml @@ -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 }} diff --git a/.github/workflows/lock-issues.yml b/.github/workflows/lock-issues.yml index 6417d415fcfe..8c828ff766cb 100644 --- a/.github/workflows/lock-issues.yml +++ b/.github/workflows/lock-issues.yml @@ -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 }} diff --git a/.github/workflows/pr-file-check.yml b/.github/workflows/pr-file-check.yml index 3eb7ad7b6338..258e07daace7 100644 --- a/.github/workflows/pr-file-check.yml +++ b/.github/workflows/pr-file-check.yml @@ -15,29 +15,15 @@ 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)' + repository: 'microsoft/vscode-github-triage-actions' + ref: stable + path: ./actions - - 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: Install Actions + run: npm install --production --prefix ./actions - - 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)' + - name: Check for changed files + uses: ./actions/python-pr-file-check diff --git a/.github/workflows/pr-labels.yml b/.github/workflows/pr-labels.yml index e953f62d2011..7ddb781e2a85 100644 --- a/.github/workflows/pr-labels.yml +++ b/.github/workflows/pr-labels.yml @@ -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 diff --git a/.github/workflows/test-plan-item-validator.yml b/.github/workflows/test-plan-item-validator.yml index 43713049f5e8..9d0805a9db9b 100644 --- a/.github/workflows/test-plan-item-validator.yml +++ b/.github/workflows/test-plan-item-validator.yml @@ -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: diff --git a/.github/workflows/triage-info-needed.yml b/.github/workflows/triage-info-needed.yml index 51c5b610f03f..1c384d824da5 100644 --- a/.github/workflows/triage-info-needed.yml +++ b/.github/workflows/triage-info-needed.yml @@ -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}}