Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test CPU Docker | |
| on: | |
| push: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Build CPU Docker image with model | |
| run: | | |
| docker build \ | |
| --build-arg BUILD_MODELS="jordimas/gemma-3-1b-it" \ | |
| --build-arg HF_TOKEN="${{ secrets.HF_TOKEN }}" \ | |
| -f Dockerfile.cpu \ | |
| -t ctranslate2-test . | |
| - name: Start container | |
| run: docker run -d --name ct2-test -p 8015:8015 ctranslate2-test | |
| - name: Wait for server to be ready | |
| run: | | |
| for i in {1..30}; do | |
| if ! docker ps -q --filter name=ct2-test | grep -q .; then | |
| echo "ERROR: Container exited unexpectedly" | |
| docker logs ct2-test | |
| exit 1 | |
| fi | |
| if curl -sf http://localhost:8015/info > /dev/null; then | |
| echo "Server is ready" | |
| exit 0 | |
| fi | |
| echo "Waiting for server... ($i/30)" | |
| sleep 5 | |
| done | |
| echo "ERROR: Server did not become ready" | |
| docker logs ct2-test | |
| exit 1 | |
| - name: Test inference | |
| run: | | |
| RESPONSE=$(curl -sf -X POST http://localhost:8015/v1/chat/completions \ | |
| -H "Content-Type: application/json" \ | |
| -d '{"model":"jordimas/gemma-3-1b-it","messages":[{"role":"user","content":"how much is 2+2?"}],"max_tokens":64}') | |
| echo "Response: $RESPONSE" | |
| CONTENT=$(echo "$RESPONSE" | jq -r '.choices[0].message.content') | |
| echo "Answer: $CONTENT" | |
| if [ -z "$CONTENT" ] || [ "$CONTENT" = "null" ]; then | |
| echo "ERROR: Response content is empty" | |
| exit 1 | |
| fi | |
| FINISH_REASON=$(echo "$RESPONSE" | jq -r '.choices[0].finish_reason') | |
| echo "Finish reason: $FINISH_REASON" | |
| if [ -z "$FINISH_REASON" ] || [ "$FINISH_REASON" = "null" ]; then | |
| echo "ERROR: finish_reason is missing" | |
| exit 1 | |
| fi | |
| echo "Test passed: got non-empty response with finish_reason=$FINISH_REASON" | |
| - name: Show container logs on failure | |
| if: failure() | |
| run: docker logs ct2-test | |
| - name: Cleanup | |
| if: always() | |
| run: docker rm -f ct2-test || true |