name: CI

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main, develop]

jobs:
  lint-and-test:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: https://gitea.com/actions/checkout@v4

      - name: Set up Python 3.12
        uses: https://gitea.com/actions/setup-python@v5
        with:
          python-version: "3.12"

      - name: Install dependencies
        run: |
          pip install -r requirements.txt -r requirements-dev.txt

      - name: Install lint and security tools
        run: |
          pip install ruff bandit

      - name: Set up Node.js
        uses: https://gitea.com/actions/setup-node@v4
        with:
          node-version: "20"

      - name: Webapp (Next.js) build and test
        run: |
          cd webapp-next && npm ci && npm test && npm run build

      - name: Lint with Ruff
        run: |
          ruff check duty_teller tests

      - name: Run tests
        env:
          PYTHONPATH: .
        run: |
          pytest tests/ -v

      - name: Security check with Bandit
        run: |
          bandit -r duty_teller -ll
