Skip to content

Commit ecd6161

Browse files
authored
Merge pull request #1165 from RBC/e2e-testing
2 parents b5a8d9e + 4674c9d commit ecd6161

35 files changed

+3167
-166
lines changed

.github/workflows/e2e.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: E2E Tests
2+
3+
permissions:
4+
contents: read
5+
issues: write
6+
pull-requests: write
7+
8+
on:
9+
push:
10+
branches: [main]
11+
issue_comment:
12+
types: [created]
13+
14+
jobs:
15+
e2e:
16+
runs-on: ubuntu-latest
17+
# Run on push/PR or when a maintainer comments "/test e2e" or "/run e2e"
18+
if: |
19+
github.event_name != 'issue_comment' || (
20+
github.event.issue.pull_request &&
21+
(contains(github.event.comment.body, '/test e2e') || contains(github.event.comment.body, '/run e2e')) &&
22+
(github.event.comment.author_association == 'OWNER' ||
23+
github.event.comment.author_association == 'MEMBER' ||
24+
github.event.comment.author_association == 'COLLABORATOR')
25+
)
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@08eba0b27e820071cde6df949e0beb9ba4906955 # v4
30+
with:
31+
# When triggered by comment, checkout the PR branch
32+
ref: ${{ github.event_name == 'issue_comment' && format('refs/pull/{0}/head', github.event.issue.number) || github.ref }}
33+
34+
- name: Set up Docker Buildx
35+
uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435
36+
37+
- name: Set up Docker Compose
38+
uses: docker/setup-compose-action@364cc21a5de5b1ee4a7f5f9d3fa374ce0ccde746
39+
40+
- name: Set up Node.js
41+
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
42+
with:
43+
node-version: '20'
44+
cache: 'npm'
45+
46+
- name: Install dependencies
47+
run: npm ci
48+
49+
- name: Configure Git for CI
50+
run: |
51+
git config --global user.name "CI Runner"
52+
git config --global user.email "[email protected]"
53+
git config --global init.defaultBranch main
54+
55+
- name: Build and start services with Docker Compose
56+
run: docker compose up -d --build
57+
58+
- name: Wait for services to be ready
59+
run: |
60+
timeout 60 bash -c 'until docker compose ps | grep -q "Up"; do sleep 2; done'
61+
sleep 10
62+
63+
- name: Run E2E tests
64+
run: npm run test:e2e
65+
66+
- name: Stop services
67+
if: always()
68+
run: docker compose down -v

