Skip to content

Add e2e workflow + respect the WATCH env var when running in Docker #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 16, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .env.docker.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ METABASE_JWT_SHARED_SECRET="ffffffffffffffffffffffffffffffffffffffffffffffffffff
MB_PORT=4300
CLIENT_PORT=4400
AUTH_PROVIDER_PORT=4500

WATCH="false"
55 changes: 55 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: E2E tests

on:
push:
branches:
- "main"
- "*-stable"
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
branches:
- "main"
- "*-stable"

jobs:
e2e-tests:
runs-on: ubuntu-22.04
timeout-minutes: 10
name: e2e-tests
env:
PREMIUM_EMBEDDING_TOKEN: ${{ secrets.ENTERPRISE_TOKEN }}
permissions:
id-token: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Run Sample App in Docker
run: |
cp .env.docker.example .env.docker &&
npm run docker:up -- -d &&
while ! nc -z localhost 4400; do sleep 1; done

- name: Install Chrome v111
uses: browser-actions/setup-chrome@v1
with:
# https://chromium.cypress.io/linux/stable/111.0.5563.146
chrome-version: 1097615
id: setup-chrome

- name: Ensure that Cypress executable is ready
run: npm ci --prefix e2e

- name: Run e2e tests
id: run-e2e-tests
run: cd e2e && npm run cypress:run

- name: Upload Cypress Artifacts upon failure
uses: actions/upload-artifact@v4
if: ${{ steps.run-e2e-tests.outcome != 'success' }}
with:
name: cypress-recording-latest
path: |
./e2e/cypress
if-no-files-found: ignore
18 changes: 17 additions & 1 deletion client/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
FROM node:22-bullseye AS runner

ARG WATCH=false
ENV WATCH=${WATCH}

ARG VITE_METABASE_INSTANCE_URL
ENV VITE_METABASE_INSTANCE_URL=${VITE_METABASE_INSTANCE_URL}

ARG VITE_AUTH_PROVIDER_URI
ENV VITE_AUTH_PROVIDER_URI=${VITE_AUTH_PROVIDER_URI}

WORKDIR /app

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

CMD ["npx", "vite", "--host"]
RUN if [ "$WATCH" != "true" ]; then \
echo "WATCH env is not set; running production yarn build..."; \
npx vite build; \
else \
echo "WATCH env is set; running in development mode..."; \
fi

ENTRYPOINT ["/app/client/entrypoint.sh"]
8 changes: 8 additions & 0 deletions client/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

if [ "$WATCH" = "true" ]; then
npx vite --host
else
npx vite preview --host
fi
Loading