diff --git a/.gitattributes b/.gitattributes index 554b857..7971149 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,3 +1,3 @@ # Generated by `npm run bundle`: collapsed in GitHub diffs and shown as binary by git diff. .github/cli/apify-test-tools.mjs linguist-generated=true -diff -.github/scripts/run-with-apify-tokens.mjs linguist-generated=true -diff \ No newline at end of file +.github/scripts/*.mjs linguist-generated=true -diff \ No newline at end of file diff --git a/.github/actions/failure-signatures/action.yaml b/.github/actions/failure-signatures/action.yaml new file mode 100644 index 0000000..f5e0504 --- /dev/null +++ b/.github/actions/failure-signatures/action.yaml @@ -0,0 +1,52 @@ +name: Match failures to known issues +description: >- + `match` matches the run's failing tests to open issues by failure signature, `record` records the signatures that + matched nothing on the issue that now covers them. See workflow-scripts-src/failure-signatures.ts. +inputs: + mode: + description: '`match` or `record`' + required: true + new-issue-number: + description: The issue the investigation opened, if any, for `record`. + required: false + default: '' +outputs: + all-known: + description: '`true` when every failure matches an open issue' + value: ${{ steps.script.outputs.all-known }} + note: + description: When only some failures match, which issues cover them and which failing tests are left + value: ${{ steps.script.outputs.note }} + +# The script ships with this action as a bundle (npm run bundle), so nothing is checked out or installed. +runs: + using: 'composite' + steps: + - name: Run the script + id: script + uses: actions/github-script@v9 + env: + MODE: ${{ inputs.mode }} + NEW_ISSUE_NUMBER: ${{ inputs.new-issue-number }} + MATCHES_PATH: ${{ runner.temp }}/failure-signatures.json + SCRIPT_PATH: ${{ github.action_path }}/../../scripts/failure-signatures.mjs + with: + script: | + const { matchKnownFailures, recordSignatures } = await import(process.env.SCRIPT_PATH); + const workspace = process.env.GITHUB_WORKSPACE; + const params = { github, context, core, matchesPath: process.env.MATCHES_PATH }; + if (process.env.MODE === 'match') { + await matchKnownFailures({ + ...params, + reportPath: `${workspace}/vitest-results/test-report.json`, + duplicatesPath: `${workspace}/duplicate-of.txt`, + }); + } else if (process.env.MODE === 'record') { + await recordSignatures({ + ...params, + dedupePath: `${workspace}/dedupe.json`, + newIssueNumber: Number(process.env.NEW_ISSUE_NUMBER) || undefined, + }); + } else { + throw new Error(`Unsupported mode '${process.env.MODE}'. Use 'match' or 'record'.`); + } diff --git a/.github/scripts/failure-signatures.mjs b/.github/scripts/failure-signatures.mjs new file mode 100644 index 0000000..5c0576d --- /dev/null +++ b/.github/scripts/failure-signatures.mjs @@ -0,0 +1,7 @@ +import{createRequire as __createRequire}from'node:module';const require=__createRequire(import.meta.url); +import{createHash as A}from"node:crypto";import{appendFile as $,readFile as N,writeFile as M}from"node:fs/promises";import{stripVTControlCharacters as O}from"node:util";var b="platform-test-signatures",y=new RegExp(``),S=16,x=new RegExp(`^[\\da-f]{${S}}$`),E=200,k=["OWNER","MEMBER","COLLABORATOR"],F="(outside any test)";function P(t){return O(t).replace(/https?:\/\/\S+/g,"").replace(/\d{4}-\d{2}-\d{2}[T ][\d:.]+Z?/g,"