puppeteer/.github/workflows/issue-analyzer.yml
2023-07-12 09:14:30 +02:00

245 lines
9.5 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') && 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@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: lts/*
- 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@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
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@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
with:
name: issue-files
path: '.'
- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
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.js
env:
PUPPETEER_PRODUCT: firefox
- name: Verify issue
timeout-minutes: 10
run: ${{ env.PACKAGE_MANAGER }} run verify
env:
DEBUG: 'puppeteer:*'
- uses: actions/upload-artifact@0b7f8abb1508181956e8e162db84b466c27e18ce # v3.1.2
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@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.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@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
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@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.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@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
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@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6.4.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@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
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 }})