Skip to content

Commit defd256

Browse files
committed
build: add config for running all tests via container
1 parent 8c000a5 commit defd256

File tree

3 files changed

+50
-3
lines changed

3 files changed

+50
-3
lines changed

contrib/containers/Containerfile

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ FROM emscripten/emsdk:4.0.4 AS emsdk
22

33

44
# We can't use node bundled in emsdk img as v20.18.0 is incompatible with pinned engines
5-
FROM docker.io/node:22-slim
5+
FROM docker.io/node:22-slim AS build
66
WORKDIR /app
77
COPY --from=emsdk /emsdk /emsdk
88
ENV PATH=$PATH:/emsdk:/emsdk/upstream/emscripten
@@ -17,7 +17,14 @@ RUN apt-get update --quiet \
1717
COPY . .
1818
RUN corepack enable && corepack install
1919
RUN yarn install
20-
# Build packages as a sanity check
20+
# Build packages as a sanity check + make available in tests stage
2121
RUN yarn workspace @getodk/tree-sitter-xpath build
2222
RUN yarn workspace @getodk/xpath build
2323
RUN yarn workspace @getodk/xforms-engine build
24+
25+
26+
FROM build AS test
27+
RUN yarn playwright install chromium --with-deps \
28+
&& yarn playwright install firefox --with-deps \
29+
&& yarn playwright install webkit --with-deps \
30+
&& rm -rf /var/lib/apt/lists/*

contrib/containers/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,18 @@ docker compose -f contrib/containers/compose.yaml up -d
2020
```
2121

2222
Access web forms preview on: http://localhost:5173
23+
24+
## Testing Web Forms
25+
26+
Run all tests:
27+
28+
```bash
29+
docker compose -f contrib/containers/compose.yaml run --rm tests
30+
```
31+
32+
Run a specific test:
33+
34+
```bash
35+
TEST_CMD='yarn workspace @getodk/web-forms run test:e2e:chromium' \
36+
docker compose -f contrib/containers/compose.yaml run --rm tests
37+
```

contrib/containers/compose.yaml

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ services:
44
build:
55
context: ../..
66
dockerfile: contrib/containers/Containerfile
7+
target: build
78
volumes:
8-
- ../../packages:/app/packages
9+
- ../../packages/common:/app/packages/common
10+
- ../../packages/web-forms:/app/packages/web-forms
11+
# Mount each package individually to avoid overwriting generated dist
12+
- ../../packages/xpath/src:/app/packages/xpath/src
13+
- ../../packages/xforms-engine/src:/app/packages/xforms-engine/src
914
ports:
1015
- "${WEB_FORMS_PORT:-5173}:5173"
1116
command: yarn workspace @getodk/web-forms dev
@@ -21,3 +26,23 @@ services:
2126
DJANGO_CORS_ALLOWED_ORIGIN: http://localhost:${WEB_FORMS_PORT:-5173}
2227
ports:
2328
- "${XLSFORM_ONLINE_PORT:-8558}:8000"
29+
30+
tests:
31+
profiles: [test]
32+
image: ghcr.io/getodk/web-forms:test
33+
build:
34+
context: ../..
35+
dockerfile: contrib/containers/Containerfile
36+
target: test
37+
environment:
38+
DISPLAY: :0
39+
volumes:
40+
- ../../packages/common:/app/packages/common
41+
- ../../packages/web-forms:/app/packages/web-forms
42+
# Mount each package individually to avoid overwriting generated dist
43+
- ../../packages/xpath/src:/app/packages/xpath/src
44+
- ../../packages/xforms-engine/src:/app/packages/xforms-engine/src
45+
- ../../packages/xpath/test:/app/packages/xpath/test
46+
- ../../packages/xforms-engine/test:/app/packages/xforms-engine/test
47+
- /tmp/.X11-unix:/tmp/.X11-unix
48+
command: ${TEST_CMD:-yarn run test}

0 commit comments

Comments
 (0)