From 6f0369e62306ed87dcc1ec94b974f157778c121f Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Thu, 18 Dec 2025 11:44:17 +0100 Subject: [PATCH] Fix shared component screenshot update (#31568) * build: fix shared component screenshot update The yarn command `test:storybook:update` was running twice `playwright-sceenshots`. However this script is using ryuk to delete remaining containers/etc and ryuk does the cleanup after 50sec of idle. So on the script second call, ryuk container was still running and the script failed. This PR introduces a shell script to install the dependencies and to run the tests in the same playrwright-screenshots call. * Update packages/shared-components/scripts/storybook-screenshot-update.sh Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * Update packages/shared-components/scripts/storybook-screenshot-update.sh Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> * doc: fix duplicated documentation after github commit --------- Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> --- packages/shared-components/package.json | 2 +- .../scripts/storybook-screenshot-update.sh | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 packages/shared-components/scripts/storybook-screenshot-update.sh diff --git a/packages/shared-components/package.json b/packages/shared-components/package.json index 1847ed2dd0..38c186a243 100644 --- a/packages/shared-components/package.json +++ b/packages/shared-components/package.json @@ -43,7 +43,7 @@ "lint:types": "tsc --noEmit --jsx react", "test:storybook": "test-storybook --url http://localhost:6007/", "test:storybook:ci": "concurrently -k -s first -n \"SB,TEST\" \"yarn storybook --no-open\" \"wait-on tcp:6007 && yarn test-storybook --url http://localhost:6007/ --ci --maxWorkers=2\"", - "test:storybook:update": "playwright-screenshots --entrypoint yarn --with-node-modules && playwright-screenshots --entrypoint /work/node_modules/.bin/test-storybook --with-node-modules --url http://host.docker.internal:6007/ --updateSnapshot" + "test:storybook:update": "playwright-screenshots --entrypoint /work/scripts/storybook-screenshot-update.sh --with-node-modules" }, "resolutions": { "playwright": "1.57.0" diff --git a/packages/shared-components/scripts/storybook-screenshot-update.sh b/packages/shared-components/scripts/storybook-screenshot-update.sh new file mode 100755 index 0000000000..6310d6887f --- /dev/null +++ b/packages/shared-components/scripts/storybook-screenshot-update.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# +# Update storybook screenshots +# +# This script should be used as the entrypoint parameter of the `playwright-screenshots` script. It +# installs the yarn dependencies, and then runs `test-storybook` to update the storybook screenshots. +# +# It expects to find a storybook instance running at :6007 on the host machine. It also requires that +# `playwright-screenshots` is given the `--with-node-modules` parameter. +# +# Example: +# +# test-storybook --url http://localhost:6007/ +# playwright-screenshots --entrypoint /work/scripts/storybook-screenshot-update.sh --with-node-modules +# +# +# Note: even though this script is small, it is important because the alternative is running +# `playwright-screenshots` twice in quick succession (once to do `yarn install`, a second to do the +# actual updates): and that fails, because running `playwright-screenshots` without actually starting +# Testcontainers leaves a ryuk container hanging around for up to 60s, which will block the second +# invocation. + +set -e + +# First install dependencies. We have to do this within the playwright container rather than the host, +# because we have which must be built for the right architecture (and some environments use a VM +# to run docker containers, meaning that things inside a container use a different architecture than +# those on the host). +yarn + +# Now run the screenshot update +/work/node_modules/.bin/test-storybook --url http://host.docker.internal:6007/ --updateSnapshot