ci(workflow): Integrate API readiness tests

This commit is contained in:
Kilian Tyler
2026-01-02 18:45:26 -05:00
parent e0d752a5b3
commit bcd6daf6b6
+50 -3
View File
@@ -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