@@ -60,3 +60,126 @@ 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+ for i in {1..5}; do
102+ if curl -fsS http://localhost:8080/version -o /tmp/version.json; then
103+ if [ -s /tmp/version.json ]; then
104+ break
105+ fi
106+ fi
107+ sleep 1
108+ done
109+ if [ ! -s /tmp/version.json ]; then
110+ echo "version response was empty"
111+ cat /tmp/version.json || true
112+ docker logs sma-ci || true
113+ exit 1
114+ fi
115+ python3 - <<'PY'
116+ import json
117+ with open("/tmp/version.json") as f:
118+ data = json.load(f)
119+ assert "version" in data
120+ assert "lastUpdate" in data
121+ print("version ok")
122+ PY
123+
124+ - name : Analyze sample metrics
125+ run : |
126+ curl -fsS -o /tmp/analysis.json -X POST \
127+ -F "file=@testdata/fixtures/sample_metrics.txt" \
128+ http://localhost:8080/api/analyze/both
129+ python3 - <<'PY'
130+ import json
131+ with open("/tmp/analysis.json") as f:
132+ data = json.load(f)
133+ assert "console" in data
134+ assert "markdown" in data
135+ print("analysis ok")
136+ PY
137+
138+ - name : Show container logs on failure
139+ if : failure()
140+ run : docker logs sma-ci
141+
142+ container-image :
143+ runs-on : ubuntu-latest
144+ needs : build
145+ if : github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
146+ env :
147+ QUAY_USERNAME : ${{ secrets.QUAY_USERNAME }}
148+ QUAY_PASSWORD : ${{ secrets.QUAY_PASSWORD }}
149+ steps :
150+ - uses : actions/checkout@v4
151+
152+ - name : Read version
153+ id : version
154+ run : echo "version=$(cat VERSION)" >> "$GITHUB_OUTPUT"
155+
156+ - name : Set build time
157+ id : build_time
158+ run : echo "build_time=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
159+
160+ - name : Set up Docker Buildx
161+ uses : docker/setup-buildx-action@v3
162+
163+ - name : Log in to Quay
164+ id : login
165+ if : ${{ env.QUAY_USERNAME != '' && env.QUAY_PASSWORD != '' }}
166+ uses : docker/login-action@v3
167+ with :
168+ registry : quay.io
169+ username : ${{ env.QUAY_USERNAME }}
170+ password : ${{ env.QUAY_PASSWORD }}
171+
172+ - name : Build and push image
173+ uses : docker/build-push-action@v5
174+ with :
175+ context : .
176+ file : ./Dockerfile
177+ push : ${{ steps.login.conclusion == 'success' }}
178+ tags : |
179+ quay.io/prygiels/sma:${{ steps.version.outputs.version }}
180+ quay.io/prygiels/sma:${{ github.sha }}
181+ quay.io/prygiels/sma:latest
182+ build-args : |
183+ VERSION=${{ steps.version.outputs.version }}
184+ BUILD_TIME=${{ steps.build_time.outputs.build_time }}
185+
0 commit comments