UPDATING README.md #93
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: CI | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| jobs: | |
| test: | |
| name: Lint & Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python 3.10 | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.10" | |
| - name: Install Torch CPU | |
| run: | | |
| pip install --upgrade pip | |
| pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu | |
| - name: Install requirements | |
| run: | | |
| pip install stable-baselines3 | |
| pip install -r requirements.txt | |
| pip install pytest pytest-asyncio httpx | |
| - name: Run tests | |
| run: python -m pytest tests/ -v --tb=short | |
| docker-build: | |
| name: Docker Build Check | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Build Docker image | |
| run: docker build -t safetyguard-x:ci . | |
| - name: Smoke test – health endpoint | |
| run: | | |
| docker run -d --name sgx-ci -p 7860:7860 safetyguard-x:ci | |
| echo "Waiting for server to start (max 90s)..." | |
| SUCCESS=0 | |
| for i in {1..18}; do | |
| if curl -s -f http://localhost:7860/health; then | |
| echo "Server is up!" | |
| SUCCESS=1 | |
| break | |
| fi | |
| echo "Waiting... ($((i*5))s)" | |
| sleep 5 | |
| done | |
| if [ $SUCCESS -eq 0 ]; then | |
| echo "FAILED: Server did not start in time." | |
| docker logs sgx-ci | |
| exit 1 | |
| fi | |
| docker stop sgx-ci |