refactor: Update CI workflow to ensure environment variables are loaded for E2E tests and add conditional cleanup.
Some checks failed
Remote Deployment Pipeline / Prepare Context (pull_request) Successful in 3s
Remote Deployment Pipeline / Deploy (Staging) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Pre-Prod) (pull_request) Failing after 46s
Remote Deployment Pipeline / Cleanup Preview (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Production) (pull_request) Has been skipped
Remote Deployment Pipeline / Deploy (Dev/Preview) (pull_request) Failing after 14m14s

This commit is contained in:
2026-01-15 21:55:03 +01:00
parent 50aa276c37
commit 01c5229f26

View File

@@ -121,16 +121,40 @@ jobs:
cd ${{ env.REMOTE_PREPROD_PATH }} 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 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..." echo "Running E2E tests..."
# Create venv to avoid polluting system python
python3 -m venv .venv python3 -m venv .venv
. .venv/bin/activate . .venv/bin/activate
source preprod.env
# Export env vars
set -a
. preprod.env
set +a
pip install -r tests/e2e/requirements.txt pip install -r tests/e2e/requirements.txt
pytest tests/e2e/
# Run tests
docker compose --env-file preprod.env -f docker-compose.yaml -f docker-compose.prod.yaml down --remove-orphans 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 # STAGE 4: DEPLOY PRODUCTION
@@ -165,6 +189,10 @@ jobs:
# Create venv to avoid polluting system python # Create venv to avoid polluting system python
python3 -m venv .venv python3 -m venv .venv
. .venv/bin/activate . .venv/bin/activate
# Export env vars so pytest can see them
set -a
. prod.env
set +a
pip install -r tests/e2e/requirements.txt pip install -r tests/e2e/requirements.txt
pytest tests/e2e/ pytest tests/e2e/