diff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.yml index 008fe4e89..c86aea378 100644 --- a/.github/workflows/playwright.yml +++ b/.github/workflows/playwright.yml @@ -39,14 +39,20 @@ jobs: if: ${{ !cancelled() }} with: filepath: ./playwright-errors/errors.md - - uses: initdc/upload-artifact@baac12d9f85834b2f8baa26a08ff97c27cc82cd9 + - name: Get trace files + id: get-trace-files + if: ${{ !cancelled() }} + run: | + IDS=$(cat ./playwright-errors/testIds.json) + TRACES=$(cat ./playwright-errors/traceFiles.json) + echo "testIds=$IDS" >> $GITHUB_OUTPUT + echo "traceFiles=$TRACES" >> $GITHUB_OUTPUT + - uses: BToersche/upload-artifact@5442a4e8a3867a1c14be1ee3a04c4f47b261d632 id: upload-traces if: ${{ !cancelled() }} with: - artifact-per-file: true - artifact-name-rule: ${name}${ext} - path: | - test-results/*/trace.zip + name: '${{ steps.get-trace-files.outputs.testIds }}' + path: '${{ steps.get-trace-files.outputs.traceFiles }}' retention-days: 1 - uses: actions/upload-artifact@v4 if: ${{ !cancelled() }} diff --git a/e2e/config/reporter.ts b/e2e/config/reporter.ts index 050d9b3f4..6f0783300 100644 --- a/e2e/config/reporter.ts +++ b/e2e/config/reporter.ts @@ -11,11 +11,15 @@ const ansiRegex = new RegExp( '([\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d] class MyReporter implements Reporter { outputFolder: string; testResults: Array; + testIds: Array; + traceFiles: Array; constructor() { this.outputFolder = 'playwright-errors' this.cleanupFolder() this.testResults = [] + this.testIds = [] + this.traceFiles = [] } stripAnsiEscapes( str: string ): string { @@ -67,6 +71,8 @@ class MyReporter implements Reporter { } this.testResults.push( testResult ) + this.testIds.push( test.id ) + this.traceFiles.push( result.attachments.find( attachment => attachment.name === 'trace' ).path ) } } @@ -80,15 +86,25 @@ class MyReporter implements Reporter { // Write the collected results to a JSON file const reportPath = path.join( folderPath, 'errors.md' ) let reportContent = '' + + const testIdsPath = path.join( folderPath, 'testIds.json' ) + let testIdsContent = '' + + const traceFilesPath = path.join( folderPath, 'traceFiles.json' ) + let traceFilesContent = '' if ( this.testResults.length ) { reportContent += `## Failed Tests ${ this.testResults.join( '' ) }` reportContent = this.stripAnsiEscapes( reportContent ) + testIdsContent = JSON.stringify( this.testIds, null, 2 ) + traceFilesContent = JSON.stringify( this.traceFiles, null, 2 ) } fs.writeFileSync( reportPath, reportContent ) + fs.writeFileSync( testIdsPath, testIdsContent ) + fs.writeFileSync( traceFilesPath, traceFilesContent ) } } export default MyReporter