66 pull_request :
77 branches :
88 - main
9- - playwright-tests
109jobs :
11- run-playwright :
10+ setup-and-build :
1211 timeout-minutes : 15
1312 runs-on : ubuntu-latest
13+
14+ steps :
15+ - uses : actions/checkout@v4
16+
17+ - name : Set up Node.js with Caching
18+ uses : actions/setup-node@v4
19+ with :
20+ node-version : lts/*
21+ cache : " yarn"
22+
23+ - name : Install node dependencies
24+ # This will be fast on subsequent runs due to caching
25+ run : yarn --frozen-lockfile
26+
27+ - name : Set up Docker Buildx
28+ uses : docker/setup-buildx-action@v3
29+ - name : Create and Switch to Buildx Builder
30+ run : |
31+ docker buildx create --use --name mybuilder
32+ - name : Log in to GitHub Container Registry
33+ # You need to log in because the cache needs to be written to GHCR
34+ uses : docker/login-action@v3
35+ with :
36+ registry : ghcr.io
37+ username : ${{ github.actor }}
38+ password : ${{ secrets.GITHUB_TOKEN }}
39+
40+ - name : Build image and save as artifact (using ghcr for layered caching)
41+ # Build the application image once
42+ run : |
43+ CACHE_TAG=ghcr.io/${{ github.repository }}/playwright-cache:latest
44+ DOCKER_BUILDKIT=1 docker buildx build \
45+ --output type=docker,name=websites-content-system:latest,dest=app-image.tar \
46+ --cache-from type=registry,ref=$CACHE_TAG \
47+ --cache-to type=registry,ref=$CACHE_TAG,mode=max \
48+ .
49+
50+ - name : Upload application image artifact
51+ # The artifact is downloaded and loaded by the test jobs
52+ uses : actions/upload-artifact@v4
53+ with :
54+ name : app-image
55+ path : app-image.tar
56+ retention-days : 1
57+ run-playwright :
58+ needs : [setup-and-build]
59+ timeout-minutes : 60
60+ runs-on : ubuntu-latest
61+ strategy :
62+ fail-fast : false
63+ matrix :
64+ shardIndex : [1, 2, 3, 4]
65+ shardTotal : [4]
1466 services :
1567 redis :
1668 image : redis
@@ -35,10 +87,21 @@ jobs:
3587 --health-start-period 80s
3688 steps :
3789 - uses : actions/checkout@v4
38- - name : Install node dependencies
39- run : yarn
40- - name : Build image
41- run : DOCKER_BUILDKIT=1 docker build --tag websites-content-system .
90+ - name : Download application image artifact
91+ uses : actions/download-artifact@v4
92+ with :
93+ name : app-image
94+ path : /tmp/
95+
96+ - name : Load application image
97+ run : docker load -i /tmp/app-image.tar
98+ - name : Set up Node.js with Cache restore
99+ uses : actions/setup-node@v4
100+ with :
101+ node-version : lts/*
102+ cache : " yarn"
103+ - name : Restore and Prepare Dependencies
104+ run : yarn --frozen-lockfile
42105 - name : Run image
43106 env :
44107 DISABLE_SSO : True
@@ -80,16 +143,51 @@ jobs:
80143 --network host \
81144 websites-content-system & sleep 3
82145 curl --head --fail --retry-delay 1 --retry 50 --retry-connrefused http://localhost
83- - name : Install Playwright Browsers
84- run : npx playwright install --with-deps
146+
147+ - name : Run playwright image
148+ run :
docker run -d --add-host=hostmachine:host-gateway -p 3000:3000 --init --workdir /home/pwuser --user pwuser mcr.microsoft.com/playwright:v1.50.1-noble /bin/sh -c "npx -y [email protected] run-server --port 3000 --host 0.0.0.0" & sleep 60 85149 - name : Run Playwright tests
86150 env :
87151 JIRA_REPORTER_ID : ${{ secrets.JIRA_REPORTER_ID }}
88152 run : |
89- JIRA_REPORTER_ID="$JIRA_REPORTER_ID" yarn playwright test
90- - uses : actions/upload-artifact@v4
91- if : always()
153+ PW_TEST_CONNECT_WS_ENDPOINT=ws://127.0.0.1:3000/ JIRA_REPORTER_ID="$JIRA_REPORTER_ID" BASE_URL=http://hostmachine PORT=80 yarn playwright test --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --reporter=blob
154+
155+ - name : Upload blob report to GitHub Actions Artifacts
156+ if : ${{ !cancelled() }}
157+ uses : actions/upload-artifact@v4
158+ with :
159+ name : blob-report-${{ matrix.shardIndex }}
160+ path : blob-report
161+ retention-days : 1
162+
163+ merge-reports :
164+ # Merge reports after playwright-tests, even if some shards have failed
165+ if : ${{ !cancelled() }}
166+ needs : [run-playwright]
167+
168+ runs-on : ubuntu-latest
169+ steps :
170+ - uses : actions/checkout@v4
171+ - uses : actions/setup-node@v4
172+ with :
173+ node-version : lts/*
174+ cache : " yarn"
175+ - name : Install dependencies
176+ run : yarn --frozen-lockfile
177+
178+ - name : Download blob reports from GitHub Actions Artifacts
179+ uses : actions/download-artifact@v4
180+ with :
181+ path : all-blob-reports
182+ pattern : blob-report-*
183+ merge-multiple : true
184+
185+ - name : Merge into HTML Report
186+ run : npx playwright merge-reports --reporter html ./all-blob-reports
187+
188+ - name : Upload HTML report
189+ uses : actions/upload-artifact@v4
92190 with :
93- name : playwright -report
94- path : playwright-report/
95- retention-days : 30
191+ name : html -report--attempt-${{ github.run_attempt }}
192+ path : playwright-report
193+ retention-days : 14
0 commit comments