Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions .github/workflows/playwright_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,10 @@ jobs:
path: ${{ github.workspace }}/playwright-report
if-no-files-found: error

# The steps below do not need the HTML report, so they also run after a step above fails: an `if`
# without a status function such as !cancelled() gets an implicit success().
- name: Merge test traces
if: steps.mergeable-artifacts.outputs.traces == 'true'
if: ${{ !cancelled() && steps.mergeable-artifacts.outputs.traces == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -427,7 +429,7 @@ jobs:
delete-merged: true

- name: Merge etalons
if: steps.mergeable-artifacts.outputs.etalons == 'true'
if: ${{ !cancelled() && steps.mergeable-artifacts.outputs.etalons == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -436,15 +438,17 @@ jobs:
delete-merged: true

- name: Download flaky test reports
if: steps.mergeable-artifacts.outputs.flaky == 'true'
id: download-flaky-reports
if: ${{ !cancelled() && steps.mergeable-artifacts.outputs.flaky == 'true' }}
uses: actions/download-artifact@v7
with:
pattern: playwright-flaky-report-*
path: ${{ github.workspace }}/flaky-reports

# The file tools/flaky-test-reporter collects from every run of this workflow (repository-check.yml).
- name: Build flaky candidates report
if: steps.mergeable-artifacts.outputs.flaky == 'true'
id: build-flaky-candidates
if: ${{ !cancelled() && steps.download-flaky-reports.outcome == 'success' }}
run: |
mkdir -p artifacts
report=artifacts/flaky-candidates.json
Expand All @@ -465,7 +469,7 @@ jobs:
} >> "$GITHUB_STEP_SUMMARY"

- name: Upload flaky candidates report
if: steps.mergeable-artifacts.outputs.flaky == 'true'
if: ${{ !cancelled() && steps.build-flaky-candidates.outcome == 'success' }}
uses: actions/upload-artifact@v7
with:
name: flaky-candidates
Expand Down
68 changes: 44 additions & 24 deletions .github/workflows/repository-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,55 @@ jobs:
run: |
# tee opens the log before the tool runs, so the directory must already exist.
mkdir -p "$GITHUB_WORKSPACE/artifacts"
report="$GITHUB_WORKSPACE/artifacts/flaky-tests-report.json"
markdown="$GITHUB_WORKSPACE/artifacts/flaky-tests-report.md"
log="$GITHUB_WORKSPACE/artifacts/collect.log"

# --silent keeps pnpm's own banner out of the summary; 2>&1 keeps the tool's warnings in.
# tee stores the plain text for the summary, then sed turns the tool's warnings into
# GitHub annotations so they surface on the run page.
pnpm --silent --filter flaky-test-reporter run collect -- \
--repo "${{ github.repository }}" \
--workflow playwright_tests.yml \
--artifact flaky-candidates \
--branch "${{ github.ref_name }}" \
--window-hours "$WINDOW_HOURS" \
--out-json "$report" \
--out-markdown "$markdown" 2>&1 \
| tee "$log" \
| sed -e 's/^warning: /::warning::/' -e 's/^Collection failed: /::error::/'
# One report per workflow. The suffix names its files, the label its summary section, and
# the rest of the arguments go to the tool.
collect_flaky() {
suffix="$1"
label="$2"
shift 2
log="$GITHUB_WORKSPACE/artifacts/collect$suffix.log"

{
echo "## Flaky test candidates"
echo ""
echo '```'
cat "$log"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
# --silent keeps pnpm's own banner out of the summary; 2>&1 keeps the tool's warnings in.
# tee stores the plain text for the summary, then sed turns the tool's warnings into
# GitHub annotations so they surface on the run page.
pnpm --silent --filter flaky-test-reporter run collect -- \
--repo "${{ github.repository }}" \
--artifact flaky-candidates \
--branch "${{ github.ref_name }}" \
--window-hours "$WINDOW_HOURS" \
--out-json "$GITHUB_WORKSPACE/artifacts/flaky-tests-report$suffix.json" \
--out-markdown "$GITHUB_WORKSPACE/artifacts/flaky-tests-report$suffix.md" \
"$@" 2>&1 \
| tee "$log" \
| sed -e 's/^warning: /::warning::/' -e 's/^Collection failed: /::error::/'

{
echo "## Flaky test candidates: $label"
echo ""
echo '```'
cat "$log"
echo '```'
} >> "$GITHUB_STEP_SUMMARY"
}

# Both reports go into one issue body after the monitor's own sections, and GitHub caps the
# body at 65,536 characters: each report gets a share of it, the demos a smaller one.
collect_flaky "" "component tests" --workflow playwright_tests.yml --max-chars 36000
collect_flaky "-demos" "demos" --workflow visual-tests-demos.yml \
--title "Flaky Test Candidates (Demos)" --max-tests 10 --max-chars 18000

# Multiline output form, so the markdown crosses the job boundary as-is. The delimiter
# must not occur in the content, which markdown headings and tables never produce.
# A report the tool did not write leaves out its section only.
{
echo 'details<<FLAKY_DETAILS_EOF'
cat "$markdown"
for markdown in flaky-tests-report.md flaky-tests-report-demos.md; do
if [ -f "$GITHUB_WORKSPACE/artifacts/$markdown" ]; then
cat "$GITHUB_WORKSPACE/artifacts/$markdown"
echo ""
fi
done
echo 'FLAKY_DETAILS_EOF'
} >> "$GITHUB_OUTPUT"

Expand All @@ -88,6 +106,8 @@ jobs:
path: |
${{ github.workspace }}/artifacts/flaky-tests-report.json
${{ github.workspace }}/artifacts/collect.log
${{ github.workspace }}/artifacts/flaky-tests-report-demos.json
${{ github.workspace }}/artifacts/collect-demos.log
retention-days: 7
if-no-files-found: ignore

Expand Down
79 changes: 73 additions & 6 deletions .github/workflows/visual-tests-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,9 @@ jobs:
# The default blob name is built from the test paths only, so jobs that differ by theme or
# shard alone would write the same zip and overwrite each other once merged.
PLAYWRIGHT_BLOB_OUTPUT_NAME: report-${{ env.PLAYWRIGHT_JOB_NAME }}.zip
# tools/playwright/flakyReporter.ts stamps every flaky test it records with the job it ran in.
FLAKY_REPORT_JOB: ${{ matrix.CONSTEL }}-${{ matrix.STRATEGY }}-${{ matrix.THEME }}
FLAKY_REPORT_BASE_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref || github.ref_name }}
run: pnpm run test-playwright

- name: Run Playwright accessibility tests (jQuery)
Expand Down Expand Up @@ -566,6 +569,15 @@ jobs:
path: ${{ github.workspace }}/apps/demos/testing/artifacts/playwright/test-results
if-no-files-found: ignore

- name: Upload flaky test report
if: always() && matrix.STRATEGY == 'screenshots'
uses: actions/upload-artifact@v7
with:
name: playwright-flaky-report-${{ env.PLAYWRIGHT_JOB_NAME }}
path: ${{ github.workspace }}/apps/demos/testing/artifacts/playwright/flaky-report.json
retention-days: 1
if-no-files-found: ignore

# One folder at repository paths: the new etalons the tests wrote, and the etalons of the failed
# shots that tools/playwright/etalonCollector.ts collected.
- name: Collect etalons
Expand Down Expand Up @@ -743,6 +755,9 @@ jobs:
# The default blob name is built from the test paths only, so jobs that differ by theme or
# shard alone would write the same zip and overwrite each other once merged.
PLAYWRIGHT_BLOB_OUTPUT_NAME: report-${{ env.PLAYWRIGHT_JOB_NAME }}.zip
# tools/playwright/flakyReporter.ts stamps every flaky test it records with the job it ran in.
FLAKY_REPORT_JOB: ${{ matrix.CONSTEL }}-screenshots-${{ matrix.THEME }}
FLAKY_REPORT_BASE_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref || github.ref_name }}
run: pnpm run test-playwright

