Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions scripts/run-docker-visual-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,33 @@
echo "Running visual tests in Docker (${IMAGE})..."
echo " Command: yarn $*"

# When running inside a git worktree, .git is a file pointing to a gitdir
# outside the mounted source tree. Mount the referenced gitdir (and the
# shared common .git directory) at the same absolute path so git commands
# work inside the container.
GIT_MOUNTS=()
if [ -f .git ]; then

Check failure on line 45 in scripts/run-docker-visual-tests.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ3Uw3k2a1u4siwYMTVm&open=AZ3Uw3k2a1u4siwYMTVm&pullRequest=11594
WORKTREE_GIT_DIR=$(sed -n 's/^gitdir: //p' .git)
if [ -n "$WORKTREE_GIT_DIR" ] && [ -d "$WORKTREE_GIT_DIR" ]; then

Check failure on line 47 in scripts/run-docker-visual-tests.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ3Uw3k2a1u4siwYMTVn&open=AZ3Uw3k2a1u4siwYMTVn&pullRequest=11594

Check failure on line 47 in scripts/run-docker-visual-tests.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ3Uw3k2a1u4siwYMTVo&open=AZ3Uw3k2a1u4siwYMTVo&pullRequest=11594
COMMONDIR_FILE="$WORKTREE_GIT_DIR/commondir"
COMMON_DIR=""
if [ -f "$COMMONDIR_FILE" ]; then

Check failure on line 50 in scripts/run-docker-visual-tests.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ3Uw3k2a1u4siwYMTVp&open=AZ3Uw3k2a1u4siwYMTVp&pullRequest=11594
COMMON_DIR_RAW=$(cat "$COMMONDIR_FILE")
case "$COMMON_DIR_RAW" in
/*) COMMON_DIR="$COMMON_DIR_RAW" ;;
*) COMMON_DIR=$(cd "$WORKTREE_GIT_DIR/$COMMON_DIR_RAW" && pwd) ;;
esac
fi
if [ -n "$COMMON_DIR" ] && [ -d "$COMMON_DIR" ]; then

Check failure on line 57 in scripts/run-docker-visual-tests.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ3Uw3k2a1u4siwYMTVq&open=AZ3Uw3k2a1u4siwYMTVq&pullRequest=11594

Check failure on line 57 in scripts/run-docker-visual-tests.sh

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use '[[' instead of '[' for conditional tests. The '[[' construct is safer and more feature-rich.

See more on https://sonarcloud.io/project/issues?id=vaadin_web-components&issues=AZ3Uw3k2a1u4siwYMTVr&open=AZ3Uw3k2a1u4siwYMTVr&pullRequest=11594
# The worktree's gitdir lives under $COMMON_DIR/worktrees/<name>,
# so mounting $COMMON_DIR alone covers both.
GIT_MOUNTS+=(-v "$COMMON_DIR:$COMMON_DIR")
else
GIT_MOUNTS+=(-v "$WORKTREE_GIT_DIR:$WORKTREE_GIT_DIR")
fi
fi
fi

# Run Docker:
# - --rm: Remove container after exit
# - -i: Enables input in --watch mode
Expand All @@ -50,6 +77,7 @@
-t \
-v "$(pwd)":/work \
-v "${NODE_MODULES_VOLUME}":/work/node_modules \
"${GIT_MOUNTS[@]}" \
-w /work \
-e PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 \
-e TEST_ENV \
Expand Down
Loading