-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest-docker.sh
More file actions
executable file
·38 lines (30 loc) · 1.18 KB
/
test-docker.sh
File metadata and controls
executable file
·38 lines (30 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
set -e
# Get Playwright version from package.json
PLAYWRIGHT_VERSION=$(node -p "require('./package.json').devDependencies['@playwright/test']?.replace(/[^\d.]/g, '')")
IMAGE_NAME="mcr.microsoft.com/playwright:v${PLAYWRIGHT_VERSION}"
# Get current directory for mounting
LOCAL_DIR=$(pwd)
DOCKER_DIR="${LOCAL_DIR}"
echo "Pulling image ${IMAGE_NAME}..."
docker pull "${IMAGE_NAME}"
# Build command - install Linux-compatible dependencies, then run tests
# This ensures platform-specific binaries (like esbuild) are installed for Linux
PLAYWRIGHT_ARGS="$*"
COMMAND=("bash" "-c" "npm install && npx playwright test ${PLAYWRIGHT_ARGS}")
echo "Creating container with command: npm install && npx playwright test ${PLAYWRIGHT_ARGS}..."
# Run the container
# Note: Since web server and tests run in the same container, localhost connections work
EXIT_CODE=0
docker run --rm \
--ipc=host \
-v "${LOCAL_DIR}:${DOCKER_DIR}" \
-w "${DOCKER_DIR}" \
"${ENV_ARGS[@]}" \
"${IMAGE_NAME}" \
"${COMMAND[@]}" || EXIT_CODE=$?
echo "Container exit code: ${EXIT_CODE}"
if [ $EXIT_CODE -ne 0 ]; then
echo "Container ended unsuccessfully, check logs for info" >&2
exit $EXIT_CODE
fi