# A test that writes a missing etalon passes (updateSnapshots: 'missing'), so this step fails the job
Expand Down Expand Up @@ -775,6 +790,15 @@ jobs:
path: ${{ github.workspace }}/apps/demos/testing/artifacts/playwright/test-results
if-no-files-found: ignore

- name: Upload flaky test report
if: always()
uses: actions/upload-artifact@v7
with:
name: playwright-flaky-report-${{ env.PLAYWRIGHT_JOB_NAME }}
path: ${{ github.workspace }}/apps/demos/testing/artifacts/playwright/flaky-report.json
retention-days: 1
if-no-files-found: ignore

# One folder at repository paths: the new etalons the tests wrote, and the etalons of the failed
# shots that tools/playwright/etalonCollector.ts collected.
- name: Collect etalons
Expand Down Expand Up @@ -820,6 +844,7 @@ jobs:
etalons_react: /^playwright-etalons-react\(/,
etalons_vue: /^playwright-etalons-vue\(/,
etalons_angular: /^playwright-etalons-angular\(/,
flaky: /^playwright-flaky-report-/,
};

for (const [outputName, pattern] of Object.entries(artifactGroups)) {
Expand Down Expand Up @@ -873,8 +898,10 @@ jobs:
path: ${{ github.workspace }}/playwright-report
if-no-files-found: error

# The steps below do not need the HTML report, so they also run after a step above fails: an `if`
# without a status function such as !cancelled() gets an implicit success().
- name: Merge Playwright traces
if: steps.playwright-artifacts.outputs.traces == 'true'
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.traces == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -886,7 +913,7 @@ jobs:
# One etalon serves every framework of a demo, so each framework gets its own artifact: merged
# together, a framework that renders differently would overwrite another's picture.
- name: Merge jQuery etalons
if: steps.playwright-artifacts.outputs.etalons_jquery == 'true'
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.etalons_jquery == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -895,7 +922,7 @@ jobs:
delete-merged: true

- name: Merge React etalons
if: steps.playwright-artifacts.outputs.etalons_react == 'true'
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.etalons_react == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -904,7 +931,7 @@ jobs:
delete-merged: true

- name: Merge Vue etalons
if: steps.playwright-artifacts.outputs.etalons_vue == 'true'
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.etalons_vue == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand All @@ -913,16 +940,56 @@ jobs:
delete-merged: true

- name: Merge Angular etalons
if: steps.playwright-artifacts.outputs.etalons_angular == 'true'
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.etalons_angular == 'true' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
name: playwright-etalons-angular
pattern: playwright-etalons-angular(*
delete-merged: true

- name: Download flaky test reports
id: download-flaky-reports
if: ${{ !cancelled() && steps.playwright-artifacts.outputs.flaky == 'true' }}
uses: actions/download-artifact@v8
with:
pattern: playwright-flaky-report-*
path: ${{ github.workspace }}/flaky-reports

# The file tools/flaky-test-reporter collects from every run of this workflow (repository-check.yml).
- name: Build flaky candidates report
id: build-flaky-candidates
if: ${{ !cancelled() && steps.download-flaky-reports.outcome == 'success' }}
run: |
mkdir -p artifacts
report=artifacts/flaky-candidates.json
find flaky-reports -type f -name flaky-report.json -print0 \
| xargs -0 jq -s '{ schemaVersion: 1, candidates: (map(.candidates) | add) }' \
> "$report"

{
echo "## Flaky tests"
echo ""
if [ "$(jq '.candidates | length' "$report")" -eq 0 ]; then
echo "_none_"
else
echo "| Test | Job |"
echo "|---|---|"
jq -r '.candidates[] | "| \(.test | gsub("\\|"; "\\|")) | \(.sourceJob) |"' "$report"
fi
} >> "$GITHUB_STEP_SUMMARY"

- name: Upload flaky candidates report
if: ${{ !cancelled() && steps.build-flaky-candidates.outcome == 'success' }}
uses: actions/upload-artifact@v7
with:
name: flaky-candidates
path: ${{ github.workspace }}/artifacts/flaky-candidates.json
retention-days: 7
if-no-files-found: ignore

- name: Merge jQuery accessibility reports
if: needs.playwright-jquery.result == 'failure'
if: ${{ !cancelled() && needs.playwright-jquery.result == 'failure' }}
uses: actions/upload-artifact/merge@v7
continue-on-error: true
with:
Expand Down
2 changes: 1 addition & 1 deletion apps/demos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ gh run download <run-id> -n playwright-traces -D ci-traces
pnpm exec playwright show-report ci-report
```

A failed comparison uploads its `-expected`, `-actual` and `-diff` images with the trace. On CI a failed test runs once more; a test that passes then is listed under "flaky" and does not fail the job.
A failed comparison uploads its `-expected`, `-actual` and `-diff` images with the trace. On CI a failed test runs once more; a test that passes then is listed under "flaky" and does not fail the job. It is not forgotten either: the job marks it with a "Flaky test" warning, the run lists the flaky tests of every job in its summary and keeps them in its `flaky-candidates` artifact, and `repository-check.yml` adds those up over 72 hours in the repository monitor issue, in a section of its own ("Flaky tests" in `e2e/playwright/README.md` describes the same for the component tests).

## Accessibility Tests

Expand Down
5 changes: 5 additions & 0 deletions apps/demos/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,15 @@ export default defineConfig({
? [
['list'],
['blob', { outputDir: './testing/artifacts/playwright/blob-report' }],
// Before the flaky reporter: its annotations share the step's limit of 10 warnings.
['../../tools/playwright/etalonCollector.ts', {
outputDir: './testing/artifacts/playwright/collected-etalons',
repositoryRoot: '../..',
}],
['../../tools/playwright/flakyReporter.ts', {
outputFile: './testing/artifacts/playwright/flaky-report.json',
defaultTheme: THEME,
}],
]
: [['list']],
timeout: 60000,
Expand Down
13 changes: 13 additions & 0 deletions tools/flaky-test-reporter/src/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ describe('parseArgs', () => {
});
});

it('keeps the default heading and test cap unless given', () => {
expect(parseArgs(flags)).toMatchObject({ title: 'Flaky Test Candidates', maxTests: 20 });
expect(parseArgs([...flags, '--title', 'Demos', '--max-tests', '10'])).toMatchObject({
title: 'Demos',
maxTests: 10,
});
});

it('leaves the report length open unless given', () => {
expect(parseArgs(flags).maxChars).toBeUndefined();
expect(parseArgs([...flags, '--max-chars', '18000'])).toMatchObject({ maxChars: 18000 });
});

it('parses identically when invoked through `pnpm run <script> --`, which forwards the separator', () => {
expect(parseArgs(['--', ...flags])).toMatchObject(parseArgs(flags));
});
Expand Down
Loading
Loading