@element-hq/element-web-playwright-common 2.2.5 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Dockerfile CHANGED
@@ -6,4 +6,13 @@ WORKDIR /work
6
6
  # fonts-dejavu is needed for the same RTL rendering as on CI
7
7
  RUN apt-get update && apt-get -y install docker.io fonts-dejavu
8
8
 
9
- ENTRYPOINT ["npx", "playwright", "test", "--update-snapshots", "--reporter", "line"]
9
+ # Set up corepack
10
+ RUN corepack enable
11
+ ENV COREPACK_ENABLE_DOWNLOAD_PROMPT=0
12
+
13
+ # Add environment variable so consumers can skip developer-centric scripts
14
+ ENV PLAYWRIGHT_COMMON_DOCKER=1
15
+
16
+ COPY docker-entrypoint.sh /docker-entrypoint.sh
17
+
18
+ ENTRYPOINT ["/docker-entrypoint.sh"]
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ if [[ "$YARN_INSTALL" == "true" ]]; then
6
+ yarn install --frozen-lockfile
7
+ fi
8
+
9
+ npx playwright test --update-snapshots --reporter line "$@"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@element-hq/element-web-playwright-common",
3
3
  "type": "module",
4
- "version": "2.2.5",
4
+ "version": "2.2.7",
5
5
  "license": "SEE LICENSE IN README.md",
6
6
  "repository": {
7
7
  "type": "git",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "@axe-core/playwright": "^4.10.1",
33
33
  "@testcontainers/postgresql": "^11.0.0",
34
- "glob": "^13.0.0",
34
+ "glob": "^13.0.1",
35
35
  "lodash-es": "^4.17.23",
36
36
  "mailpit-api": "^1.2.0",
37
37
  "strip-ansi": "^7.1.0",
@@ -8,11 +8,18 @@ SCRIPT_DIR=$(dirname "$SCRIPT_PATH")
8
8
 
9
9
  IMAGE_NAME="element-web-playwright-common"
10
10
 
11
+ if docker --version | grep -q podman; then docker_is_podman=1; fi
12
+
11
13
  build_image() {
12
14
  echo "Building $IMAGE_NAME image in $SCRIPT_DIR"
13
15
 
14
16
  # Check the playwright version
15
- PW_VERSION=$(yarn list --pattern @playwright/test --depth=0 --json --non-interactive --no-progress | jq -r '.data.trees[].name | split("@") | last')
17
+ PM=$(cat package.json | jq -r '.packageManager')
18
+ if [[ $PM == "pnpm@"* ]]; then
19
+ PW_VERSION=$(pnpm list @playwright/test --depth=0 --json | jq -r '.[].devDependencies["@playwright/test"].version')
20
+ else
21
+ PW_VERSION=$(yarn list --pattern @playwright/test --depth=0 --json --non-interactive --no-progress | jq -r '.data.trees[].name | split("@") | last')
22
+ fi
16
23
  echo "with Playwright version $PW_VERSION"
17
24
 
18
25
  # Build image
@@ -49,6 +56,7 @@ RUN_ARGS=(
49
56
  )
50
57
 
51
58
  DEFAULT_ARGS=(--grep @screenshot)
59
+ LINK_MODULES=true
52
60
 
53
61
  # Some arguments to customise behaviour so the same script / image can be
54
62
  # re-used for other screenshot generation.
@@ -59,7 +67,15 @@ while [[ $# -gt 0 ]]; do
59
67
  # It's a volume rather than a directory because otherwise things tend to start picking up
60
68
  # files from it in the native environment and break.
61
69
  --with-node-modules)
62
- RUN_ARGS+=(--mount "type=volume,src=ew-docker-node-modules,dst=/work/node_modules,volume-nocopy")
70
+ mount_param="type=volume,src=ew-docker-node-modules,dst=/work/node_modules"
71
+ # podman doesn't support `volume-nocopy`
72
+ if [ -z "$docker_is_podman" ]; then mount_param+=",volume-nocopy"; fi
73
+ RUN_ARGS+=(--mount "${mount_param}" -e YARN_INSTALL=true)
74
+ shift
75
+ ;;
76
+ # Disables the automatic detection & linking of node_modules which can clash with developer tooling e.g. pnpm-link
77
+ --no-link-modules)
78
+ LINK_MODULES=false
63
79
  shift
64
80
  ;;
65
81
  # Sets a different entrypoint (in which case the default arguments to the script will be ignored)
@@ -77,16 +93,17 @@ done
77
93
 
78
94
  build_image
79
95
 
80
- # Ensure we pass all symlinked node_modules to the container
81
- pushd node_modules > /dev/null
82
- SYMLINKS=$(find . -maxdepth 2 -type l -not -path "./.bin/*")
83
- popd > /dev/null
84
- for LINK in $SYMLINKS; do
85
- TARGET=$(readlink -f "node_modules/$LINK") || true
86
- if [ -d "$TARGET" ]; then
87
- if docker --version | grep -q podman; then
88
- echo -e "\033[31m" >&2
89
- cat <<'EOF' >&2
96
+ if [[ $LINK_MODULES == true ]]; then
97
+ # Ensure we pass all symlinked node_modules to the container
98
+ pushd node_modules > /dev/null
99
+ SYMLINKS=$(find . -maxdepth 2 -type l -not -path "./.bin/*")
100
+ popd > /dev/null
101
+ for LINK in $SYMLINKS; do
102
+ TARGET=$(readlink -f "node_modules/$LINK") || true
103
+ if [ -d "$TARGET" ]; then
104
+ if [ -n "$docker_is_podman" ]; then
105
+ echo -e "\033[31m" >&2
106
+ cat <<'EOF' >&2
90
107
  WARNING: `node_modules` contains symlinks, and the support for this in
91
108
  `playwright-screenshots.sh` is broken under podman due to
92
109
  https://github.com/containers/podman/issues/25947.
@@ -94,12 +111,13 @@ https://github.com/containers/podman/issues/25947.
94
111
  If you get errors such as 'Error: crun: creating `<path>`', then retry this
95
112
  having `yarn unlink`ed the relevant node modules.
96
113
  EOF
97
- echo -e "\033[0m" >&2
114
+ echo -e "\033[0m" >&2
115
+ fi
116
+ echo "mounting linked package ${LINK:2} in container"
117
+ RUN_ARGS+=( "-v" "$TARGET:/work/node_modules/${LINK:2}" )
98
118
  fi
99
- echo "mounting linked package ${LINK:2} in container"
100
- RUN_ARGS+=( "-v" "$TARGET:/work/node_modules/${LINK:2}" )
101
- fi
102
- done
119
+ done
120
+ fi
103
121
 
104
122
  # Our Playwright fixtures use Testcontainers [1], which uses a docker image
105
123
  # called Ryuk [2], which will clean up any dangling containers/networks/etc