Skip to content

checkpoint

checkpoint #53

Workflow file for this run

name: E2E Tests
on:
push:
branches: [main, develop, MIGRATING_TO_HELM]
paths-ignore:
- 'docs/**'
- '*.md'
- 'LICENSE'
pull_request:
branches: [main, develop]
paths-ignore:
- 'docs/**'
- '*.md'
- 'LICENSE'
workflow_dispatch: # Allow manual triggering
concurrency:
group: e2e-${{ github.ref }}
cancel-in-progress: true
jobs:
e2e-fast:
name: Fast E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v1
with:
version: "latest"
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Install dependencies
run: uv sync --dev
- name: Run fast E2E tests
run: |
uv run pytest tests/e2e/test_copier_to_deployment.py -v -m "not slow" --tb=short
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-fast-test-results
path: |
tests/e2e/*.log
/tmp/e2e_test_*
if-no-files-found: ignore
e2e-docker:
name: Docker Compose E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 30
# Only run on manual trigger or release branches
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v1
with:
version: "latest"
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Install dependencies
run: uv sync --dev
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Run Docker Compose E2E tests
run: |
uv run pytest tests/e2e/test_copier_to_deployment.py::TestCopierToDeployment::test_07_docker_compose_prod_deployment -v -s --tb=short
- name: Show test artifacts on failure
if: failure()
run: |
echo "=== Checking for E2E test temp directories ==="
ls -la /tmp/e2e_test_* 2>/dev/null || echo "No e2e_test_* directories found in /tmp"
echo ""
echo "=== Checking for pytest temp directories ==="
find /tmp -maxdepth 2 -name "e2e_test_*" -type d 2>/dev/null || echo "No directories found"
echo ""
echo "=== Recent pytest cache ==="
ls -la .pytest_cache/ 2>/dev/null || echo "No pytest cache"
- name: Show Docker Compose logs on failure
if: failure()
run: |
echo "=== Showing Docker Compose logs for all api-forge containers ==="
echo ""
echo "=== All api-forge Containers Status ==="
docker ps -a --filter "name=api-forge" --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}" || true
echo ""
echo "=== Temporal Schema Setup Logs ==="
docker logs api-forge-temporal-schema-setup 2>&1 || echo "Container not found or no logs"
echo ""
echo "=== PostgreSQL Logs ==="
docker logs api-forge-postgres --tail=100 2>&1 || echo "Container not found or no logs"
echo ""
echo "=== Temporal Server Logs ==="
docker logs api-forge-temporal --tail=100 2>&1 || echo "Container not found or no logs"
echo ""
echo "=== Worker Logs ==="
docker logs api-forge-worker --tail=100 2>&1 || echo "Container not found or no logs"
echo ""
echo "=== App Logs ==="
docker logs api-forge-app --tail=100 2>&1 || echo "Container not found or no logs"
echo ""
echo "=== Redis Logs ==="
docker logs api-forge-redis --tail=50 2>&1 || echo "Container not found or no logs"
- name: Cleanup Docker resources
if: always()
run: |
# Stop and remove all api-forge containers
docker ps -aq --filter "name=api-forge" | xargs -r docker rm -f || true
# Remove api-forge networks
docker network ls -q --filter "name=api-forge" | xargs -r docker network rm || true
# Remove api-forge volumes
docker volume ls -q --filter "name=api-forge" | xargs -r docker volume rm || true
# General cleanup
docker system prune -af --volumes || true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-docker-test-results
path: |
tests/e2e/*.log
/tmp/e2e_test_*
if-no-files-found: ignore
e2e-kubernetes:
name: Kubernetes E2E Tests (Helm)
runs-on: ubuntu-latest
timeout-minutes: 30
# Only run on manual trigger or release branches
if: github.event_name == 'workflow_dispatch' || startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: Install uv
uses: astral-sh/setup-uv@v1
with:
version: "latest"
- name: Cache uv dependencies
uses: actions/cache@v4
with:
path: ~/.cache/uv
key: ${{ runner.os }}-uv-${{ hashFiles('**/pyproject.toml') }}
restore-keys: |
${{ runner.os }}-uv-
- name: Install dependencies
run: uv sync --dev
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Minikube
uses: medyagh/setup-minikube@latest
with:
driver: docker
kubernetes-version: v1.28.0
cpus: 4
memory: 6144m
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 'v3.13.0'
- name: Verify Kubernetes cluster and Helm
run: |
kubectl cluster-info
kubectl get nodes
helm version
- name: Run Kubernetes E2E tests (Helm deployment)
run: |
uv run pytest tests/e2e/test_copier_to_deployment.py::TestCopierToDeployment::test_08_kubernetes_deployment -v -s --tb=short
- name: Get Helm and Kubernetes logs on failure
if: failure()
run: |
echo "=== Helm Releases ==="
helm list -n api-forge-prod || true
echo ""
echo "=== Helm Release Status ==="
helm status api-forge -n api-forge-prod || true
echo ""
echo "=== Kubernetes Resources ==="
kubectl get all -n api-forge-prod || true
echo ""
echo "=== Pod Descriptions ==="
kubectl describe pods -n api-forge-prod || true
echo ""
echo "=== Pod Logs ==="
kubectl logs -n api-forge-prod --all-containers --tail=100 || true
echo ""
echo "=== Job Status ==="
kubectl get jobs -n api-forge-prod || true
echo ""
echo "=== ConfigMaps ==="
kubectl get configmaps -n api-forge-prod || true
echo ""
echo "=== Secrets ==="
kubectl get secrets -n api-forge-prod || true
- name: Cleanup Kubernetes resources
if: always()
run: |
helm uninstall api-forge -n api-forge-prod --wait --timeout=300s || true
kubectl delete pods -n api-forge-prod --all --force --grace-period=0 || true
kubectl delete namespace api-forge-prod --wait=true --timeout=120s || true
- name: Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: e2e-k8s-test-results
path: |
tests/e2e/*.log
/tmp/e2e_test_*
if-no-files-found: ignore
e2e-summary:
name: E2E Test Summary
runs-on: ubuntu-latest
needs: [e2e-fast, e2e-docker, e2e-kubernetes]
if: always()
steps:
- name: Check test results
run: |
echo "Fast tests: ${{ needs.e2e-fast.result }}"
echo "Docker tests: ${{ needs.e2e-docker.result }}"
echo "Kubernetes tests: ${{ needs.e2e-kubernetes.result }}"
# Fast tests must pass
if [[ "${{ needs.e2e-fast.result }}" == "failure" ]]; then
echo "❌ Fast E2E tests failed"
exit 1
fi
# Docker/K8s tests only checked if they ran (not skipped)
if [[ "${{ needs.e2e-docker.result }}" == "failure" ]]; then
echo "❌ Docker E2E tests failed"
exit 1
fi
if [[ "${{ needs.e2e-kubernetes.result }}" == "failure" ]]; then
echo "❌ Kubernetes E2E tests failed"
exit 1
fi
echo "✅ All E2E tests passed (or were skipped)"