Skip to content

Commit 00d4bdc

Browse files
committed
Add GH CI smoke tests
1 parent d79634d commit 00d4bdc

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,70 @@ jobs:
6060
- name: Validate rules
6161
run: ./bin/metrics-analyzer validate ./automated-rules
6262

63+
container-smoke:
64+
runs-on: ubuntu-latest
65+
needs: build
66+
steps:
67+
- uses: actions/checkout@v4
68+
69+
- name: Read version
70+
id: version
71+
run: echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
72+
73+
- name: Set build time
74+
id: build_time
75+
run: echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
76+
77+
- name: Build image
78+
run: |
79+
docker build \
80+
--build-arg VERSION="${{ steps.version.outputs.version }}" \
81+
--build-arg BUILD_TIME="${{ steps.build_time.outputs.build_time }}" \
82+
-t sma:ci .
83+
84+
- name: Start container
85+
run: |
86+
docker run -d --rm --name sma-ci -p 8080:8080 sma:ci
87+
88+
- name: Wait for readiness
89+
run: |
90+
for i in {1..10}; do
91+
if curl -fsS http://localhost:8080/health >/dev/null; then
92+
exit 0
93+
fi
94+
sleep 1
95+
done
96+
docker logs sma-ci
97+
exit 1
98+
99+
- name: Check version endpoint
100+
run: |
101+
curl -fsS http://localhost:8080/version | python3 - <<'PY'
102+
import json,sys
103+
data = json.load(sys.stdin)
104+
assert "version" in data
105+
assert "lastUpdate" in data
106+
print("version ok")
107+
PY
108+
109+
- name: Analyze sample metrics
110+
run: |
111+
curl -fsS -o /tmp/analysis.json -X POST \
112+
-F "file=@testdata/fixtures/sample_metrics.txt" \
113+
http://localhost:8080/api/analyze/both
114+
python3 - <<'PY'
115+
import json
116+
with open("/tmp/analysis.json") as f:
117+
data = json.load(f)
118+
assert "console" in data
119+
assert "markdown" in data
120+
print("analysis ok")
121+
PY
122+
123+
- name: Show container logs on failure
124+
if: failure()
125+
run: docker logs sma-ci
126+
63127
container-image:
64128
runs-on: ubuntu-latest
65129
needs: build

0 commit comments

Comments
 (0)