# This workflow becomes active only after an isolated Gitea Actions runner is
# deliberately registered. No runner is installed on the production server.
name: CI

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

jobs:
  python-tests:
    name: Python ${{ matrix.python-version }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ["3.9", "3.12"]
    defaults:
      run:
        working-directory: flashops
    env:
      PYTHONPATH: ${{ gitea.workspace }}/flashops/services/control-plane:${{ gitea.workspace }}/flashops/services/host-agent
    steps:
      - name: Check out repository
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
          cache: pip
          cache-dependency-path: flashops/services/control-plane/requirements.txt

      - name: Install dependencies
        run: python -m pip install -r services/control-plane/requirements.txt

      - name: Run tests
        run: python -m pytest services/control-plane/tests services/host-agent/tests -q

      - name: Compile Python modules
        run: python -m compileall -q services/control-plane/flashops_control services/host-agent/flashops_agent
