Follow us on GitHub, GitLab or Bluesky! #403
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: Backstop.js regression testing | |
on: | |
pull_request: | |
permissions: # https://github.com/EnricoMi/publish-unit-test-result-action/issues/161#issuecomment-905921434 | |
contents: read | |
issues: write | |
pull-requests: write | |
checks: write | |
jobs: | |
backstop: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 1 | |
matrix: | |
ref: | |
- ${{ github.base_ref }} | |
- ${{ github.head_ref }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
ref: ${{ matrix.ref }} | |
- name: Compute variables | |
# See https://docs.github.com/en/actions/reference/workflow-commands-for-github-actions#environment-files | |
run: | | |
exec >> $GITHUB_ENV | |
if [ "$current_ref" = "$base_ref" ]; then | |
echo backstop_verb=reference | |
else | |
echo backstop_verb=test | |
fi | |
env: | |
current_ref: ${{ matrix.ref }} | |
base_ref: ${{ github.base_ref }} | |
- uses: actions/setup-node@v4 | |
with: | |
cache: yarn | |
node-version: 18 | |
# Work around https://github.com/yarnpkg/yarn/issues/4890 | |
- name: Install dependencies | |
run: yarn --frozen-lockfile --network-timeout 1000000 | |
- if: ${{ env.backstop_verb == 'test' }} | |
name: Download baseline Backstop results from previous run | |
uses: actions/download-artifact@v4 | |
with: | |
name: backstop-report | |
path: tests/backstop | |
- name: Run Backstop | |
run: | | |
yarn start & | |
for retry in $(seq 1 6); do if ! curl --silent -o /dev/null http://localhost:3000/ ; then sleep 10; fi; done | |
node scripts/make_backstop_json.js | |
npx backstop ${{ env.backstop_verb }} --config=build/backstop.json || true | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: backstop-report | |
path: tests/backstop | |
overwrite: true | |
- if: ${{ env.backstop_verb == 'test' }} | |
uses: EnricoMi/publish-unit-test-result-action@v2 | |
with: | |
fail_on: nothing | |
files: tests/backstop/ci_report/xunit.xml |