Skip to content

Commit

Permalink
Try to fix flaky playwright tests not being reported (#40290)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevin940726 authored Apr 13, 2022
1 parent 00ef72b commit eb61ff9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .github/report-flaky-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ inputs:
description: 'The flaky-test label name'
required: true
default: 'flaky-test'
artifact-name:
description: 'The name of the uploaded artifact'
artifact-name-prefix:
description: 'The prefix name of the uploaded artifact'
required: true
default: 'flaky-tests-report'
runs:
Expand Down
12 changes: 7 additions & 5 deletions .github/report-flaky-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ const metaData = {
( async function run() {
const token = core.getInput( 'repo-token', { required: true } );
const label = core.getInput( 'label', { required: true } );
const artifactName = core.getInput( 'artifact-name', { required: true } );
const artifactNamePrefix = core.getInput( 'artifact-name-prefix', {
required: true,
} );

const octokit = github.getOctokit( token );

const flakyTests = await downloadReportFromArtifact(
octokit,
artifactName
artifactNamePrefix
);

if ( ! flakyTests ) {
Expand Down Expand Up @@ -191,16 +193,16 @@ async function fetchAllIssuesLabeledFlaky( octokit, label ) {
return issues;
}

async function downloadReportFromArtifact( octokit, artifactName ) {
async function downloadReportFromArtifact( octokit, artifactNamePrefix ) {
const {
data: { artifacts },
} = await octokit.rest.actions.listWorkflowRunArtifacts( {
...github.context.repo,
run_id: github.context.payload.workflow_run.id,
} );

const matchArtifact = artifacts.find(
( artifact ) => artifact.name === artifactName
const matchArtifact = artifacts.find( ( artifact ) =>
artifact.name.startsWith( artifactNamePrefix )
);

if ( ! matchArtifact ) {
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/end2end-test-playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,6 @@ jobs:
uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2
if: always()
with:
name: flaky-tests-report
name: flaky-tests-report-playwright
path: flaky-tests
if-no-files-found: ignore
2 changes: 1 addition & 1 deletion .github/workflows/end2end-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ jobs:
uses: actions/upload-artifact@e448a9b857ee2131e752b06002bf0e093c65e571 # v2.2.2
if: always()
with:
name: flaky-tests-report
name: flaky-tests-report-${{ matrix.part }}
path: flaky-tests
if-no-files-found: ignore
6 changes: 2 additions & 4 deletions .github/workflows/flaky-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: Report Flaky Tests

on:
workflow_run:
# We should also add 'End-to-End Tests Playwright' here but that
# wil run this workflow whenever either one of them completes.
workflows: ['End-to-End Tests']
workflows: ['End-to-End Tests', 'End-to-End Tests Playwright']
types:
- completed

Expand All @@ -31,4 +29,4 @@ jobs:
with:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
label: '[Type] Flaky Test'
artifact-name: flaky-tests-report
artifact-name-prefix: flaky-tests-report

0 comments on commit eb61ff9

Please sign in to comment.