aleksa.sh/.forgejo/workflows/cypress.yaml
aleksa a9b8e7bc9e
All checks were successful
E2E Tests with Cypress / cypress (push) Successful in 3m12s
initial boilerplate code
2025-04-12 07:05:13 +02:00

71 lines
2.1 KiB
YAML

name: E2E Tests with Cypress
on:
push:
branches:
- main
- dev
pull_request:
branches:
- main
jobs:
cypress:
runs-on: ubuntu-host-docker
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Start test app with Docker Compose
run: docker compose up --build -d app-test
- name: Wait for test app to be healthy
run: |
SERVICE_NAME="app-test"
# wait for the container to exist
until CONTAINER_ID=$(docker compose ps -q $SERVICE_NAME 2>/dev/null) && [ -n "$CONTAINER_ID" ]; do
echo "Waiting for $SERVICE_NAME container to be created..."
sleep 5
done
# now check health status
while [ "$(docker inspect -f '{{.State.Health.Status}}' $CONTAINER_ID)" != "healthy" ]; do
echo "Waiting for $SERVICE_NAME to become healthy..."
sleep 5
done
echo "$SERVICE_NAME is healthy!"
- name: Build Docker Cypress image
run: |
tar -ch \
cypress.config.ts \
cypress/e2e \
cypress/tsconfig.json \
tsconfig.json \
Dockerfile.cypress \
| docker build -f Dockerfile.cypress -t cypress-tests -
- name: Run Cypress tests with artifact collection
run: |
mkdir -p cypress-videos cypress-screenshots
docker run --network host \
-v $(pwd)/cypress-videos:/e2e/cypress/videos \
-v $(pwd)/cypress-screenshots:/e2e/cypress/screenshots \
-t cypress-tests || true
- name: Upload test artifacts
uses: https://data.forgejo.org/forgejo/upload-artifact@v4
if: always()
with:
name: cypress-artifacts.zip
path: |
cypress-videos/
cypress-screenshots/
retention-days: 3
- name: Cleanup Docker resources
if: always()
run: |
docker compose down --volumes --rmi local --remove-orphans
docker system prune -af \
--filter "label!=production"