Dockerfile

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
FROM node:20 AS builder
2+
3+
USER root
4+
5+
WORKDIR /app
6+
7+
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 ./
8+
COPY src/ /app/src/
9+
COPY public/ /app/public/
10+
11+
# Build the UI and server
12+
RUN npm pkg delete scripts.prepare \
13+
&& npm ci --include=dev \
14+
&& npm run build-ui -dd \
15+
&& npx tsc --project tsconfig.publish.json \
16+
&& cp config.schema.json dist/ \
17+
&& npm prune --omit=dev
18+
19+
FROM node:20 AS production
20+
21+
COPY --from=builder /app/package*.json ./
22+
COPY --from=builder /app/node_modules/ /app/node_modules/
23+
COPY --from=builder /app/dist/ /app/dist/
24+
COPY --from=builder /app/build /app/dist/build/
25+
COPY proxy.config.json config.schema.json ./
26+
COPY docker-entrypoint.sh /docker-entrypoint.sh
27+
28+
USER root
29+
30+
RUN apt-get update && apt-get install -y \
31+
git tini \
32+
&& rm -rf /var/lib/apt/lists/*
33+
34+
RUN chown 1000:1000 /app/dist/build \
35+
&& chmod g+w /app/dist/build
36+
37+
USER 1000
38+
39+
WORKDIR /app
40+
41+
EXPOSE 8080 8000
42+
43+
ENTRYPOINT ["tini", "--", "/docker-entrypoint.sh"]
44+
CMD ["node", "dist/index.js"]

docker-compose.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
services:
2+
git-proxy:
3+
build: .
4+
ports:
5+
- '8000:8000'
6+
- '8081:8081'
7+
command: ['node', 'dist/index.js', '--config', '/app/test-e2e.proxy.config.json']
8+
volumes:
9+
- ./test-e2e.proxy.config.json:/app/test-e2e.proxy.config.json:ro
10+
# If using Podman, you might need to add the :Z or :z option for SELinux
11+
# - ./test-e2e.proxy.config.json:/app/test-e2e.proxy.config.json:ro,Z
12+
depends_on:
13+
- mongodb
14+
- git-server
15+
networks:
16+
- git-network
17+
environment:
18+
- NODE_ENV=test
19+
- GIT_PROXY_UI_PORT=8081
20+
- GIT_PROXY_SERVER_PORT=8000
21+
- NODE_OPTIONS=--trace-warnings
22+
- NODE_TLS_REJECT_UNAUTHORIZED=0
23+
# Runtime environment variables for UI configuration
24+
# API_URL should point to the same origin as the UI (both on 8081)
25+
# Leave empty or unset for same-origin API access
26+
# - API_URL=
27+
# CORS configuration - controls which origins can access the API
28+
# Options:
29+
# - '*' = Allow all origins (testing/development)
30+
# - Comma-separated list = 'http://localhost:3000,https://example.com'
31+
# - Unset/empty = Same-origin only (most secure)
32+
- ALLOWED_ORIGINS=
33+
mongodb:
34+
image: mongo:7
35+
ports:
36+
- '27017:27017'
37+
networks:
38+
- git-network
39+
environment:
40+
- MONGO_INITDB_DATABASE=gitproxy
41+
volumes:
42+
- mongodb_data:/data/db
43+
44+
git-server:
45+
build: localgit/
46+
ports:
47+
- '8443:8443' # HTTPS git server
48+
environment:
49+
- GIT_HTTP_EXPORT_ALL=true
50+
networks:
51+
- git-network
52+
hostname: git-server
53+
54+
networks:
55+
git-network:
56+
driver: bridge
57+
58+
volumes:
59+
mongodb_data:

docker-entrypoint.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
# Use runtime environment variables (not VITE_* which are build-time only)
3+
# API_URL can be set at runtime to override auto-detection
4+
# ALLOWED_ORIGINS can be set at runtime for CORS configuration
5+
cat > /app/dist/build/runtime-config.json << EOF
6+
{
7+
"apiUrl": "${API_URL:-}",
8+
"allowedOrigins": [
9+
"${ALLOWED_ORIGINS:-*}"
10+
],
11+
"environment": "${NODE_ENV:-production}"
12+
}
13+
EOF
14+
15+
echo "Created runtime configuration with:"
16+
echo " API URL: ${API_URL:-auto-detect}"
17+
echo " Allowed Origins: ${ALLOWED_ORIGINS:-*}"
18+
echo " Environment: ${NODE_ENV:-production}"
19+
20+
exec "$@"

localgit/Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
FROM httpd:2.4
2+
3+
RUN apt-get update && apt-get install -y \
4+
git \
5+
apache2-utils \
6+
python3 \
7+
openssl \
8+
&& rm -rf /var/lib/apt/lists/*
9+
10+
COPY httpd.conf /usr/local/apache2/conf/httpd.conf
11+
COPY git-capture-wrapper.py /usr/local/bin/git-capture-wrapper.py
12+
COPY generate-cert.sh /usr/local/bin/generate-cert.sh
13+
14+
RUN chmod +x /usr/local/bin/generate-cert.sh \
15+
&& /usr/local/bin/generate-cert.sh
16+
17+
RUN htpasswd -cb /usr/local/apache2/conf/.htpasswd admin admin123 \
18+
&& htpasswd -b /usr/local/apache2/conf/.htpasswd testuser user123
19+
20+
COPY init-repos.sh /usr/local/bin/init-repos.sh
21+
22+
RUN chmod +x /usr/local/bin/init-repos.sh \
23+
&& chmod +x /usr/local/bin/git-capture-wrapper.py \
24+
&& mkdir -p /var/git-captures \
25+
&& chown www-data:www-data /var/git-captures \
26+
&& /usr/local/bin/init-repos.sh
27+
28+
EXPOSE 8443
29+
30+
CMD ["httpd-foreground"]

0 commit comments

Comments
 (0)