Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/playwright report on fail #3793

Merged
merged 18 commits into from
Mar 12, 2025
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
c9db0d2
Enhance Playwright test configuration and reporting for easier troubl…
stigus Mar 11, 2025
a1ccb05
- Endret beskrivelse for bestilling, slik at importerte personer kan …
stigus Mar 11, 2025
e89e4a1
- Endret beskrivelse for bestilling, slik at importerte personer kan …
stigus Mar 11, 2025
61b8175
- Endret beskrivelse for bestilling, slik at importerte personer kan …
stigus Mar 11, 2025
2ee628b
- Endret beskrivelse for bestilling, slik at importerte personer kan …
stigus Mar 11, 2025
3bf6c46
- Endret beskrivelse for bestilling, slik at importerte personer kan …
stigus Mar 11, 2025
3687da6
Enhance Playwright test configuration and reporting for easier troubl…
stigus Mar 11, 2025
fec5507
- Endret beskrivelse for bestilling, slik at importerte personer kan …
stigus Mar 11, 2025
acf9838
- Endret beskrivelse for bestilling, slik at importerte personer kan …
stigus Mar 11, 2025
8479f66
- Endret beskrivelse for bestilling, slik at importerte personer kan …
stigus Mar 11, 2025
a48245e
Se om project_id trengs, eller om den er deprecated i cdn-upload
stigus Mar 11, 2025
c0b4edb
Fixed failing test
stigus Mar 11, 2025
23819bc
Mer intuitiv permission handling i workflow etter kommentar
stigus Mar 12, 2025
98b5b82
Tester fix
stigus Mar 12, 2025
c12e408
Tester fix v2
stigus Mar 12, 2025
a9d7e56
Merge branch 'master' into feature/playwright-report-on-fail
stigus Mar 12, 2025
23f34f9
Tester deploy backend
stigus Mar 12, 2025
dac3a1c
Merge branch 'master' into feature/playwright-report-on-fail
stigus Mar 12, 2025
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
9 changes: 9 additions & 0 deletions .github/workflows/app.dolly-frontend.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: dolly-frontend

permissions:
contents: read
id-token: write
packages: write

on:
push:
paths:
Expand All @@ -21,6 +26,10 @@ jobs:
uses: ./.github/workflows/common.playwright.yml
with:
working-directory: "apps/dolly-frontend"
permissions:
contents: read
id-token: write
packages: write
secrets:
READER_TOKEN: ${{ secrets.READER_TOKEN }}

Expand Down
81 changes: 78 additions & 3 deletions .github/workflows/common.playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ on:
secrets:
READER_TOKEN:
required: true

permissions:
contents: read
id-token: write
packages: write

jobs:
playwright-tests:
timeout-minutes: 15
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
shardIndex: [ 1, 2, 3, 4, 5 ]
shardTotal: [ 5 ]
shardIndex: [ 1, 2, 3 ]
shardTotal: [ 3 ]
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
steps:
Expand All @@ -35,4 +41,73 @@ jobs:
run: npx playwright install --with-deps
- name: Run Playwright tests
working-directory: ${{ inputs.working-directory }}/src/main/js
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
run: npx playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }}
- name: Upload blob report to GitHub Actions Artifacts
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v4
with:
name: blob-report-${{ matrix.shardIndex }}
path: ${{ inputs.working-directory }}/src/main/js/blob-report
retention-days: 1

merge-reports:
if: ${{ !cancelled() }}
needs: [ playwright-tests ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.x

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v4
with:
path: ${{ inputs.working-directory }}/src/main/js/all-blob-reports
pattern: blob-report-*
merge-multiple: true

- name: Merge into HTML Report
working-directory: ${{ inputs.working-directory }}/src/main/js
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: Upload HTML report
uses: actions/upload-artifact@v4
with:
name: html-report--attempt-${{ github.run_attempt }}
path: ${{ inputs.working-directory }}/src/main/js/playwright-report
retention-days: 14

- name: Upload HTML report to CDN
uses: nais/deploy/actions/cdn-upload/v2@master
with:
team: dolly
source: ${{ inputs.working-directory }}/src/main/js/playwright-report
destination: /${{ github.repository }}/${{ github.run_number }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
# project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}

- name: Merge to json report
working-directory: ${{ inputs.working-directory }}/src/main/js
run: npx playwright merge-reports --reporter json ./all-blob-reports > playwright-report/report.json

- name: Make fancy GHA Summary
working-directory: ${{ inputs.working-directory }}/src/main/js
run: |
total_tests=$(jq '.stats.expected + .stats.unexpected' playwright-report/report.json)
passed_tests=$(jq '.stats.expected' playwright-report/report.json)
failed_tests=$(jq '.stats.unexpected' playwright-report/report.json)
failed_test_info=$(jq -r '.suites[].specs[] | select(.ok == false) | "\(.title) (\(.file), \(.tests[].projectName))"' playwright-report/report.json)
echo "## Playwright Test Report Summary" >> $GITHUB_STEP_SUMMARY
echo "Total tests: $total_tests ✅" >> $GITHUB_STEP_SUMMARY
echo "Passed tests: $passed_tests ✅" >> $GITHUB_STEP_SUMMARY
if [ "$failed_tests" -gt 0 ]; then
echo "Failed tests: $failed_tests ❌" >> $GITHUB_STEP_SUMMARY
echo "### Failed Tests:" >> $GITHUB_STEP_SUMMARY
while IFS= read -r test; do
echo "- $test ❌" >> $GITHUB_STEP_SUMMARY
done <<< "$failed_test_info"
else
echo "Failed tests: $failed_tests 🔹" >> $GITHUB_STEP_SUMMARY
fi
echo "Se hele rapporten [her](https://cdn.nav.no/dolly/${{ github.repository }}/${{ github.run_number }}/playwright-report/index.html)." >> $GITHUB_STEP_SUMMARY
15 changes: 13 additions & 2 deletions apps/dolly-frontend/src/main/js/playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,22 @@ export default defineConfig({
// One worker on CI to make tests more stable
workers: process.env.CI ? 1 : 3,

reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
reporter: [
[
process.env.CI ? 'blob' : 'html',
{
attachments: true,
},
],
],

use: {
baseURL: 'http://localhost:5678/',
trace: 'on-first-retry',
screenshot: {
mode: 'on',
fullPage: true,
},
},

/* Configure projects for major browsers */
Expand Down