diff --git a/.gitea/workflows/workflow.yaml b/.gitea/workflows/workflow.yaml index 26e722c..2105173 100644 --- a/.gitea/workflows/workflow.yaml +++ b/.gitea/workflows/workflow.yaml @@ -121,16 +121,40 @@ jobs: cd ${{ env.REMOTE_PREPROD_PATH }} docker compose --env-file preprod.env -f docker-compose.yaml -f docker-compose.prod.yaml up -d --build --remove-orphans --wait - # Run E2E Tests + - name: Run E2E Tests + uses: appleboy/ssh-action@823bd89e131d8d508129f9443cad5855e9ba96f0 # v1.2.4 + with: + host: ${{ env.SSH_HOST }} + username: ${{ env.SSH_USER }} + key: ${{ env.SSH_PRIVATE_KEY }} + port: ${{ env.SSH_PORT }} + script: | + set -e + cd ${{ env.REMOTE_PREPROD_PATH }} + echo "Running E2E tests..." - # Create venv to avoid polluting system python python3 -m venv .venv . .venv/bin/activate - source preprod.env + + # Export env vars + set -a + . preprod.env + set +a + pip install -r tests/e2e/requirements.txt - pytest tests/e2e/ - - docker compose --env-file preprod.env -f docker-compose.yaml -f docker-compose.prod.yaml down --remove-orphans + + # Run tests + if pytest tests/e2e/; then + echo "Tests passed!" + # Cleanup on success + docker compose --env-file preprod.env -f docker-compose.yaml -f docker-compose.prod.yaml down --remove-orphans + else + echo "Tests failed!" + # Optional: Cleanup on failure? Or keep for debugging? + # User's previous script had it after, implying it runs if pytest succeeds (due to set -e). + # I will fail the step. + exit 1 + fi # ------------------------------------------------------------------ # STAGE 4: DEPLOY PRODUCTION @@ -165,6 +189,10 @@ jobs: # Create venv to avoid polluting system python python3 -m venv .venv . .venv/bin/activate + # Export env vars so pytest can see them + set -a + . prod.env + set +a pip install -r tests/e2e/requirements.txt pytest tests/e2e/