Backend CI #6
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: Backend CI | |
| on: | |
| push: | |
| paths: | |
| - "backend/**" | |
| pull_request: | |
| paths: | |
| - "backend/**" | |
| workflow_dispatch: | |
| jobs: | |
| lint: | |
| name: 🔍 Lint & Format | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| pip install ruff | |
| - name: Run Ruff (linter) | |
| run: ruff check . | |
| - name: Run Ruff (formatter) | |
| run: ruff format --check . | |
| type-check: | |
| name: 🔎 Type Check | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| pip install mypy | |
| - name: Run mypy | |
| run: mypy app/ | |
| security: | |
| name: 🔒 Security | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: | | |
| pip install -r requirements.txt | |
| pip install bandit pip-audit | |
| - name: Run Bandit | |
| run: bandit -r app/ | |
| - name: Run pip-audit | |
| run: pip-audit -r requirements.txt | |
| smoke-test: | |
| name: 🚀 Smoke Test | |
| needs: lint | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: backend | |
| env: | |
| PROJECT_NAME: "NeSy" | |
| ENVIRONMENT: "development" | |
| NEO4J_URI: ${{ secrets.NEO4J_URI }} | |
| NEO4J_USERNAME: ${{ secrets.NEO4J_USERNAME }} | |
| NEO4J_PASSWORD: ${{ secrets.NEO4J_PASSWORD }} | |
| LLM_API_KEY: ${{ secrets.LLM_API_KEY }} | |
| LLM_BASE_URL: ${{ secrets.LLM_BASE_URL }} | |
| LLM_EXTRACTION_MODEL_NAME: ${{ secrets.LLM_EXTRACTION_MODEL_NAME }} | |
| LLM_XAI_MODEL_NAME: ${{ secrets.LLM_XAI_MODEL_NAME }} | |
| EMBEDDING_MODEL_NAME: ${{ secrets.EMBEDDING_MODEL_NAME }} | |
| HF_HUB_TOKEN: ${{ secrets.HF_HUB_TOKEN }} | |
| LLM_EXTRACTION_TEMPERATURE: "0.0" | |
| LLM_EXTRACTION_MAX_TOKENS: "1500" | |
| LLM_EXTRACTION_TOP_P: "1.0" | |
| LLM_EXTRACTION_SEED: "42" | |
| LLM_STREAM: "false" | |
| LLM_EXTRACTION_FORCE_JSON: "false" | |
| LLM_XAI_TEMPERATURE: "0.1" | |
| LLM_XAI_MAX_TOKENS: "2500" | |
| LLM_XAI_TOP_P: "1.0" | |
| LLM_XAI_SEED: "42" | |
| LLM_XAI_STREAM: "false" | |
| LLM_XAI_FORCE_JSON: "false" | |
| SEMANTIC_MATCHING_THRESHOLD: "0.9" | |
| MIN_MATCH: "2" | |
| SCORING_TOP_K: "5" | |
| SCORING_TOP_EXCLUDED: "3" | |
| ALLOWED_ORIGINS: "*" | |
| ALLOWED_METHODS: "*" | |
| ALLOWED_HEADERS: "*" | |
| ALLOW_CREDENTIALS: "false" | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Connect to Tailscale | |
| uses: tailscale/github-action@v2 | |
| with: | |
| oauth-client-id: ${{ secrets.TS_OAUTH_CLIENT_ID }} | |
| oauth-secret: ${{ secrets.TS_OAUTH_SECRET }} | |
| tags: tag:ci | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install dependencies | |
| run: pip install -r requirements.txt | |
| - name: Start FastAPI server | |
| run: | | |
| fastapi dev app/main.py & | |
| echo "Waiting for server to start..." | |
| sleep 15 | |
| - name: Check health endpoint | |
| run: | | |
| curl --fail --retry 5 --retry-delay 3 http://localhost:8000/health | |
| - name: Check root endpoint | |
| run: | | |
| curl --fail http://localhost:8000/ |