feat: Add pre-production deployment stage with E2E tests, a dedicated environment file, and update production deployment dependency. #30

Open
kovagoadi wants to merge 14 commits from test_preprod into main
Showing only changes of commit 01c5229f26 - Show all commits

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
pip install -r tests/e2e/requirements.txt
pytest tests/e2e/
# Export env vars
set -a
. preprod.env
set +a
pip install -r tests/e2e/requirements.txt
# 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 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/