This repository was archived by the owner on Feb 24, 2026. It is now read-only.
Adding e2e CI/CD workflow #22
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
| name: E2E Tests | |
| on: | |
| pull_request: | |
| branches: [dev-dspot] | |
| paths: | |
| - 'apps/**' | |
| - 'packages/**' | |
| - 'docker/**' | |
| - 'package.json' | |
| - 'yarn.lock' | |
| workflow_run: | |
| workflows: ['Build API Dependencies', 'Build WebApp Dependencies'] | |
| types: | |
| - completed | |
| branches: [dev-dspot] | |
| jobs: | |
| e2e-tests: | |
| name: Run E2E Tests | |
| runs-on: ubuntu-latest | |
| # Run on PR or if dependency workflow completed successfully | |
| if: | | |
| github.event_name == 'pull_request' || | |
| (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success') | |
| environment: staging | |
| permissions: | |
| contents: read | |
| id-token: write | |
| env: | |
| ECR_REGISTRY: ${{ vars.ECR_REGISTRY }} | |
| ECR_REPOSITORY_DEPENDENCIES: ${{ vars.ECR_REPOSITORY_DEPENDENCIES }} | |
| AWS_REGION: ${{ vars.AWS_REGION }} | |
| # 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: Install Docker | |
| run: | | |
| # Add Docker's official GPG key: | |
| sudo apt-get update | |
| sudo apt-get install ca-certificates curl -y | |
| sudo install -m 0755 -d /etc/apt/keyrings | |
| curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
| sudo chmod a+r /etc/apt/keyrings/docker.gpg | |
| # Add the repository to Apt sources: | |
| echo \ | |
| "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ | |
| "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ | |
| sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
| sudo apt-get update | |
| # Install Docker packages | |
| sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin -y | |
| - 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: Install Docker Compose | |
| run: | | |
| sudo curl -L "https://github.com/docker/compose/releases/download/v2.23.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
| sudo chmod +x /usr/local/bin/docker-compose | |
| docker-compose --version | |
| - name: Start Infrastructure Services | |
| run: | | |
| # Create .env file for docker-compose | |
| cat > .env << EOF | |
| ECR_REGISTRY=${{ env.ECR_REGISTRY }} | |
| ECR_REPOSITORY_DEPENDENCIES=${{ env.ECR_REPOSITORY_DEPENDENCIES }} | |
| DB_NAME=${{ env.DB_NAME }} | |
| DB_USER=${{ env.DB_USER }} | |
| DB_PASS=${{ env.DB_PASS }} | |
| DB_PORT=${{ env.DB_PORT }} | |
| DB_HOST=${{ env.DB_HOST }} | |
| API_HOST=${{ env.API_HOST }} | |
| API_PORT=${{ env.API_PORT }} | |
| EOF | |
| 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-api-dev | |
| 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-api-dev | |
| 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: | | |
| # 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 |