name: Server CI on: push: branches: - main paths: - guardrails/** - pyproject.toml workflow_dispatch: jobs: build-test-server: runs-on: ubuntu-latest steps: - name: Check out head uses: actions/checkout@v5 with: persist-credentials: false - name: Set up QEMU uses: docker/setup-qemu-action@master with: platforms: linux/amd64 - name: Set up Docker Buildx uses: docker/setup-buildx-action@master with: platforms: linux/amd64 - name: Build Docker image uses: docker/build-push-action@v6 with: context: . file: server_ci/Dockerfile platforms: linux/amd64 push: false tags: guardrails:server-ci load: true build-args: | GUARDRAILS_TOKEN=${{ secrets.GUARDRAILS_API_KEY }} - name: Start Docker container run: | docker run -d --name guardrails-container -p 8000:8000 -e OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} guardrails:server-ci - name: Wait for Docker container to be ready run: | for i in {1..30}; do if docker exec guardrails-container curl -s http://localhost:8000/; then echo "Server is up!" break fi echo "Waiting for server..." sleep 5 done - name: Run Pytest run: | pip install pytest pytest-asyncio openai ".[api]" pytest server_ci/tests docker stop guardrails-container docker rm guardrails-container