-
Notifications
You must be signed in to change notification settings - Fork 147
feat: e2e tests using docker compose #1165
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
base: main
Are you sure you want to change the base?
Changes from all commits
0435bc4
c23b4bb
b666f9b
7f5ef32
e332148
6f47043
5b5bc63
4e82a52
24b91e4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| name: E2E Tests | ||
|
|
||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| pull-requests: write | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main] | ||
| issue_comment: | ||
| types: [created] | ||
|
|
||
| jobs: | ||
| e2e: | ||
| runs-on: ubuntu-latest | ||
| # Run on push/PR or when a maintainer comments "/test e2e" or "/run e2e" | ||
| if: | | ||
| github.event_name != 'issue_comment' || ( | ||
| github.event.issue.pull_request && | ||
| (contains(github.event.comment.body, '/test e2e') || contains(github.event.comment.body, '/run e2e')) && | ||
| (github.event.comment.author_association == 'OWNER' || | ||
| github.event.comment.author_association == 'MEMBER' || | ||
| github.event.comment.author_association == 'COLLABORATOR') | ||
| ) | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4 | ||
| with: | ||
| # When triggered by comment, checkout the PR branch | ||
| ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || github.ref }} | ||
|
Comment on lines
+16
to
+32
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This step makes me a bit nervous. It's not a great security practice to run Actions on a forked PR but it would be valuable to run these tests on specific PRs that may be adding breaking changes to validate full end-to-end app functionality. I'm not sure if there's a better way than this to run this workflow and would like the team's thoughts. |
||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 | ||
|
|
||
| - name: Set up Docker Compose | ||
| uses: docker/setup-compose-action@364cc21a5de5b1ee4a7f5f9d3fa374ce0ccde746 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4 | ||
| with: | ||
| node-version: '20' | ||
| cache: 'npm' | ||
|
|
||
| - name: Install dependencies | ||
| run: npm ci | ||
|
|
||
| - name: Configure Git for CI | ||
| run: | | ||
| git config --global user.name "CI Runner" | ||
| git config --global user.email "[email protected]" | ||
| git config --global init.defaultBranch main | ||
|
|
||
| - name: Build and start services with Docker Compose | ||
| run: docker compose up -d --build | ||
|
|
||
| - name: Wait for services to be ready | ||
| run: | | ||
| timeout 60 bash -c 'until docker compose ps | grep -q "Up"; do sleep 2; done' | ||
| sleep 10 | ||
|
|
||
| - name: Run E2E tests | ||
| run: npm run test:e2e | ||
|
|
||
| - name: Stop services | ||
| if: always() | ||
| run: docker compose down -v | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| FROM node:20 AS builder | ||
|
|
||
| USER root | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| COPY tsconfig.json tsconfig.publish.json proxy.config.json config.schema.json integration-test.config.json vite.config.ts package*.json index.html index.ts ./ | ||
| COPY src/ /app/src/ | ||
| COPY public/ /app/public/ | ||
|
|
||
| # Build the UI and server | ||
| RUN npm pkg delete scripts.prepare \ | ||
| && npm ci --include=dev \ | ||
| && npm run build-ui -dd \ | ||
| && npx tsc --project tsconfig.publish.json \ | ||
| && cp config.schema.json dist/ \ | ||
| && npm prune --omit=dev | ||
|
|
||
| FROM node:20 AS production | ||
|
|
||
| COPY --from=builder /app/package*.json ./ | ||
| COPY --from=builder /app/node_modules/ /app/node_modules/ | ||
| COPY --from=builder /app/dist/ /app/dist/ | ||
| COPY --from=builder /app/build /app/dist/build/ | ||
| COPY proxy.config.json config.schema.json ./ | ||
| COPY docker-entrypoint.sh /docker-entrypoint.sh | ||
|
|
||
| USER root | ||
|
|
||
| RUN apt-get update && apt-get install -y \ | ||
| git tini \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| RUN chown 1000:1000 /app/dist/build \ | ||
| && chmod g+w /app/dist/build | ||
|
|
||
| USER 1000 | ||
|
|
||
| WORKDIR /app | ||
|
|
||
| EXPOSE 8080 8000 | ||
|
|
||
| ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"] | ||
| CMD ["node", "dist/index.js"] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| services: | ||
| git-proxy: | ||
| build: . | ||
| ports: | ||
| - '8000:8000' | ||
| - '8081:8081' | ||
| command: ['node', 'dist/index.js', '--config', '/app/integration-test.config.json'] | ||
| volumes: | ||
| - ./integration-test.config.json:/app/integration-test.config.json:ro | ||
| # If using Podman, you might need to add the :Z or :z option for SELinux | ||
| # - ./integration-test.config.json:/app/integration-test.config.json:ro,Z | ||
| depends_on: | ||
| - mongodb | ||
| - git-server | ||
| networks: | ||
| - git-network | ||
| environment: | ||
| - NODE_ENV=test | ||
| - GIT_PROXY_UI_PORT=8081 | ||
| - GIT_PROXY_SERVER_PORT=8000 | ||
| - NODE_OPTIONS=--trace-warnings | ||
| # Runtime environment variables for UI configuration | ||
| # API_URL should point to the same origin as the UI (both on 8081) | ||
| # Leave empty or unset for same-origin API access | ||
| # - API_URL= | ||
| # CORS configuration - controls which origins can access the API | ||
| # Options: | ||
| # - '*' = Allow all origins (testing/development) | ||
| # - Comma-separated list = 'http://localhost:3000,https://example.com' | ||
| # - Unset/empty = Same-origin only (most secure) | ||
| - ALLOWED_ORIGINS= | ||
|
|
||
| mongodb: | ||
| image: mongo:7 | ||
| ports: | ||
| - '27017:27017' | ||
| networks: | ||
| - git-network | ||
| environment: | ||
| - MONGO_INITDB_DATABASE=gitproxy | ||
| volumes: | ||
| - mongodb_data:/data/db | ||
|
|
||
| git-server: | ||
| build: localgit/ | ||
| ports: | ||
| - '8080:8080' # Add this line to expose the git server | ||
| environment: | ||
| - GIT_HTTP_EXPORT_ALL=true | ||
| networks: | ||
| - git-network | ||
| hostname: git-server | ||
|
|
||
| networks: | ||
| git-network: | ||
| driver: bridge | ||
|
|
||
| volumes: | ||
| mongodb_data: |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| #!/bin/bash | ||
| # Use runtime environment variables (not VITE_* which are build-time only) | ||
| # API_URL can be set at runtime to override auto-detection | ||
| # ALLOWED_ORIGINS can be set at runtime for CORS configuration | ||
| cat > /app/dist/build/runtime-config.json << EOF | ||
| { | ||
| "apiUrl": "${API_URL:-}", | ||
| "allowedOrigins": [ | ||
| "${ALLOWED_ORIGINS:-*}" | ||
| ], | ||
| "environment": "${NODE_ENV:-production}" | ||
| } | ||
| EOF | ||
|
|
||
| echo "Created runtime configuration with:" | ||
| echo " API URL: ${API_URL:-auto-detect}" | ||
| echo " Allowed Origins: ${ALLOWED_ORIGINS:-*}" | ||
| echo " Environment: ${NODE_ENV:-production}" | ||
|
|
||
| exec "$@" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kriswest we can do this in a follow-up PR but it may be worth adding
workflow_dispatchand allowing this test suite to be executed as part of a pre-release step in the future.