|
| 1 | +name: helm-smoke-ocr-service |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "*" ] |
| 6 | + pull_request: |
| 7 | + branches: [ "*" ] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +permissions: |
| 11 | + contents: read |
| 12 | + |
| 13 | +jobs: |
| 14 | + lint: |
| 15 | + runs-on: ubuntu-24.04 |
| 16 | + |
| 17 | + steps: |
| 18 | + - name: Checkout |
| 19 | + uses: actions/checkout@v5 |
| 20 | + |
| 21 | + - name: Set up Helm |
| 22 | + uses: azure/setup-helm@v4 |
| 23 | + |
| 24 | + - name: Helm lint |
| 25 | + run: | |
| 26 | + helm lint charts/ocr-service |
| 27 | +
|
| 28 | + - name: Helm template (default) |
| 29 | + run: | |
| 30 | + helm template ocr-service charts/ocr-service >/tmp/ocr-service-rendered-default.yaml |
| 31 | + test -s /tmp/ocr-service-rendered-default.yaml |
| 32 | +
|
| 33 | + - name: Helm template (autoscaling enabled) |
| 34 | + run: | |
| 35 | + helm template ocr-service charts/ocr-service \ |
| 36 | + --set autoscaling.enabled=true \ |
| 37 | + >/tmp/ocr-service-rendered-hpa.yaml |
| 38 | + test -s /tmp/ocr-service-rendered-hpa.yaml |
| 39 | +
|
| 40 | + smoke: |
| 41 | + needs: lint |
| 42 | + runs-on: ubuntu-24.04 |
| 43 | + timeout-minutes: 45 |
| 44 | + |
| 45 | + steps: |
| 46 | + - name: Checkout |
| 47 | + uses: actions/checkout@v5 |
| 48 | + |
| 49 | + - name: Set up Helm |
| 50 | + uses: azure/setup-helm@v4 |
| 51 | + |
| 52 | + - name: Create kind cluster |
| 53 | + uses: helm/kind-action@v1.10.0 |
| 54 | + with: |
| 55 | + cluster_name: ocr-service-smoke |
| 56 | + wait: 300s |
| 57 | + |
| 58 | + - name: Install chart |
| 59 | + run: | |
| 60 | + set -euo pipefail |
| 61 | + helm upgrade --install ocr-service ./charts/ocr-service \ |
| 62 | + --set image.repository=cogstacksystems/cogstack-ocr-service \ |
| 63 | + --set image.tag=1.0.9 \ |
| 64 | + --set image.pullPolicy=IfNotPresent \ |
| 65 | + --wait \ |
| 66 | + --timeout 20m |
| 67 | +
|
| 68 | + - name: Wait for rollout |
| 69 | + run: | |
| 70 | + kubectl rollout status deployment/ocr-service --timeout=20m |
| 71 | +
|
| 72 | + - name: Start port-forward |
| 73 | + run: | |
| 74 | + set -euo pipefail |
| 75 | + kubectl port-forward svc/ocr-service 18090:8090 >/tmp/ocr-service-port-forward.log 2>&1 & |
| 76 | + echo $! >/tmp/ocr-service-port-forward.pid |
| 77 | +
|
| 78 | + - name: Wait for health |
| 79 | + run: | |
| 80 | + set -euo pipefail |
| 81 | + timeout=900 |
| 82 | + interval=10 |
| 83 | + url="http://127.0.0.1:18090/api/health" |
| 84 | +
|
| 85 | + end=$((SECONDS+timeout)) |
| 86 | + while [ $SECONDS -lt $end ]; do |
| 87 | + if curl -fsS "$url" >/dev/null; then |
| 88 | + echo "Service healthy at $url" |
| 89 | + exit 0 |
| 90 | + fi |
| 91 | + sleep "$interval" |
| 92 | + done |
| 93 | +
|
| 94 | + echo "Service failed to become healthy within ${timeout}s" |
| 95 | + exit 1 |
| 96 | +
|
| 97 | + - name: Check readiness |
| 98 | + run: | |
| 99 | + curl -fsS "http://127.0.0.1:18090/api/ready" |
| 100 | +
|
| 101 | + - name: Check info |
| 102 | + run: | |
| 103 | + curl -fsS "http://127.0.0.1:18090/api/info" |
| 104 | +
|
| 105 | + - name: Process sample text |
| 106 | + run: | |
| 107 | + set -euo pipefail |
| 108 | + response="$(curl -fsS -F file=@ocr_service/tests/resources/docs/generic/pat_id_1.txt \ |
| 109 | + "http://127.0.0.1:18090/api/process")" |
| 110 | + echo "$response" | grep -q '"text"' || { echo "Smoke test failed: missing text field"; exit 1; } |
| 111 | + echo "$response" | grep -q "Bart Davidson" || { echo "Smoke test failed: expected substring not found"; exit 1; } |
| 112 | +
|
| 113 | + - name: Diagnostics on failure |
| 114 | + if: failure() |
| 115 | + run: | |
| 116 | + set +e |
| 117 | + kubectl get pods -o wide |
| 118 | + kubectl get events --sort-by=.lastTimestamp | tail -n 200 |
| 119 | + kubectl describe deployment ocr-service |
| 120 | + kubectl describe pods -l app.kubernetes.io/instance=ocr-service |
| 121 | + kubectl logs deployment/ocr-service --all-containers=true --tail=-1 |
| 122 | + helm status ocr-service |
| 123 | + cat /tmp/ocr-service-port-forward.log || true |
| 124 | +
|
| 125 | + - name: Stop port-forward |
| 126 | + if: always() |
| 127 | + run: | |
| 128 | + if [ -f /tmp/ocr-service-port-forward.pid ]; then |
| 129 | + kill "$(cat /tmp/ocr-service-port-forward.pid)" || true |
| 130 | + fi |
| 131 | +
|
| 132 | + - name: Teardown release |
| 133 | + if: always() |
| 134 | + run: | |
| 135 | + helm uninstall ocr-service || true |
0 commit comments