All checks were successful
Build and Push to ACR / Build and Push (push) Successful in 1m43s
Change-Id: I3184ea3bc23ecc769c9de5fad0a0a0229e353629
96 lines
3.3 KiB
YAML
96 lines
3.3 KiB
YAML
|
|
name: Integration Test
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ "main" ]
|
|
workflow_dispatch: {}
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
# ── Job 1: Platform Conformance ───────────────────────────────────────────
|
|
platform-check:
|
|
name: Platform Conformance
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Platform conformance
|
|
uses: ./.gitea/actions/platform-check
|
|
|
|
# ── Job 2: Unit Tests + Container Smoke ───────────────────────────────────
|
|
smoke-test:
|
|
name: Unit Tests + Container Smoke
|
|
runs-on: ubuntu-latest
|
|
needs: platform-check
|
|
timeout-minutes: 15
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Python 3.11
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.11'
|
|
cache: pip
|
|
|
|
- name: Unit tests
|
|
run: |
|
|
pip install -r requirements.txt -q
|
|
pytest app/ -v --tb=short
|
|
|
|
- name: Install Docker CLI
|
|
run: command -v docker &>/dev/null || (apt-get update -qq && apt-get install -y docker.io)
|
|
|
|
- name: Build container image
|
|
run: docker build -t ci-image:test .
|
|
|
|
- name: Start service and wait for health
|
|
run: |
|
|
docker run -d --name ci-service -p 8000:8000 ci-image:test
|
|
echo "Waiting for /health (up to 60s)..."
|
|
timeout 60 bash -c '
|
|
until curl -sf http://localhost:8000/health >/dev/null; do
|
|
echo " still waiting..."; sleep 2
|
|
done
|
|
'
|
|
echo "✓ Service started"
|
|
|
|
- name: Validate health response
|
|
run: |
|
|
curl -sf http://localhost:8000/health > /tmp/health.json
|
|
echo "Health response:"
|
|
cat /tmp/health.json
|
|
python3 - <<'PYEOF'
|
|
import json, sys
|
|
body = json.load(open('/tmp/health.json'))
|
|
status = str(body.get('status') or '').upper()
|
|
if status not in ('UP', 'OK', 'HEALTHY'):
|
|
print(f" ✗ unexpected health status: {body.get('status')!r}")
|
|
sys.exit(1)
|
|
print(f" ✓ health status: {body['status']}")
|
|
PYEOF
|
|
echo "✓ Container smoke test: PASSED"
|
|
|
|
- name: Write job summary
|
|
if: always()
|
|
run: |
|
|
COMPONENT=$(python3 -c "import yaml; d=yaml.safe_load(open('catalog-info.yaml')); print(d['metadata']['name'])" 2>/dev/null || echo "test-alex-gitops-1")
|
|
echo "## Integration Test: \`${COMPONENT}\`" >> $GITHUB_STEP_SUMMARY
|
|
echo "" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Stage | Detail |" >> $GITHUB_STEP_SUMMARY
|
|
echo "|-------|--------|" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Platform conformance | catalog-info.yaml ✓ \`.platform/initialized.md\` ✓ (see platform-check job) |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Unit tests | \`pytest app/ -v\` |" >> $GITHUB_STEP_SUMMARY
|
|
echo "| Container smoke | \`GET /health\` → HTTP 200, status=UP |" >> $GITHUB_STEP_SUMMARY
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: docker rm -f ci-service 2>/dev/null || true
|
|
|