Skip to content

Commit

Permalink
⚗️ Github action
Browse files Browse the repository at this point in the history
  • Loading branch information
sergei-maertens committed Apr 4, 2024
1 parent d628c38 commit b2a8aef
Show file tree
Hide file tree
Showing 7 changed files with 151 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/actions/report-flaky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
13 changes: 13 additions & 0 deletions .github/actions/report-flaky/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---

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'
outputs:
runs:
using: 'node20'
main: 'report_flaky.js'
69 changes: 69 additions & 0 deletions .github/actions/report-flaky/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .github/actions/report-flaky/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
}
26 changes: 26 additions & 0 deletions .github/actions/report-flaky/report_flaky.js
Original file line number Diff line number Diff line change
@@ -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();
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit b2a8aef

Please sign in to comment.