-
Notifications
You must be signed in to change notification settings - Fork 5
95 lines (91 loc) · 4.1 KB
/
cypress.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
name: Cypress visual regression tests
on:
push:
branches: [ "master", "redesign-2024" ]
pull_request:
branches: [ "master", "redesign-2024" ]
jobs:
cypress-run:
runs-on: ubuntu-22.04
container:
# This must stay in sync with the image used by the test-{site}-visual scripts in package.json.
image: cypress/browsers:node-20.14.0-chrome-125.0.6422.141-1-ff-126.0.1-edge-125.0.2535.85-1
options: --user 0
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Cypress run (Ada)
uses: cypress-io/github-action@v6
with:
component: true
browser: chrome
env:
CYPRESS_SITE: ada
- name: Cypress run (Physics)
if: ${{ success() || failure() }}
uses: cypress-io/github-action@v6
with:
component: true
browser: chrome
env:
CYPRESS_SITE: phy
# Temporary: ignore failures during redesign
continue-on-error: true
- name: VRT update - create or update branch
id: cypress-create-branch
if: ${{ failure() }}
run: |
# Temporary hack to mitigate https://github.com/FRSOURCE/cypress-plugin-visual-regression-diff/issues/322
apt update && apt install exiftool -y
echo "%Image::ExifTool::UserDefined = ('Image::ExifTool::PNG::TextualData' => {FRSOURCE_CPVRD_V => { }});" > ~/.ExifTool_config
git config --global --add safe.directory $(pwd)
# Create or update VRT branch
target_ref=${{ github.head_ref || github.ref_name }}
update_branch_name=vrt/$target_ref
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
find ./src/test/pages/__image_snapshots__ -type f -name "*.actual.png" -exec bash -c 'exiftool -overwrite_original -FRSOURCE_CPVRD_V="1" "$1"; mv "$1" "${1/.actual./.}"' shell {} \;
git fetch origin $target_ref
git checkout -B $update_branch_name origin/$target_ref
git commit -am "Update VRT baselines"
git push --set-upstream origin $update_branch_name --force
echo "TARGET_REF=$target_ref" >> "$GITHUB_ENV"
echo "UPDATE_BRANCH_NAME=$update_branch_name" >> "$GITHUB_ENV"
- name: VRT update - create PR if required
id: cypress-create-pr
if: ${{ failure() && steps.cypress-create-branch.outcome == 'success' }}
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const { repo, owner } = context.repo;
const pulls = await github.rest.pulls.list({
owner: owner,
repo: repo,
head: "${{ env.UPDATE_BRANCH_NAME }}",
base: "${{ env.TARGET_REF }}",
state: 'open',
});
if (pulls.data.length == 0) {
const pr = await github.rest.pulls.create({
title: '[VRT] Update baselines for ${{ env.TARGET_REF }}',
owner: owner,
repo: repo,
head: "${{ env.UPDATE_BRANCH_NAME }}",
base: "${{ env.TARGET_REF }}",
body: 'Updates VRT baselines'
});
return pr.data.html_url;
} else {
return pulls.data[0].html_url;
};
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: VRT update - write job summary
if: ${{ failure() && steps.cypress-create-pr.outcome == 'success' }}
run: |
echo '## 👀 Visual Regression Test updates' >> $GITHUB_STEP_SUMMARY
echo 'This run failed due to visual differences compared to our baseline images. A PR with new baseline images has been generated. Please review it [here](${{ steps.cypress-create-pr.outputs.result }}) and merge it if the differences are expected.' >> $GITHUB_STEP_SUMMARY
echo 'See [this wiki page](https://github.com/isaacphysics/isaac-wiki/wiki/Visual-regression-tests) for more information and troubleshooting steps.' >> $GITHUB_STEP_SUMMARY