Merge pull request #1325 from guardrails-ai/remove-venv #95
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: Server CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| jobs: | |
| build-test-server: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| tag: ["fastapi", "flask"] | |
| 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.${{ matrix.tag }} | |
| platforms: linux/amd64 | |
| push: false | |
| tags: guardrails:${{ matrix.tag }} | |
| 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:${{ matrix.tag }} | |
| - 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 guardrails-ai | |
| pytest server_ci/tests | |
| docker stop guardrails-container | |
| docker rm guardrails-container |