Support n-dimensional coord Qs #921
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cypress visual regression tests | |
on: | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
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 | |
- 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 | |