All checks were successful
Build and Push to ACR / Build and Push (push) Successful in 13m22s
Change-Id: Icd7052470aa194342d4adce029e6c9f9154ab3ac
97 lines
3.4 KiB
YAML
97 lines
3.4 KiB
YAML
|
|
name: Integration Test
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ "main", "staging", "prod" ]
|
|
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 Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version-file: go.mod
|
|
cache: true
|
|
|
|
- name: Tidy modules
|
|
run: go mod tidy
|
|
|
|
- name: Unit tests
|
|
run: go test ./... -v
|
|
|
|
- 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 8080:8080 ci-image:test
|
|
echo "Waiting for /health (up to 60s)..."
|
|
timeout 60 bash -c '
|
|
until curl -sf http://localhost:8080/health >/dev/null; do
|
|
echo " still waiting..."; sleep 2
|
|
done
|
|
'
|
|
echo "✓ Service started"
|
|
|
|
- name: Validate health response
|
|
run: |
|
|
curl -sf http://localhost:8080/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; docs=list(yaml.safe_load_all(open('catalog-info.yaml'))); d=next((x for x in docs if isinstance(x,dict) and x.get('kind')=='Component'),docs[0]); print(d['metadata']['name'])" 2>/dev/null || echo "tmpl-test-go")
|
|
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 | \`go test ./... -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
|
|
|