2023-11-27 11:22:14 +08:00
|
|
|
# Each `push on master` will persist image-snapshots that used as compare target in visual regression.
|
|
|
|
|
2023-11-28 19:42:35 +08:00
|
|
|
name: 👁️ Visual Regression Persist Start
|
2023-11-27 11:22:14 +08:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
2023-12-14 17:02:31 +08:00
|
|
|
- feature
|
2023-11-27 11:22:14 +08:00
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: read
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
# Prepare node modules. Reuse cache if available
|
|
|
|
setup:
|
|
|
|
name: prepare node_modules
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- name: checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: cache package-lock.json
|
2024-02-01 18:20:41 +08:00
|
|
|
uses: actions/cache@v4
|
2023-11-27 11:22:14 +08:00
|
|
|
with:
|
|
|
|
path: package-temp-dir
|
|
|
|
key: lock-${{ github.sha }}
|
|
|
|
|
|
|
|
- name: create package-lock.json
|
|
|
|
run: npm i --package-lock-only --ignore-scripts
|
|
|
|
|
|
|
|
- name: hack for single file
|
|
|
|
run: |
|
|
|
|
if [ ! -d "package-temp-dir" ]; then
|
|
|
|
mkdir package-temp-dir
|
|
|
|
fi
|
|
|
|
cp package-lock.json package-temp-dir
|
|
|
|
- name: cache node_modules
|
|
|
|
id: node_modules_cache_id
|
2024-02-01 18:20:41 +08:00
|
|
|
uses: actions/cache@v4
|
2023-11-27 11:22:14 +08:00
|
|
|
with:
|
|
|
|
path: node_modules
|
|
|
|
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
|
|
|
|
|
|
|
|
- name: install
|
|
|
|
if: steps.node_modules_cache_id.outputs.cache-hit != 'true'
|
|
|
|
run: npm ci
|
|
|
|
|
|
|
|
test-image:
|
|
|
|
name: test image
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
needs: setup
|
|
|
|
steps:
|
|
|
|
- name: checkout
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
- name: restore cache from package-lock.json
|
2024-02-01 18:20:41 +08:00
|
|
|
uses: actions/cache@v4
|
2023-11-27 11:22:14 +08:00
|
|
|
with:
|
|
|
|
path: package-temp-dir
|
|
|
|
key: lock-${{ github.sha }}
|
|
|
|
|
|
|
|
- name: restore cache from node_modules
|
2024-02-01 18:20:41 +08:00
|
|
|
uses: actions/cache@v4
|
2023-11-27 11:22:14 +08:00
|
|
|
with:
|
|
|
|
path: node_modules
|
|
|
|
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
|
|
|
|
|
|
|
|
- name: generate image snapshots
|
2023-11-27 15:48:42 +08:00
|
|
|
run: |
|
2023-11-28 19:42:35 +08:00
|
|
|
node node_modules/puppeteer/install.mjs
|
2023-11-27 15:48:42 +08:00
|
|
|
npm run version
|
|
|
|
npm run test-image
|
2023-11-28 19:42:35 +08:00
|
|
|
tar -czvf imageSnapshots.tar.gz imageSnapshots/*
|
2023-11-27 11:22:14 +08:00
|
|
|
env:
|
|
|
|
NODE_OPTIONS: "--max_old_space_size=4096"
|
|
|
|
|
|
|
|
# Upload `imageSnapshots` on master
|
|
|
|
- name: upload report artifact
|
2024-02-02 22:38:36 +08:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-11-27 11:22:14 +08:00
|
|
|
with:
|
|
|
|
name: image-snapshots
|
2023-11-28 19:42:35 +08:00
|
|
|
path: imageSnapshots.tar.gz
|
2023-11-27 11:22:14 +08:00
|
|
|
|
|
|
|
# Upload git ref for next workflow `visual-regression-persist-finish` use
|
|
|
|
- name: Save persist key
|
|
|
|
if: ${{ always() }}
|
|
|
|
run: echo ${{ github.sha }} > ./visual-regression-ref.txt
|
|
|
|
|
|
|
|
- name: Upload persist key
|
|
|
|
if: ${{ always() }}
|
2024-02-02 22:38:36 +08:00
|
|
|
uses: actions/upload-artifact@v4
|
2023-11-27 11:22:14 +08:00
|
|
|
with:
|
2023-12-15 12:33:45 +08:00
|
|
|
name: visual-regression-ref
|
2023-11-27 11:22:14 +08:00
|
|
|
path: ./visual-regression-ref.txt
|