From bcd6daf6b6645ed29c02bd0afb0e2721449b4f27 Mon Sep 17 00:00:00 2001 From: Kilian Tyler Date: Fri, 2 Jan 2026 18:45:26 -0500 Subject: [PATCH] ci(workflow): Integrate API readiness tests --- .github/workflows/publish.yml | 53 +++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d800435..d484553 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -25,10 +25,13 @@ jobs: include: - platform: linux/amd64 runner: ubuntu-latest + test: true - platform: linux/arm64 runner: ubuntu-24.04-arm + test: true - platform: linux/arm/v7 runner: ubuntu-24.04-arm + test: false steps: - name: Checkout repository @@ -54,20 +57,64 @@ jobs: with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - - name: Build and push by digest + - name: Build Docker image id: build uses: docker/build-push-action@v6 with: context: . platforms: ${{ matrix.platform }} labels: ${{ steps.meta.outputs.labels }} - outputs: ${{ github.event_name != 'pull_request' && format('type=image,name={0}/{1},push-by-digest=true,name-canonical=true,push=true', env.REGISTRY, env.IMAGE_NAME) || 'type=docker' }} + load: ${{ matrix.test }} + tags: hypermind-test:${{ github.sha }} + cache-from: type=gha + cache-to: type=gha,mode=max + + - name: Run container for testing + if: matrix.test + run: docker run -d --name hypermind-test -p 3000:3000 hypermind-test:${{ github.sha }} + + - name: Wait for server to be ready + if: matrix.test + run: | + for i in {1..30}; do + if curl -sf http://localhost:3000/api/stats; then + echo "Server is ready" + exit 0 + fi + echo "Waiting for server... ($i/30)" + sleep 1 + done + echo "Server failed to start" + docker logs hypermind-test + exit 1 + + - name: Verify API response + if: matrix.test + run: | + response=$(curl -sf http://localhost:3000/api/stats) + echo "Response: $response" + echo "$response" | jq -e '.count != null and .id != null' + + - name: Cleanup test container + if: always() && matrix.test + run: docker rm -f hypermind-test || true + + - name: Push by digest + if: github.event_name != 'pull_request' + id: push + uses: docker/build-push-action@v6 + with: + context: . + platforms: ${{ matrix.platform }} + labels: ${{ steps.meta.outputs.labels }} + outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true + cache-from: type=gha - name: Export digest if: github.event_name != 'pull_request' run: | mkdir -p ${{ runner.temp }}/digests - digest="${{ steps.build.outputs.digest }}" + digest="${{ steps.push.outputs.digest }}" touch "${{ runner.temp }}/digests/${digest#sha256:}" - name: Upload digest