Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Adding e2e CI/CD workflow #18

Adding e2e CI/CD workflow

Adding e2e CI/CD workflow #18

Workflow file for this run

name: E2E Tests
on:
pull_request:
branches: [dev-dspot]
paths:
- 'apps/**/*.*'
- 'packages/**/*.*'
- '.deploy/**/*'
- '.github/workflows/e2e-tests.yml'
- 'package.json'
- 'yarn.lock'
workflow_dispatch:
jobs:
check-api-dependencies:
name: Check and Build API Dependencies
uses: ./.github/workflows/api-dependencies.yml
secrets: inherit
check-web-dependencies:
name: Check and Build Web Dependencies
uses: ./.github/workflows/webapp-dependencies.yml
secrets: inherit
e2e-tests:
name: Run E2E Tests
needs: [check-api-dependencies, check-web-dependencies]
runs-on: ubuntu-latest
env:
ECR_REGISTRY: ${{ vars.ECR_REGISTRY }}
ECR_REPOSITORY_DEPENDENCIES: ${{ vars.ECR_REPOSITORY_DEPENDENCIES }}
AWS_REGION: us-east-1 # AWS region where your ECR repositories are located
# Use same DB config as in docker-compose.infra.yml
DB_NAME: gauzy
DB_USER: postgres
DB_PASS: gauzy_password
DB_PORT: 5432
DB_HOST: db
API_HOST: 0.0.0.0
API_PORT: 3000
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Start Infrastructure Services
run: |
docker-compose -f docker-compose.infra.yml up -d
echo "Waiting for DB to be ready..."
timeout 30s bash -c 'until docker exec db pg_isready -U postgres; do sleep 1; done'
- name: Create E2E Services Config
run: |
cat > docker-compose.e2e.yml << 'EOF'
version: '3.8'
services:
api:
build:
context: .
dockerfile: .deploy/api/Dockerfile
args:
DEPENDENCIES_IMAGE: ${ECR_REGISTRY}/${ECR_REPOSITORY_DEPENDENCIES}:latest
environment:
NODE_ENV: production
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DB_NAME: ${DB_NAME}
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASS}
API_HOST: ${API_HOST}
API_PORT: ${API_PORT}
ports:
- "${API_PORT}:${API_PORT}"
networks:
- overlay
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:${API_PORT}/api"]
interval: 10s
timeout: 5s
retries: 5
webapp:
build:
context: .
dockerfile: .deploy/webapp/Dockerfile
args:
DEPENDENCIES_IMAGE: ${ECR_REGISTRY}/${ECR_REPOSITORY_DEPENDENCIES}:latest-webapp
environment:
NODE_ENV: production
API_BASE_URL: http://api:${API_PORT}
API_HOST: api
API_PORT: ${API_PORT}
PORT: 4200
ports:
- "4200:4200"
networks:
- overlay
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:4200"]
interval: 10s
timeout: 5s
retries: 5
seed:
image: ${ECR_REGISTRY}/${ECR_REPOSITORY_DEPENDENCIES}:latest
working_dir: /workspace
volumes:
- .:/workspace
- ~/.cache/yarn:/root/.cache/yarn
environment:
NODE_ENV: production
DB_HOST: ${DB_HOST}
DB_PORT: ${DB_PORT}
DB_NAME: ${DB_NAME}
DB_USER: ${DB_USER}
DB_PASS: ${DB_PASS}
networks:
- overlay
healthcheck:
test: ["CMD-SHELL", "yarn --cwd /workspace ts-node ./.scripts/has-seed-completed.ts"]
interval: 10s
timeout: 5s
retries: 5
command: |
/bin/sh -c "
yarn config set network-timeout 300000 &&
yarn install --frozen-lockfile --cache-folder /root/.cache/yarn &&
yarn seed:all &&
touch /workspace/.seed-completed
"
e2e:
image: ${ECR_REGISTRY}/${ECR_REPOSITORY_DEPENDENCIES}:latest
working_dir: /workspace
volumes:
- .:/workspace
- ~/.cache/yarn:/root/.cache/yarn
environment:
NODE_ENV: production
API_BASE_URL: http://api:${API_PORT}
WEBAPP_URL: http://webapp:4200
CYPRESS_baseUrl: http://webapp:4200
networks:
- overlay
depends_on:
api:
condition: service_healthy
webapp:
condition: service_healthy
seed:
condition: service_healthy
command: |
/bin/sh -c "
yarn config set network-timeout 300000 &&
yarn install --frozen-lockfile --cache-folder /root/.cache/yarn &&
yarn e2e:ci
"
networks:
overlay:
external: true
EOF
- name: Create Seed Check Script
run: |
cat > .scripts/has-seed-completed.ts << 'EOF'
import { existsSync } from 'fs';
// Check if seed completion marker exists
if (!existsSync('/workspace/.seed-completed')) {
process.exit(1);
}
// Add any additional checks here (e.g., check specific tables)
process.exit(0);
EOF
- name: Start Services in Parallel
run: |
# Export variables for docker-compose
export ECR_REGISTRY=${{ env.ECR_REGISTRY }}
export ECR_REPOSITORY_DEPENDENCIES=${{ env.ECR_REPOSITORY_DEPENDENCIES }}
export DB_NAME=${{ env.DB_NAME }}
export DB_USER=${{ env.DB_USER }}
export DB_PASS=${{ env.DB_PASS }}
export DB_PORT=${{ env.DB_PORT }}
export DB_HOST=${{ env.DB_HOST }}
export API_HOST=${{ env.API_HOST }}
export API_PORT=${{ env.API_PORT }}
# Start API, WebApp and Seed in parallel
docker-compose -f docker-compose.e2e.yml up -d api webapp seed
echo "Waiting for all services to be healthy..."
timeout 300s bash -c '
until docker-compose -f docker-compose.e2e.yml ps | grep -q "seed.*healthy"; do
echo "Waiting for seed to complete..."
sleep 5
done
until docker-compose -f docker-compose.e2e.yml ps | grep -q "api.*healthy"; do
echo "Waiting for API to be ready..."
sleep 5
done
until docker-compose -f docker-compose.e2e.yml ps | grep -q "webapp.*healthy"; do
echo "Waiting for WebApp to be ready..."
sleep 5
done
'
- name: Run E2E Tests
run: |
docker-compose -f docker-compose.e2e.yml up \
e2e \
--abort-on-container-exit \
--exit-code-from e2e
- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-test-results
path: |
dist/cypress
cypress/screenshots
cypress/videos
- name: Cleanup
if: always()
run: |
docker-compose -f docker-compose.infra.yml down
docker-compose -f docker-compose.e2e.yml down