-
Notifications
You must be signed in to change notification settings - Fork 151
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
Merged
+3,167
−166
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
5dc9159
feat: e2e tests using docker compose
coopernetes c5050c7
fix: e2e tests run in CI, pin e2e workflow deps
coopernetes 060edb2
fix: update repo API test
coopernetes 1396cfb
feat: add git packet capture wrapper to localgit, docs + Dockerfile e…
coopernetes 3beeb45
fix: remove obsolete version field from docker-compose.yml
sidshas03 74fac6e
fix: resolve Cypress e2e test issues
sidshas03 cc6f0a7
fix: resolve remaining Cypress CI issues
sidshas03 8876fa0
fix: cypress tests, runtime cfg for apiBaseUrl + approved push e2e test
coopernetes 25d404a
fix: remove dead code, formatting
coopernetes d3f7b9d
fix: update new tests to new vitest
coopernetes 0e27447
chore: remove old apiBase code
coopernetes f90cc7f
feat: remove http, resolve conflicts
coopernetes 2b5125e
chore: revert cypress test changes
coopernetes 2bcbe98
chore: merge ui changes with new baseUrl function
coopernetes 4674c9d
revert unused files and http support
coopernetes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 }} | ||
coopernetes marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| - 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 "ci@example.com" | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 test-e2e.proxy.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"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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/test-e2e.proxy.config.json'] | ||
| volumes: | ||
| - ./test-e2e.proxy.config.json:/app/test-e2e.proxy.config.json:ro | ||
| # If using Podman, you might need to add the :Z or :z option for SELinux | ||
| # - ./test-e2e.proxy.config.json:/app/test-e2e.proxy.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 | ||
| - NODE_TLS_REJECT_UNAUTHORIZED=0 | ||
| # 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: | ||
| - '8443:8443' # HTTPS git server | ||
| environment: | ||
| - GIT_HTTP_EXPORT_ALL=true | ||
| networks: | ||
| - git-network | ||
| hostname: git-server | ||
|
|
||
| networks: | ||
| git-network: | ||
| driver: bridge | ||
|
|
||
| volumes: | ||
| mongodb_data: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 "$@" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| FROM httpd:2.4 | ||
|
|
||
| RUN apt-get update && apt-get install -y \ | ||
| git \ | ||
| apache2-utils \ | ||
| python3 \ | ||
| openssl \ | ||
| && rm -rf /var/lib/apt/lists/* | ||
|
|
||
| COPY httpd.conf /usr/local/apache2/conf/httpd.conf | ||
| COPY git-capture-wrapper.py /usr/local/bin/git-capture-wrapper.py | ||
| COPY generate-cert.sh /usr/local/bin/generate-cert.sh | ||
|
|
||
| RUN chmod +x /usr/local/bin/generate-cert.sh \ | ||
| && /usr/local/bin/generate-cert.sh | ||
|
|
||
| RUN htpasswd -cb /usr/local/apache2/conf/.htpasswd admin admin123 \ | ||
| && htpasswd -b /usr/local/apache2/conf/.htpasswd testuser user123 | ||
|
|
||
| COPY init-repos.sh /usr/local/bin/init-repos.sh | ||
|
|
||
| RUN chmod +x /usr/local/bin/init-repos.sh \ | ||
| && chmod +x /usr/local/bin/git-capture-wrapper.py \ | ||
| && mkdir -p /var/git-captures \ | ||
| && chown www-data:www-data /var/git-captures \ | ||
| && /usr/local/bin/init-repos.sh | ||
|
|
||
| EXPOSE 8443 | ||
|
|
||
| CMD ["httpd-foreground"] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.