Feat/automated tests #6
This file contains 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: End-to-End Tests | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
jobs: | |
e2e: | |
runs-on: ubuntu-latest | |
strategy: | |
fail-fast: false # https://github.com/cypress-io/github-action/issues/48 | |
matrix: | |
containers: [1, 2] # Uses 2 parallel instances | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- uses: pnpm/action-setup@v4 | |
with: | |
run_install: false | |
- name: Use Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: 'pnpm' | |
- name: Start Middleware Containers | |
run: | | |
docker compose -f deploy/docker/docker-compose.middleware.yml up -d | |
docker ps | |
- name: Wait for Middleware Containers to be Healthy | |
run: | | |
max_retries=5 | |
retry_interval=10 | |
wait_for_healthy() { | |
for ((i=1; i<=$max_retries; i++)); do | |
if [ "$(docker compose -f deploy/docker/docker-compose.middleware.yml ps --format json | jq -r '.[].Health' | grep -v healthy)" ]; then | |
echo "Attempt $i of $max_retries: Waiting for all containers to be healthy..." | |
sleep $retry_interval | |
else | |
echo "All containers are healthy!" | |
return 0 | |
fi | |
done | |
echo "Timeout waiting for containers to be healthy" | |
docker compose -f deploy/docker/docker-compose.middleware.yml ps | |
docker compose -f deploy/docker/docker-compose.middleware.yml logs | |
return 1 | |
} | |
wait_for_healthy | |
- name: E2E Tests | |
uses: cypress-io/github-action@v6 | |
with: | |
browser: chrome | |
record: true | |
parallel: true | |
build: pnpm copy-env build | |
start: pnpm start | |
wait-on: 'http://localhost:5700,http://localhost:5800,http://localhost:5801' | |
env: | |
VITE_API_URL: 'http://localhost:5800' | |
VITE_COLLAB_URL: 'http://localhost:5801' | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NODE_ENV: 'ci' | |
NODE_OPTIONS: '--max_old_space_size=8192' | |
TURBO_TEAM: ${{ secrets.TURBO_TEAM }} | |
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }} | |
CYPRESS_PROJECT_ID: ${{ secrets.PROJECT_ID }} | |
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }} | |
COMMIT_INFO_MESSAGE: ${{ github.event.pull_request.title }} | |
COMMIT_INFO_SHA: ${{ github.event.pull_request.head.sha }} |