mirror of
https://github.com/vector-im/element-web.git
synced 2026-05-04 19:56:45 +02:00
Add options to use playwright screenshot script for other things
In this case, storybook screenshots, but this keeps it so this script doesnt know about storybook itself (we can move the actual storybook specific code to here if we standardise on it more).
This commit is contained in:
parent
03c2f2cd5f
commit
4df86c4d3f
@ -1,25 +1,29 @@
|
||||
#!/bin/bash
|
||||
set -x
|
||||
|
||||
# Handle symlinks here as we tend to be executed as an npm binary
|
||||
SCRIPT_PATH=$(readlink -f "$0")
|
||||
SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
|
||||
|
||||
IMAGE_NAME="element-web-playwright-common"
|
||||
echo "Building $IMAGE_NAME image in $SCRIPT_DIR"
|
||||
|
||||
# Build image
|
||||
PW_VERSION=$(
|
||||
yarn list \
|
||||
--pattern @playwright/test \
|
||||
--depth=0 \
|
||||
--json \
|
||||
--non-interactive \
|
||||
--no-progress | \
|
||||
jq -r '.data.trees[].name | split("@")[2]' \
|
||||
)
|
||||
echo "with Playwright version $PW_VERSION"
|
||||
build_image() {
|
||||
echo "Building $IMAGE_NAME image in $SCRIPT_DIR"
|
||||
|
||||
docker build -t "$IMAGE_NAME" --build-arg "PLAYWRIGHT_VERSION=$PW_VERSION" "$SCRIPT_DIR"
|
||||
# Build image
|
||||
PW_VERSION=$(
|
||||
yarn list \
|
||||
--pattern @playwright/test \
|
||||
--depth=0 \
|
||||
--json \
|
||||
--non-interactive \
|
||||
--no-progress | \
|
||||
jq -r '.data.trees[].name | split("@")[2]' \
|
||||
)
|
||||
echo "with Playwright version $PW_VERSION"
|
||||
|
||||
docker build -t "$IMAGE_NAME" --build-arg "PLAYWRIGHT_VERSION=$PW_VERSION" "$SCRIPT_DIR"
|
||||
}
|
||||
|
||||
RUN_ARGS=(
|
||||
--rm
|
||||
@ -36,6 +40,35 @@ RUN_ARGS=(
|
||||
-it
|
||||
)
|
||||
|
||||
DEFAULT_ARGS=(--grep @screenshot)
|
||||
|
||||
# Some arguments to customise behaviour so the same script / image can be
|
||||
# re-used for other screenshot generation.
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
# Mounts a separate node_modules directory from a docker volume in the container.
|
||||
# Must be used if executing something that requires native node modules
|
||||
# It's a volume rather than a directory because otherwise things tend to start picking up
|
||||
# files from it in the native environment and break.
|
||||
--with-node-modules)
|
||||
RUN_ARGS+=(--mount "type=volume,src=ew-docker-node-modules,dst=/work/node_modules,volume-nocopy")
|
||||
shift
|
||||
;;
|
||||
# Sets a different entrypoint (in which case the default arguments to the script will be ignored)
|
||||
--entrypoint)
|
||||
shift
|
||||
RUN_ARGS+=(--entrypoint "$1")
|
||||
DEFAULT_ARGS=()
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
break
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
build_image
|
||||
|
||||
# Ensure we pass all symlinked node_modules to the container
|
||||
pushd node_modules || exit > /dev/null
|
||||
SYMLINKS=$(find . -maxdepth 2 -type l -not -path "./.bin/*")
|
||||
@ -48,6 +81,4 @@ for LINK in $SYMLINKS; do
|
||||
fi
|
||||
done
|
||||
|
||||
DEFAULT_ARGS=(--grep @screenshot)
|
||||
|
||||
docker run "${RUN_ARGS[@]}" "$IMAGE_NAME" "${DEFAULT_ARGS[@]}" "$@"
|
||||
docker run "${RUN_ARGS[@]}" "$IMAGE_NAME" "${DEFAULT_ARGS[@]}" "$@"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user