STG - BackstopJS on latest develop #48
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: 🙈 BackstopJS | |
run-name: "${{ inputs.env == 'prd' && '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: | |
inputs: | |
env: | |
description: "Target deployment environment." | |
type: string | |
required: true | |
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 }} | |
NODE_VERSION: 20 | |
jobs: | |
backstop: | |
name: 🙈 BackstopJS | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ inputs.env }} | |
url: "https://${{ vars.WWW_DOMAIN }}" | |
concurrency: | |
group: backstop | |
cancel-in-progress: false | |
env: | |
DEPLOY_ENV: ${{ inputs.env }} | |
steps: | |
- name: 𐂷 Checkout | |
uses: actions/checkout@v4 | |
with: | |
repository: dgrebb/dgrebb.com | |
ref: ${{ github.ref }} | |
token: ${{ github.token }} | |
fetch-depth: 1 | |
sparse-checkout: | | |
.github/actions | |
_ci | |
- name: 🛢 Install Dependencies | |
uses: ./.github/actions/install-cache-deps | |
with: | |
WORKSPACE_ROOT: _ci/backstop | |
BROWSER_BINARIES: true | |
- name: 🔥 Warmup Cache | |
run: ./_ci/_utils/warmup.sh ${{ inputs.env }} | |
- name: 👀 Testing Bitmaps | |
id: backstop | |
continue-on-error: true | |
run: cd _ci/backstop && pnpm exec playwright install && ENV=$DEPLOY_ENV pnpm test.gh | |
- name: Summarize Failures | |
if: steps.backstop.outcome != 'success' | |
env: | |
REPORT_PATH: ${{ inputs.env }} | |
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: ${{ inputs.env }} | |
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: ${{ inputs.env }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: backstop-report | |
retention-days: 3 | |
path: _ci/backstop/bd/bitmaps_test/gh-${{ env.REPORT_PATH }} |