2023-12-09 21:49:47 +08:00
|
|
|
# Each PR will visual-regression diff that help to check code is work as expect.
|
|
|
|
|
|
|
|
name: 👀 Visual Regression Diff Build
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
2023-12-09 23:54:58 +08:00
|
|
|
branches: [master, feature]
|
2023-12-09 21:49:47 +08:00
|
|
|
types: [opened, synchronize, reopened]
|
|
|
|
|
|
|
|
# Cancel prev CI if new commit come
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
jobs:
|
2024-06-13 19:32:19 +08:00
|
|
|
############################ Generate Snapshot ###########################
|
|
|
|
visual-diff-snapshot:
|
|
|
|
name: visual-diff snapshot
|
|
|
|
strategy:
|
|
|
|
matrix:
|
2024-09-19 03:30:19 +08:00
|
|
|
shard: [1/2, 2/2]
|
2023-12-09 21:49:47 +08:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-08-18 00:23:19 +08:00
|
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: oven-sh/setup-bun@v2
|
|
|
|
- run: bun install
|
2023-12-09 21:49:47 +08:00
|
|
|
|
|
|
|
- name: generate image snapshots
|
|
|
|
id: test-image
|
|
|
|
run: |
|
|
|
|
node node_modules/puppeteer/install.mjs
|
2024-08-18 00:23:19 +08:00
|
|
|
bun run version
|
|
|
|
bun run test:image -- --shard=${{matrix.shard}}
|
2023-12-09 21:49:47 +08:00
|
|
|
env:
|
2024-09-19 03:30:19 +08:00
|
|
|
NODE_OPTIONS: --max_old_space_size=4096
|
2023-12-09 21:49:47 +08:00
|
|
|
|
2024-06-13 19:32:19 +08:00
|
|
|
- uses: actions/upload-artifact@v4
|
|
|
|
name: artifact snapshot
|
|
|
|
with:
|
|
|
|
name: snapshot-artifacts-${{ strategy.job-index }}
|
|
|
|
path: imageSnapshots/
|
|
|
|
retention-days: 2
|
|
|
|
|
|
|
|
############################### Diff Images ##############################
|
|
|
|
visual-diff-report:
|
|
|
|
name: visual-diff report
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: visual-diff-snapshot
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v4
|
2024-08-18 00:23:19 +08:00
|
|
|
- uses: oven-sh/setup-bun@v2
|
|
|
|
- run: bun install
|
2024-06-13 19:32:19 +08:00
|
|
|
|
|
|
|
- uses: actions/download-artifact@v4
|
|
|
|
with:
|
|
|
|
pattern: snapshot-artifacts-*
|
|
|
|
merge-multiple: true
|
|
|
|
path: imageSnapshots/
|
|
|
|
|
2023-12-09 21:49:47 +08:00
|
|
|
# Execute visual regression diff task and zip then
|
|
|
|
# output as visualRegressionReport.tar.gz
|
|
|
|
- name: visual regression diff
|
2023-12-19 11:23:53 +08:00
|
|
|
env:
|
|
|
|
EVENT_NUMBER: ${{ github.event.number }}
|
|
|
|
BASE_REF: ${{ github.base_ref }}
|
2023-12-09 21:49:47 +08:00
|
|
|
run: |
|
2024-08-18 00:23:19 +08:00
|
|
|
bun run test:visual-regression -- --pr-id=$EVENT_NUMBER --base-ref=$BASE_REF --max-workers=2
|
2023-12-09 21:49:47 +08:00
|
|
|
|
|
|
|
# Upload report in `visualRegressionReport`
|
|
|
|
- name: upload report artifact
|
2024-02-02 22:38:36 +08:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-12-18 14:25:40 +08:00
|
|
|
if: ${{ always() }}
|
2023-12-09 21:49:47 +08:00
|
|
|
with:
|
|
|
|
name: visual-regression-report
|
|
|
|
path: visualRegressionReport.tar.gz
|
|
|
|
|
|
|
|
# Upload git ref for next workflow `visual-regression-diff-finish` use
|
|
|
|
- name: Save persist key
|
|
|
|
if: ${{ always() }}
|
2023-12-18 14:25:40 +08:00
|
|
|
# should be pr id
|
2023-12-09 21:49:47 +08:00
|
|
|
run: echo ${{ github.event.number }} > ./visual-regression-pr-id.txt
|
|
|
|
|
|
|
|
- name: Upload persist key
|
|
|
|
if: ${{ always() }}
|
2024-02-02 22:38:36 +08:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-12-09 21:49:47 +08:00
|
|
|
with:
|
|
|
|
name: visual-regression-diff-ref
|
2024-08-03 20:24:15 +08:00
|
|
|
path: ./visual-regression-pr-id.txt
|