Skip to content

PRD - BackstopJS on latest main #39

PRD - BackstopJS on latest main

PRD - BackstopJS on latest main #39

Workflow file for this run

name: 🙈 BackstopJS
run-name: "${{ github.ref_name == 'main' && 'PRD' || 'STG' }} - BackstopJS ${{ github.event_name == 'pull_request' && format('PR #{0}: {1} on ', github.event.pull_request.number, github.event.pull_request.title) || format('on latest {0}', github.ref_name) }}"
on:
workflow_call:
secrets:
GH_WORKFLOW_TOKEN:
required: true
AWS_S3_BUCKET_REPORTS:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_SECRET_ACCESS_KEY:
required: true
AWS_REGION:
required: true
REPORTS_DISTRIBUTION:
required: true
workflow_dispatch:
permissions:
checks: write
contents: write
pull-requests: write
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
backstop:
name: 🙈 BackstopJS
runs-on: ubuntu-latest
concurrency:
group: backstop
cancel-in-progress: true
environment:
name: ${{ github.ref_name == 'main' && 'prd' || 'stg' }}
env:
DEPLOY_ENV: ${{ github.ref_name == 'main' && 'production' || 'staging' }}
steps:
- name: 𐂷 Checkout
uses: actions/checkout@v4
with:
repository: dgrebb/dgrebb.com
ref: ${{ github.ref }}
token: ${{ github.token }}
sparse-checkout: |
_ci
- name: ⬢ Setup Node & Cache
uses: actions/setup-node@v4
with:
node-version: "20.9.0"
cache: "npm"
cache-dependency-path: |
_ci/backstop/package.json
_ci/backstop/package-lock.json
_ci/backstop/node_modules
- name: ↧ Install & Patch
run: cd _ci/backstop && npm ci && npx playwright install --with-deps
- name: 🔥 Warmup Cache
run: ./_ci/_utils/warmup.sh ${{ github.ref_name == 'main' && 'prd' || 'stg' }}
- name: 👀 Testing Bitmaps
id: backstop
continue-on-error: true
run: cd _ci/backstop && ENV=$DEPLOY_ENV npm run test.gh
- name: Summarize Failures
if: steps.backstop.outcome != 'success'
env:
REPORT_PATH: ${{ github.ref_name == 'main' && 'prd' || 'stg' }}
run: |
cd _ci/backstop
echo "# Backstop Summary" >> $GITHUB_STEP_SUMMARY
echo "## 📋 <a href=\"http://${{ vars.REPORTS_DOMAIN }}/backstop/html_report/gh-$REPORT_PATH/\" target=\"_blank\">View Report</a>" >> $GITHUB_STEP_SUMMARY
FAIL_TABLE=$(./_utils/parse-report.sh ${{ vars.REPORTS_DOMAIN }} $REPORT_PATH)
echo $FAIL_TABLE >> $GITHUB_STEP_SUMMARY
- name: Summarize Success
if: steps.backstop.outcome == 'success'
env:
REPORT_PATH: ${{ github.ref_name == 'main' && 'prd' || 'stg' }}
run: |
echo "# Backstop Summary" >> $GITHUB_STEP_SUMMARY
echo "## 📋 <a href=\"http://${{ vars.REPORTS_DOMAIN }}/backstop/html_report/gh-$REPORT_PATH/\" target=\"_blank\">View Report</a>" >> $GITHUB_STEP_SUMMARY
echo "## 100% Passing Visual Regresstion!" >> $GITHUB_STEP_SUMMARY
echo "### 🥳 Congratulations!" >> $GITHUB_STEP_SUMMARY
- name: ⬆ Uploading Test Report
id: upload
if: always()
uses: jakejarvis/s3-sync-action@master
with:
args: --acl public-read --follow-symlinks --delete --cache-control max-age=2853200,public
env:
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET_REPORTS }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: "_ci/backstop/bd/"
DEST_DIR: "backstop"
- name: ∅ Invalidate CloudFront
uses: chetan/invalidate-cloudfront-action@v2
env:
DISTRIBUTION: ${{ secrets.REPORTS_DISTRIBUTION }}
PATHS: "/*"
AWS_REGION: ${{ secrets.AWS_REGION }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: 🛟 Saving Artifact
if: steps.backstop.outcome != 'success'
env:
REPORT_PATH: ${{ github.ref_name == 'main' && 'prd' || 'stg' }}
uses: actions/upload-artifact@v3
with:
name: backstop-report
retention-days: 3
path: _ci/backstop/bd/bitmaps_test/gh-${{ env.REPORT_PATH }}