-
Notifications
You must be signed in to change notification settings - Fork 2
113 lines (104 loc) · 4.43 KB
/
common.playwright.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Playwright Tests
on:
workflow_call:
inputs:
working-directory:
type: string
description: "The working directory for the job, e.g. apps/dolly-frontend (without leading/trailing slash)."
required: true
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 ]
shardTotal: [ 3 ]
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
registry-url: https://npm.pkg.github.com/
scope: "@navikt"
- name: Install dependencies
working-directory: ${{ inputs.working-directory }}/src/main/js
run: npm ci
- name: Install Playwright Browsers
working-directory: ${{ inputs.working-directory }}/src/main/js
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 }}
- 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