Skip to content

Commit dee294e

Browse files
committed
Add e2e workflow + respect the WATCH env var when running in Docker (#28)
(cherry picked from commit b6b40e9)
1 parent 1edebeb commit dee294e

File tree

8 files changed

+133
-1682
lines changed

8 files changed

+133
-1682
lines changed

.env.docker.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ METABASE_JWT_SHARED_SECRET="ffffffffffffffffffffffffffffffffffffffffffffffffffff
44
MB_PORT=4300
55
CLIENT_PORT=4400
66
AUTH_PROVIDER_PORT=4500
7+
8+
WATCH="false"

.github/workflows/e2e-tests.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: E2E tests
2+
3+
on:
4+
push:
5+
branches:
6+
- "main"
7+
- "*-stable"
8+
pull_request:
9+
types: [opened, synchronize, reopened, ready_for_review]
10+
branches:
11+
- "main"
12+
- "*-stable"
13+
14+
jobs:
15+
e2e-tests:
16+
runs-on: ubuntu-22.04
17+
timeout-minutes: 10
18+
name: e2e-tests
19+
env:
20+
PREMIUM_EMBEDDING_TOKEN: ${{ secrets.ENTERPRISE_TOKEN }}
21+
permissions:
22+
id-token: write
23+
contents: read
24+
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Run Sample App in Docker
29+
run: |
30+
cp .env.docker.example .env.docker &&
31+
npm run docker:up -- -d &&
32+
while ! nc -z localhost 4400; do sleep 1; done
33+
34+
- name: Install Chrome v111
35+
uses: browser-actions/setup-chrome@v1
36+
with:
37+
# https://chromium.cypress.io/linux/stable/111.0.5563.146
38+
chrome-version: 1097615
39+
id: setup-chrome
40+
41+
- name: Ensure that Cypress executable is ready
42+
run: npm ci --prefix e2e
43+
44+
- name: Run e2e tests
45+
id: run-e2e-tests
46+
run: cd e2e && npm run cypress:run
47+
48+
- name: Upload Cypress Artifacts upon failure
49+
uses: actions/upload-artifact@v4
50+
if: ${{ steps.run-e2e-tests.outcome != 'success' }}
51+
with:
52+
name: cypress-recording-latest
53+
path: |
54+
./e2e/cypress
55+
if-no-files-found: ignore

client/Dockerfile

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
FROM node:22-bullseye AS runner
22

3+
ARG WATCH=false
4+
ENV WATCH=${WATCH}
5+
6+
ARG VITE_METABASE_INSTANCE_URL
7+
ENV VITE_METABASE_INSTANCE_URL=${VITE_METABASE_INSTANCE_URL}
8+
9+
ARG VITE_AUTH_PROVIDER_URI
10+
ENV VITE_AUTH_PROVIDER_URI=${VITE_AUTH_PROVIDER_URI}
11+
312
WORKDIR /app
413

514
COPY ./client ./client
@@ -16,4 +25,11 @@ RUN if [ -d "../local-dist/embedding-sdk" ]; then \
1625
echo "Local embedding-sdk dist is not found in ../local-dist/embedding-sdk, skipping copy"; \
1726
fi
1827

19-
CMD ["npx", "vite", "--host"]
28+
RUN if [ "$WATCH" != "true" ]; then \
29+
echo "WATCH env is not set; running production yarn build..."; \
30+
npx vite build; \
31+
else \
32+
echo "WATCH env is set; running in development mode..."; \
33+
fi
34+
35+
ENTRYPOINT ["/app/client/entrypoint.sh"]

client/entrypoint.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
if [ "$WATCH" = "true" ]; then
5+
npx vite --host
6+
else
7+
npx vite preview --host
8+
fi

0 commit comments

Comments
 (0)