Skip to content

Commit

Permalink
chore: Move e2e compose file and added the job to the workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
pierre-castro committed Nov 9, 2024
1 parent 60aa1ef commit 73f0613
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 55 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,18 @@ jobs:
run: npm i
- name: Run frontend tests
run: npm run test

e2e:
runs-on: ubuntu-latest
defaults:
run:
working-directory: e2e
if: false # Disable e2e tests, deprecated at the moment
timeout-minutes: 2
steps:
- name: Check out code
uses: actions/checkout@v2
- name: Run backend, frontend, APIgateway and database services in a dedicated container
run: docker compose -f docker-compose.yml up -d
- name: Run e2e tests
run: docker compose exec playwright npx playwright test
52 changes: 0 additions & 52 deletions docker-compose.e2e.yml

This file was deleted.

12 changes: 12 additions & 0 deletions e2e/.env.e2e
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# This reproduces the production behavior of the application
NODE_ENV=production

JWT_SECRET_KEY=defaultvalue
# The service name in docker-compose
DATABASE_HOST_PROD=db
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=password
DATABASE_NAME=postgres

STRIPE_SECRET_KEY=sk_test_123
5 changes: 3 additions & 2 deletions e2e/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/playwright
FROM mcr.microsoft.com/playwright:latest

WORKDIR /app

Expand All @@ -9,4 +9,5 @@ COPY playwright.config.ts /app/playwright.config.ts

COPY tests/ /app/tests/

CMD npx playwright test

CMD ["tail", "-f", "/dev/null"]
31 changes: 31 additions & 0 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
backend:
build: ../backend
env_file:
- .env.e2e
depends_on:
- db
frontend:
build: ../frontend
depends_on:
- backend
db:
image: postgres
environment:
POSTGRES_PASSWORD: password
apigateway:
image: nginx
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
depends_on:
- backend
- frontend
ports:
- 7001:80
playwright:
build: .
volumes:
- ./playwright-report:/app/playwright-report
- ./test-results:/app/test-results
depends_on:
- apigateway
23 changes: 23 additions & 0 deletions e2e/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
events {}

http {

server {
listen 80;

location /api {
proxy_pass http://backend:4000/;
}

location /hmr {
proxy_pass http://frontend:7001/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}

location / {
proxy_pass http://frontend:5173/;
}
}
}
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"scripts": {
"start": "docker compose up --build",
"e2e": "docker compose -f docker-compose.e2e.yml up --build --exit-code-from e2e",
"build_prod_and_start": "docker compose -f docker-compose.build.prod.yml up --build"
}
}

0 comments on commit 73f0613

Please sign in to comment.