diff --git a/.github/actions/report-flaky/.gitignore b/.github/actions/report-flaky/.gitignore new file mode 100644 index 0000000000..c2658d7d1b --- /dev/null +++ b/.github/actions/report-flaky/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/.github/actions/report-flaky/action.yml b/.github/actions/report-flaky/action.yml new file mode 100644 index 0000000000..1414fa88da --- /dev/null +++ b/.github/actions/report-flaky/action.yml @@ -0,0 +1,12 @@ +--- + +name: Report flaky tests +description: Parses log file for flaky tests and adds annotations for them +inputs: + logFile: + description: Log file containing the flaky test logs + required: true + default: 'log/flaky.jsonl' +runs: + using: 'node20' + main: 'report_flaky.js' diff --git a/.github/actions/report-flaky/package-lock.json b/.github/actions/report-flaky/package-lock.json new file mode 100644 index 0000000000..b0bbbf86ad --- /dev/null +++ b/.github/actions/report-flaky/package-lock.json @@ -0,0 +1,69 @@ +{ + "name": "report-flaky", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "report-flaky", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "@actions/core": "^1.10.1" + } + }, + "node_modules/@actions/core": { + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", + "dependencies": { + "@actions/http-client": "^2.0.1", + "uuid": "^8.3.2" + } + }, + "node_modules/@actions/http-client": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/@actions/http-client/-/http-client-2.2.1.tgz", + "integrity": "sha512-KhC/cZsq7f8I4LfZSJKgCvEwfkE8o1538VoBeoGzokVLLnbFDEAdFD3UhoMklxo2un9NJVBdANOresx7vTHlHw==", + "dependencies": { + "tunnel": "^0.0.6", + "undici": "^5.25.4" + } + }, + "node_modules/@fastify/busboy": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", + "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", + "engines": { + "node": ">=14" + } + }, + "node_modules/tunnel": { + "version": "0.0.6", + "resolved": "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz", + "integrity": "sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==", + "engines": { + "node": ">=0.6.11 <=0.7.0 || >=0.7.3" + } + }, + "node_modules/undici": { + "version": "5.28.4", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", + "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", + "dependencies": { + "@fastify/busboy": "^2.0.0" + }, + "engines": { + "node": ">=14.0" + } + }, + "node_modules/uuid": { + "version": "8.3.2", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", + "integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==", + "bin": { + "uuid": "dist/bin/uuid" + } + } + } +} diff --git a/.github/actions/report-flaky/package.json b/.github/actions/report-flaky/package.json new file mode 100644 index 0000000000..8e8daf90ed --- /dev/null +++ b/.github/actions/report-flaky/package.json @@ -0,0 +1,14 @@ +{ + "name": "report-flaky", + "version": "1.0.0", + "description": "Flaky test reporter action", + "main": "report_flaky.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "MIT", + "dependencies": { + "@actions/core": "^1.10.1" + } +} diff --git a/.github/actions/report-flaky/report_flaky.js b/.github/actions/report-flaky/report_flaky.js new file mode 100644 index 0000000000..b1422aed67 --- /dev/null +++ b/.github/actions/report-flaky/report_flaky.js @@ -0,0 +1,26 @@ +// Taken from: https://nodejs.org/api/readline.html#readline_example_read_file_stream_line_by_line +const fs = require('node:fs'); +const readline = require('node:readline'); + +const core = require('@actions/core'); + +const logFilePath = core.getInput('logFile'); + +async function emitAnnotations() { + const fileStream = fs.createReadStream(logFilePath); + + const rl = readline.createInterface({ + input: fileStream, + crlfDelay: Infinity, + }); + // Note: we use the crlfDelay option to recognize all instances of CR LF + // ('\r\n') in input.txt as a single line break. + + for await (const line of rl) { + // each line is expected to be valid JSON + const logRecord = JSON.parse(line); + core.warning(logRecord.msg, {file: logRecord.file, startLine: logRecord.line}); + } +} + +emitAnnotations(); diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 79555bd159..e0d0c84908 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -96,6 +96,10 @@ jobs: DB_PASSWORD: '' DEBUG: 'true' + - run: npm ci + working-directory: .github/actions/report-flaky + - uses: ./.github/actions/report-flaky + - name: Run JS tests run: npm test @@ -178,6 +182,10 @@ jobs: DB_PASSWORD: '' DEBUG: 'true' + - run: npm ci + working-directory: .github/actions/report-flaky + - uses: ./.github/actions/report-flaky + e2etests: runs-on: ubuntu-latest strategy: diff --git a/.github/workflows/debug.yml b/.github/workflows/debug.yml new file mode 100644 index 0000000000..c3e2a8905e --- /dev/null +++ b/.github/workflows/debug.yml @@ -0,0 +1,20 @@ +name: Debug + +# Run this workflow every time a new commit pushed to your repository +on: + push: + +jobs: + debug: + name: Debug + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - run: | + mkdir -p log + echo '{"msg": "Flaky test: test_concurrent_file_uploads", "file": "src/openforms/formio/tests/test_api_fileupload.py", "line": 403}' > log/flaky.jsonl + - run: npm ci + working-directory: .github/actions/report-flaky + + - uses: ./.github/actions/report-flaky