-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (113 loc) · 4.15 KB
/
test-backstop.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
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 }}