Skip to content

Commit 32eccfd

Browse files
authored
ci: make puppeteer works when reusing node_modules (ant-design#46107)
* feat: update * feat: add options as root user * chore: update * chore: update * feat: move puppeteer into node_modules cache * chore: update * fix: update * fix: typo for push * chore: cleanup * fix: make persist finish works * chore: test tar speed * chore: debug tar files * fix: clone firstly * fix: clone with token * chore: local passed * fix: commit not cm * fix: git config --local * chore: clean up * chore: update * fix: replace token to user_id
1 parent 082975e commit 32eccfd

File tree

4 files changed

+27
-21
lines changed

4 files changed

+27
-21
lines changed

.github/workflows/visual-regression-persist-finish.yml

+21-15
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Each `push on master` will persist image-snapshots that used as compare target in visual regression.
22

3-
name: Visual Regression Persist Finish
3+
name: 👁️ Visual Regression Persist Finish
44

55
on:
66
workflow_run:
7-
workflows: ["name: Visual Regression Persist Start"]
7+
workflows: ["👁️ Visual Regression Persist Start"]
88
types:
99
- completed
1010

@@ -76,32 +76,38 @@ jobs:
7676
workflow: ${{ github.event.workflow_run.workflow_id }}
7777
run_id: ${{ github.event.workflow_run.id }}
7878
name: image-snapshots
79-
path: imageSnapshots
79+
path: ./
8080

8181
- name: Persist to Snapshot Repo
82-
if: github.event.pull_request.head.ref == 'master'
82+
if: github.ref_name == 'master'
8383
id: persist
8484
continue-on-error: true
8585
env:
8686
GITHUB_TOKEN: ${{ secrets.ANTD_IMAGE_SNAP_REPO_TOKEN }}
8787
# should push to snapshot repo firstly
8888
# push the single folder to the repo
8989
run: |
90-
git config user.name "Antd Visual-Regression Bot"
91-
git config user.email "<>"
90+
git clone https://[email protected]/ant-design/antd-image-snapshots.git
9291
93-
git clone [email protected]:ant-design/antd-image-snapshots.git
94-
rm antd-image-snapshots/*.txt
95-
rm -rf antd-image-snapshots/imageSnapshots
92+
echo "✅ Clone Finished"
9693
94+
rm antd-image-snapshots/*.txt
9795
mv visual-regression-ref.txt antd-image-snapshots/
98-
mv ./imageSnapshots antd-image-snapshots/
96+
97+
rm -rf antd-image-snapshots/imageSnapshots/*
98+
tar -xzvf imageSnapshots.tar.gz -C antd-image-snapshots/imageSnapshots
99+
100+
echo "✅ Changes Finished"
99101
100102
cd antd-image-snapshots
101-
git add .
102-
git cm -m 'feat: update snapshot from ${{steps.visuall-regression.outputs.id}}'
103103
104-
git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | \
105-
xargs -L1 git config --unset-all
104+
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
105+
git config --local user.name "github-actions[bot]"
106+
107+
git commit -a -m 'feat: update snapshot from ${{steps.visuall-regression.outputs.id}}'
108+
109+
echo "✅ Commit Finished"
110+
111+
git push --prune https://vaugsX:[email protected]/ant-design/antd-image-snapshots.git +refs/remotes/origin/*:refs/heads/*
106112
107-
git push --prune https://token:[email protected]/ant-design/antd-image-snapshots.git +refs/remotes/origin/*:refs/heads/* +refs/tags/*:refs/tags/*
113+
echo "✅ Push Finished"

.github/workflows/visual-regression-persist-start.yml

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Each `push on master` will persist image-snapshots that used as compare target in visual regression.
22

3-
name: Visual Regression Persist Start
3+
name: 👁️ Visual Regression Persist Start
44

55
on:
66
push:
@@ -15,7 +15,6 @@ jobs:
1515
setup:
1616
name: prepare node_modules
1717
runs-on: ubuntu-latest
18-
container: ghcr.io/puppeteer/puppeteer:21.5.2
1918
steps:
2019
- name: checkout
2120
uses: actions/checkout@v4
@@ -67,20 +66,20 @@ jobs:
6766
key: node_modules-${{ hashFiles('**/package-temp-dir/package-lock.json') }}
6867

6968
- name: generate image snapshots
70-
id: site
7169
run: |
70+
node node_modules/puppeteer/install.mjs
7271
npm run version
7372
npm run test-image
73+
tar -czvf imageSnapshots.tar.gz imageSnapshots/*
7474
env:
75-
SITE_ENV: development
7675
NODE_OPTIONS: "--max_old_space_size=4096"
7776

7877
# Upload `imageSnapshots` on master
7978
- name: upload report artifact
8079
uses: actions/upload-artifact@v3
8180
with:
8281
name: image-snapshots
83-
path: imageSnapshots/
82+
path: imageSnapshots.tar.gz
8483

8584
# Upload git ref for next workflow `visual-regression-persist-finish` use
8685
- name: Save persist key

jest-puppeteer.config.js

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// jest-puppeteer.config.js
22
module.exports = {
33
launch: {
4+
ignoreDefaultArgs: ['--disable-extensions'],
45
args: [
56
// Required for Docker version of Puppeteer
67
'--no-sandbox',

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@
274274
"pretty-format": "^29.0.0",
275275
"prismjs": "^1.29.0",
276276
"progress": "^2.0.3",
277-
"puppeteer": "^21.1.1",
277+
"puppeteer": "^21.5.2",
278278
"qs": "^6.10.1",
279279
"rc-footer": "^0.6.8",
280280
"rc-tween-one": "^3.0.3",

0 commit comments

Comments
 (0)