puppeteer/.github/workflows/issue-analyzer.yml
2024-01-24 11:27:35 +01:00

245 lines
9.6 KiB
YAML

name: Issue Analyzer
permissions: read-all
on:
issues:
types: [opened, reopened, edited]
concurrency:
group: issue-${{ format('issue-{0}', github.event.issue.number) }}
cancel-in-progress: true
jobs:
analyze-issue:
name: Analyze Issues
runs-on: ubuntu-latest
if: ${{ contains(github.event.issue.labels.*.name, 'bug') && !contains(github.event.issue.labels.*.name, 'disable-analyzer') && !contains(github.event.issue.labels.*.name, 'confirmed') && !contains(github.event.issue.labels.*.name, '@puppeteer/browsers') && !contains(github.event.issue.labels.*.name, '@puppeteer/ng-schematics') && github.event.issue.number > 9481 }}
env:
ISSUE_BODY: ${{ toJson(github.event.issue.body) }}
outputs:
runsOn: ${{ steps.issue-analysis.outputs.runsOn }}
nodeVersion: ${{ steps.issue-analysis.outputs.nodeVersion }}
packageManager: ${{ steps.issue-analysis.outputs.packageManager }}
errorMessage: ${{ steps.issue-analysis.outputs.errorMessage }}
permissions:
issues: write
steps:
- name: Remove labels
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
if (${{ contains(github.event.issue.labels.*.name, 'not-reproducible') }}) {
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ["not-reproducible"]
})
}
if (${{ contains(github.event.issue.labels.*.name, 'needs-feedback') }}) {
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ["needs-feedback"]
})
}
if (${{ contains(github.event.issue.labels.*.name, 'invalid') }}) {
github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: ["invalid"]
})
}
- name: Check out repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Set up Node.js
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version-file: '.nvmrc'
- name: Install dependencies
run: npm ci
- name: Analyze issue
id: issue-analysis
run: echo $ISSUE_BODY | ./tools/analyze_issue.mjs >> $GITHUB_OUTPUT
- uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0
with:
name: issue-files
path: out/
verify-issue:
name: Verify Issue
needs: analyze-issue
runs-on: ${{ needs.analyze-issue.outputs.runsOn }}
permissions:
issues: write
env:
PACKAGE_MANAGER: ${{ needs.analyze-issue.outputs.packageManager }}
NODE_VERSION: ${{ needs.analyze-issue.outputs.nodeVersion }}
steps:
- uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1
with:
name: issue-files
path: '.'
- name: Set up Node.js
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # v4.0.1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Enable corepack
run: corepack enable
- name: Install dependencies
run: ${{ env.PACKAGE_MANAGER }} install
env:
YARN_ENABLE_IMMUTABLE_INSTALLS: false
- name: Install dependencies Firefox
run: node ./node_modules/puppeteer/install.mjs
env:
PUPPETEER_PRODUCT: firefox
- name: Verify issue
timeout-minutes: 10
run: ${{ env.PACKAGE_MANAGER }} run verify
env:
DEBUG: 'puppeteer:*'
- uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0
if: success() || failure()
with:
name: runtime-output
path: |
*.log
**/*.pdf
if-no-files-found: error
label-verified-issue:
needs: [verify-issue]
if: success()
name: Label verified issue
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add labels
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["confirmed"]
})
- name: Find Comment Id
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
id: find-comment-id
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
- name: Upsert comment
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
with:
comment-id: ${{ steps.find-comment-id.outputs.comment-id }}
issue-number: ${{ github.event.issue.number }}
edit-mode: replace
body: |
The issue has been labeled as **confirmed** by the automatic analyser.
Someone from the Puppeteer team will take a look soon!
---
[Analyzer run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
label-invalid-issue:
needs: [analyze-issue]
if: failure() && needs.analyze-issue.outputs.errorMessage != ''
name: Label invalid issue
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add labels
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["invalid"]
})
- name: Find Comment Id
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
id: find-comment-id
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
- name: Upsert comment
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
with:
comment-id: ${{ steps.find-comment-id.outputs.comment-id }}
issue-number: ${{ github.event.issue.number }}
edit-mode: replace
body: |
${{ needs.analyze-issue.outputs.errorMessage }}
---
[Analyzer run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
label-unverifiable-issue:
needs: [analyze-issue, verify-issue]
if: failure() && needs.analyze-issue.outputs.errorMessage == ''
name: Label unverifiable issue
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Add labels
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ["not-reproducible", "needs-feedback"]
})
- name: Find Comment Id
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2.4.0
id: find-comment-id
with:
issue-number: ${{ github.event.issue.number }}
comment-author: 'github-actions[bot]'
- name: Upsert comment
uses: peter-evans/create-or-update-comment@23ff15729ef2fc348714a3bb66d2f655ca9066f2 # v3.1.0
with:
comment-id: ${{ steps.find-comment-id.outputs.comment-id }}
issue-number: ${{ github.event.issue.number }}
edit-mode: replace
body: |
This issue was not reproducible. Please check that your example runs locally and the following:
- Ensure the script does not rely on dependencies outside of `puppeteer` and `puppeteer-core`.
- Ensure the error string is just the error message.
- Bad:
```ts
Error: something went wrong
at Object.<anonymous> (/Users/username/repository/script.js:2:1)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47
```
- Good: `Error: something went wrong`.
- Ensure your configuration file (if applicable) is valid.
- If the issue is flaky (does not reproduce all the time), make sure 'Flaky' is checked.
- If the issue is not expected to error, make sure to write 'no error'.
Once the above checks are satisfied, please edit your issue with the changes and we will
try to reproduce the bug again.
---
[Analyzer run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})