name: build

on:
  push:
    branches:
      - master
  pull_request:
    branches:
      - master
  schedule:
    - cron: 53 18 */10 * *

jobs:
  code-quality:
    name: Code quality checks for CleverCSV
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3

      # NOTE: Keep versions in sync with .pre-commit-config.yaml

      - name: Run black
        uses: psf/black@stable
        with:
          version: "23.3.0"

      - name: Run isort
        uses: jamescurtin/isort-action@master
        with:
          isortVersion: "5.12.0"

      - name: Run ruff
        uses: chartboost/ruff-action@v1
        with:
          version: "v0.0.261"

  python-test:
    needs: [code-quality]
    name: Tests
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ 'ubuntu-latest', 'macos-latest', 'windows-latest' ]
        py: [ '3.9', '3.14' ] # minimal and latest
    steps:
      - name: Install Python ${{ matrix.py }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.py }}

      - name: Checkout
        uses: actions/checkout@v3

      - name: Install CleverCSV
        run: pip install -e .[full,tests]

      - name: Run unit tests
        run: python -m unittest discover -v -f -s ./tests/test_unit
