1
+ name : Testing for visual regression on old theme
2
+
3
+ # Run the workflow when code is pushed or when a pull request is created
4
+ on :
5
+ push :
6
+ branches :
7
+ - ' **'
8
+ pull_request :
9
+ branches :
10
+ - main
11
+
12
+ jobs :
13
+ playwright :
14
+ name : Run Playwright
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ # Checkout the repository so the workflow has access to the code
18
+ - name : Checkout code
19
+ uses : actions/checkout@v3
20
+ - name : Install dependencies
21
+ run : cd tests && npm ci
22
+ - name : Setup Hugo
23
+ uses : peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0
24
+ with :
25
+ hugo-version : " 0.134.2"
26
+ extended : true
27
+ - name : Install Playwright browsers
28
+ run : npx playwright install --with-deps
29
+ - name : Run Playwright tests
30
+ id : test-visual
31
+ run : |
32
+ make tests | tee output.log
33
+ if grep -q -e "Error: A snapshot doesn't exist at" -e "Screenshot comparison failed" output.log; then
34
+ echo "Playwright tests failed due to a snapshot issue."
35
+ echo "SNAPSHOT_DIFFERENCES=true" >> $GITHUB_ENV
36
+ exit 1
37
+ elif grep -q "failed" output.log; then
38
+ echo "Playwright tests failed due to a non-snapshot issue."
39
+ exit 1
40
+ fi
41
+ - uses : actions/upload-artifact@v4
42
+ id : artifact-upload
43
+ if : ${{ !cancelled() && failure() && steps.test-visual.conclusion == 'failure' }}
44
+ with :
45
+ name : playwright-report
46
+ path : tests/playwright-report/
47
+ retention-days : 3
48
+ - name : Comment on PR with Playwright report
49
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
50
+ if : ${{ failure() && env.SNAPSHOT_DIFFERENCES == 'true' }}
51
+ with :
52
+ script : |
53
+ const body = `### <span aria-hidden="true">❌</span> Playwright visual snapshot differences were detected.
54
+
55
+ View the [Playwright report](${{ steps.artifact-upload.outputs.artifact-url }})
56
+ **To approve the snapshot changes and update the snapshots, please comment:** /approve-snapshots`;
57
+
58
+ await github.rest.issues.createComment({
59
+ issue_number: context.issue.number,
60
+ owner: context.repo.owner,
61
+ repo: context.repo.repo,
62
+ body: body,
63
+ });
64
+
65
+ # - name: Update the screenshots based on Ubuntu env on GH
66
+ # id: test-visual-update
67
+ # if: ${{ failure() && steps.test-visual.conclusion == 'failure' }}
68
+ # run: make tests-update-screenshots
69
+ # - name: Upload updated Playwright screenshots
70
+ # uses: actions/upload-artifact@v4
71
+ # if: ${{ failure() && steps.test-visual-update.conclusion == 'success' }}
72
+ # with:
73
+ # name: playwright-screenshots-updated
74
+ # path: tests/src/__screenshots__/**/*.png
75
+ # retention-days: 3
0 commit comments