@@ -15,6 +15,75 @@ concurrency:
1515
1616jobs :
1717 update-snapshots :
18+ runs-on : ubuntu-latest
19+ strategy :
20+ fail-fast : false
21+ matrix :
22+ include :
23+ - name : components-unit
24+ command : pnpm --filter @public-ui/components test:update:unit
25+ type : unit
26+ - name : hydrate-server-unit
27+ command : pnpm --filter @public-ui/hydrate-server test:update:unit
28+ type : unit
29+ - name : hydrate-unit
30+ command : pnpm --filter @public-ui/hydrate test:update:unit
31+ type : unit
32+ - name : theme-default-e2e
33+ command : pnpm --filter @public-ui/theme-default test:update:e2e
34+ type : e2e
35+ - name : theme-kern-e2e
36+ command : pnpm --filter @public-ui/theme-kern test:update:e2e
37+ type : e2e
38+ - name : test-tag-name-transformer-e2e
39+ command : pnpm --filter @public-ui/test-tag-name-transformer test:update:e2e
40+ type : e2e
41+ steps :
42+ - name : Checkout branch
43+ uses : actions/checkout@v6
44+ with :
45+ ref : ${{ github.ref_name }}
46+ persist-credentials : false
47+
48+ - uses : ./.github/actions/pnpm-setup
49+
50+ - name : Install Playwright browsers
51+ if : matrix.type == 'e2e'
52+ run : npx playwright install --with-deps firefox
53+
54+ - name : Build
55+ if : matrix.type == 'e2e'
56+ run : pnpm --filter @public-ui/sample-react^... build
57+
58+ - name : Purge existing snapshots
59+ if : inputs.delete_snapshots == true
60+ run : |
61+ if [ "${{ matrix.type }}" = "e2e" ]; then
62+ find packages -name '*.png' -path '*/snapshots/*' | grep -v 'node_modules' | xargs --no-run-if-empty rm -f
63+ else
64+ find packages \( -path '*/node_modules' -prune \) -o -path '*/__snapshots__/*' -type f -print | xargs --no-run-if-empty rm -f
65+ fi
66+
67+ - name : Run snapshot update
68+ run : ${{ matrix.command }}
69+
70+ - name : Package snapshot changes
71+ run : |
72+ {
73+ git diff --name-only --diff-filter=d HEAD
74+ git ls-files --others --exclude-standard
75+ } | grep -E '(__snapshots__|snapshots)/' | tar cf snapshots.tar -T - 2>/dev/null || tar cf snapshots.tar --files-from /dev/null
76+
77+ - name : Upload snapshot artifacts
78+ uses : actions/upload-artifact@v7
79+ with :
80+ name : snapshots-${{ matrix.name }}
81+ path : snapshots.tar
82+ if-no-files-found : ignore
83+ retention-days : 1
84+
85+ push :
86+ needs : update-snapshots
1887 runs-on : ubuntu-latest
1988 steps :
2089 - uses : actions/create-github-app-token@v3
@@ -35,52 +104,27 @@ jobs:
35104 ref : ${{ github.ref_name }}
36105 token : ${{ steps.app-token.outputs.token }}
37106
38- # https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time
39- - name : Install Node.js
40- uses : actions/setup-node@v6
41- with :
42- node-version : 22
43-
44- - name : Install pnpm
45- uses : pnpm/action-setup@v4
46- id : pnpm-install
47- with :
48- version : 10
49- run_install : false
50-
51- - name : Get pnpm store directory
52- id : pnpm-cache
53- shell : bash
54- run : echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
55-
56- - name : Setup pnpm cache
57- uses : actions/cache@v5
58- with :
59- path : ${{ steps.pnpm-cache.outputs.STORE_PATH }}
60- key : ${{ runner.os }}-pnpm-store
61- restore-keys : |
62- ${{ runner.os }}-pnpm-store
63-
64- - name : Install
65- run : pnpm i --no-frozen-lockfile
66-
67- - name : Install Playwright browsers
68- run : npx playwright install --with-deps firefox
69-
70- - name : Build
71- run : pnpm --filter @public-ui/sample-react^... build
72-
73- - name : Purge existing snapshots (optional)
107+ - name : Purge existing snapshots
74108 if : inputs.delete_snapshots == true
75- run : find packages -name '*.png' -path '*/snapshots/*' | grep -v 'node_modules' | xargs rm # Remove any existing snapshots, except those in node_modules
109+ run : |
110+ find packages -name '*.png' -path '*/snapshots/*' | grep -v 'node_modules' | xargs --no-run-if-empty rm -f
111+ find packages \( -path '*/node_modules' -prune \) -o -path '*/__snapshots__/*' -type f -print | xargs --no-run-if-empty rm -f
76112
77- - name : Display git status (before test-update)
78- run : git status
79-
80- - name : Run snapshot updates
81- run : pnpm test:update
82-
83- - name : Display git status (after test-update)
113+ - name : Download snapshot artifacts
114+ uses : actions/download-artifact@v8
115+ with :
116+ pattern : snapshots-*
117+ path : snapshot-artifacts
118+
119+ - name : Apply snapshot updates
120+ run : |
121+ for dir in snapshot-artifacts/snapshots-*/; do
122+ if [ -f "${dir}snapshots.tar" ]; then
123+ tar xf "${dir}snapshots.tar"
124+ fi
125+ done
126+
127+ - name : Display git status
84128 run : git status
85129
86130 - name : Stage snapshot changes
0 commit comments