Merge pull request #1202 from guardrails-ai/fix-watch #57
This file contains 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 | |
steps: | |
- name: Check out head | |
uses: actions/checkout@v3 | |
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:${{ github.sha }} | |
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:${{ github.sha }} | |
- 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 openai guardrails-ai | |
pytest server_ci/tests | |
docker stop guardrails-container | |
docker rm guardrails-container |