Skip to content
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
133 changes: 133 additions & 0 deletions .github/workflows/e2e-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: E2E & Integration Tests

on:
push:
branches: [productionize, 'productionize/**', 'devin/**']
pull_request:
branches: [productionize]

jobs:
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install backend dependencies
run: cd backend && npm ci

- name: Install test dependencies
run: npm ci

- name: Run integration tests
run: npm run test:integration

- name: Upload integration test results
if: always()
uses: actions/upload-artifact@v4
with:
name: integration-test-results
path: test-results/integration-results.xml
retention-days: 14

e2e-tests:
name: E2E Tests
runs-on: ubuntu-latest
needs: integration-tests
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install backend dependencies
run: cd backend && npm ci

- name: Install test dependencies
run: npm ci

- name: Install Playwright browsers
run: npx playwright install --with-deps chromium

- name: Start backend server
run: cd backend && node server.js &
env:
TODO_APP_PORT: 3000

- name: Start frontend server
run: cd frontend && python3 -m http.server 8080 &

- name: Wait for services to be ready
run: |
echo "Waiting for backend..."
for i in $(seq 1 30); do
curl -sf http://localhost:3000/health && break
sleep 1
done
echo "Waiting for frontend..."
for i in $(seq 1 30); do
curl -sf http://localhost:8080/ && break
sleep 1
done
echo "Services are ready"

- name: Run E2E tests
run: npm run test:e2e
env:
TODO_APP_FRONTEND_URL: http://localhost:8080
TODO_APP_BACKEND_URL: http://localhost:3000

- name: Upload E2E test results
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-test-results
path: |
test-results/e2e-results.xml
playwright-report/
retention-days: 14

- name: Upload Playwright traces
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-traces
path: playwright-report/
retention-days: 7

smoke-tests:
name: Smoke Tests
runs-on: ubuntu-latest
needs: integration-tests
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '18'

- name: Install backend dependencies
run: cd backend && npm ci

- name: Start backend server
run: cd backend && node server.js &
env:
TODO_APP_PORT: 3000

- name: Wait for backend to be ready
run: |
for i in $(seq 1 30); do
curl -sf http://localhost:3000/health && break
sleep 1
done

- name: Run smoke tests
run: bash tests/smoke/smoke-test.sh http://localhost:3000
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ node_modules/
*.log
.env
.env.local
test-results/
playwright-report/
12 changes: 12 additions & 0 deletions Dockerfile.backend.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18-alpine

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci --production

COPY . .

EXPOSE 3000

CMD ["node", "server.js"]
9 changes: 9 additions & 0 deletions Dockerfile.frontend.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM python:3.11-alpine

WORKDIR /app

COPY . .

EXPOSE 8080

CMD ["python3", "-m", "http.server", "8080"]
14 changes: 14 additions & 0 deletions Dockerfile.tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
FROM node:18-bookworm

RUN npx playwright install --with-deps chromium

WORKDIR /app

COPY package.json package-lock.json ./
RUN npm ci

COPY . .

RUN mkdir -p /app/test-results

CMD ["npm", "run", "test:integration"]
14 changes: 9 additions & 5 deletions backend/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const cors = require('cors');
const todosRouter = require('./routes/todos');

const app = express();
const PORT = 3000;
const PORT = process.env.TODO_APP_PORT || 3000;

app.use(cors());
app.use(express.json());
Expand All @@ -14,7 +14,11 @@ app.get('/health', (req, res) => {
res.json({ status: 'ok' });
});

app.listen(PORT, () => {
console.log(`Backend server running on http://localhost:${PORT}`);
console.log(`API available at http://localhost:${PORT}/api/todos`);
});
if (require.main === module) {
app.listen(PORT, () => {
console.log(`Backend server running on http://localhost:${PORT}`);
console.log(`API available at http://localhost:${PORT}/api/todos`);
});
}

module.exports = app;
61 changes: 61 additions & 0 deletions docker-compose.test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
version: '3.8'

services:
backend:
build:
context: ./backend
dockerfile: ../Dockerfile.backend.test
ports:
- "3000:3000"
environment:
- TODO_APP_PORT=3000
- TODO_APP_NODE_ENV=test
healthcheck:
test: ["CMD", "wget", "--spider", "-q", "http://localhost:3000/health"]
interval: 5s
timeout: 3s
retries: 10
start_period: 10s

frontend:
build:
context: ./frontend
dockerfile: ../Dockerfile.frontend.test
ports:
- "8080:8080"
depends_on:
backend:
condition: service_healthy

integration-tests:
build:
context: .
dockerfile: Dockerfile.tests
depends_on:
backend:
condition: service_healthy
environment:
- TODO_APP_BACKEND_URL=http://backend:3000
command: npm run test:integration
volumes:
- ./test-results:/app/test-results
profiles:
- integration

e2e-tests:
build:
context: .
dockerfile: Dockerfile.tests
depends_on:
backend:
condition: service_healthy
frontend:
condition: service_started
environment:
- TODO_APP_BACKEND_URL=http://backend:3000
- TODO_APP_FRONTEND_URL=http://frontend:8080
command: npm run test:e2e
volumes:
- ./test-results:/app/test-results
profiles:
- e2e
Loading
Loading