Skip to content

Commit 0f81d9f

Browse files
authored
Commit snapshot changes (#1374)
1 parent a808942 commit 0f81d9f

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

.github/workflows/test.yml

+30-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ on:
66
- main
77
pull_request:
88

9+
# Add concurrency group to cancel in-progress runs
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
914
env:
1015
CARGO_TERM_COLOR: always
1116
RUST_VERSION: 1.80.1
@@ -71,9 +76,9 @@ jobs:
7176
storybook:
7277
runs-on: ubuntu-22.04
7378
container:
74-
image: ghcr.io/cartridge-gg/controller/storybook-env:sha-db7f70d
79+
image: ghcr.io/cartridge-gg/controller/storybook-env:sha-a808942
7580
permissions:
76-
contents: "read"
81+
contents: "write"
7782
id-token: "write"
7883
pull-requests: "write"
7984
steps:
@@ -171,6 +176,26 @@ jobs:
171176
echo "snapshot_failed=false" >> "$GITHUB_ENV"
172177
fi
173178
179+
# Add new steps after the check-diffs step
180+
- name: Configure Git
181+
if: env.snapshot_failed == 'true'
182+
run: |
183+
git config --global user.name 'github-actions[bot]'
184+
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
185+
186+
- name: Update and commit snapshots
187+
if: env.snapshot_failed == 'true'
188+
run: |
189+
# Run the update script
190+
pnpm test:storybook:update
191+
192+
# Stage and commit changes
193+
git add packages/*/__image_snapshots__/
194+
git commit -m "chore: update storybook snapshots [skip ci]"
195+
196+
# Push to the PR branch
197+
git push origin HEAD:${{ github.head_ref }}
198+
174199
# Upload diff images to GCP
175200
- uses: "google-github-actions/auth@v2"
176201
with:
@@ -271,11 +296,11 @@ jobs:
271296
body: comment
272297
});
273298
274-
# Fail the job if there were visual differences
299+
# Modify the final check step to not fail when snapshots are updated
275300
- name: Check for failures
276301
if: always()
277302
run: |
278303
if [[ "${{ env.snapshot_failed }}" == "true" ]]; then
279-
echo "Visual differences detected in Storybook tests"
280-
exit 1
304+
echo "Visual differences detected in Storybook tests - snapshots have been updated automatically"
305+
exit 0
281306
fi

scripts/update-storybook-snapshot.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ docker run \
3131
-e DEBUG=true \
3232
--ipc=host \
3333
-ti \
34-
ghcr.io/cartridge-gg/controller/storybook-env:sha-db7f70d \
34+
ghcr.io/cartridge-gg/controller/storybook-env:sha-a808942 \
3535
bash -c "pnpm i && pnpm --filter $PACKAGE test-storybook -u --url http://host.docker.internal:$PORT"
3636

3737
status=$?

0 commit comments

Comments
 (0)