Skip to content

Commit

Permalink
test: add podman playwright (#1013)
Browse files Browse the repository at this point in the history
  • Loading branch information
NasgulNexus authored Sep 12, 2024
1 parent a7c64e9 commit d9d26b1
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions scripts/playwright-docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,36 @@ set -euo pipefail
IMAGE_NAME="mcr.microsoft.com/playwright"
IMAGE_TAG="v1.45.3-jammy" # This version have to be synchronized with playwright version from package.json

NODE_MODULES_CACHE_DIR="$HOME/.cache/dynamic-forms-playwright-docker-node-modules"
NODE_MODULES_CACHE_DIR="$HOME/.cache/page-constructor-playwright-docker-node-modules"

command_exists() {
command -v "$1" >/dev/null 2>&1
}

run_command() {
docker run --rm --network host -it -w /work \
$CONTAINER_TOOL run --rm --network host -it -w /work \
-v $(pwd):/work \
-v "$NODE_MODULES_CACHE_DIR:/work/node_modules" \
"$IMAGE_NAME:$IMAGE_TAG" \
/bin/bash -c "$1"
}

if command_exists docker; then
CONTAINER_TOOL="docker"
elif command_exists podman; then
CONTAINER_TOOL="podman"
else
echo "Neither Docker nor Podman is installed on the system."
exit 1
fi

if [[ "$1" = "clear-cache" ]]; then
rm -rf "$NODE_MODULES_CACHE_DIR"
exit 0
fi

if [[ ! -d "$NODE_MODULES_CACHE_DIR" ]]; then
mkdir -p "$NODE_MODULES_CACHE_DIR"
run_command 'npm ci'
fi

Expand Down

0 comments on commit d9d26b1

Please sign in to comment.