name: Checks

on: workflow_call

jobs:

  format-job:

    name: "Format (Python-${{ matrix.python-version }} on ${{ matrix.os }})"
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: true
      matrix:
        os:
          - ubuntu-latest
        python-version:
          - "3.8"

    steps:
      - name: SCM Checkout
        uses: actions/checkout@v4

      - name: Setup Python & Poetry Environment
        uses: ./.github/actions/python-environment
        with:
          python-version: ${{ matrix.python-version }}

      - name: Run Coverage
        run: poetry run invoke check.format

  typing-job:

    name: "Typing (Python-${{ matrix.python-version }} on ${{ matrix.os }})"
    needs: [format-job]
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: true
      matrix:
        os:
          - ubuntu-latest
        python-version:
          - "3.8"
          - "3.9"
          - "3.10"
          - "3.11"
          - "3.12"

    steps:
      - name: SCM Checkout
        uses: actions/checkout@v4

      - name: Setup Python & Poetry Environment
        uses: ./.github/actions/python-environment
        with:
          python-version: ${{ matrix.python-version }}

      - name: Run Coverage
        run: poetry run invoke check.typing --files src/

  linting-job:

    name: "Lint (Python-${{ matrix.python-version }} on ${{ matrix.os }})"
    needs: [format-job]
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: true
      matrix:
        os:
          - ubuntu-latest
        python-version:
          - "3.8"

    steps:
      - name: SCM Checkout
        uses: actions/checkout@v4

      - name: Setup Python & Poetry Environment
        uses: ./.github/actions/python-environment
        with:
          python-version: ${{ matrix.python-version }}

      - name: Run Linter
        run: poetry run invoke check.lint --files src/

  tests-job:

    name: "Tests (Python-${{ matrix.python-version }} on ${{ matrix.os }})"
    needs: [format-job, linting-job, typing-job]
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: true
      matrix:
        os:
          - ubuntu-latest
          - macos-latest
          - windows-latest
        python-version:
          - "3.8"
          - "3.9"
          - "3.10"
          - "3.11"
          - "3.12"

    steps:
      - name: SCM Checkout
        uses: actions/checkout@v4

      - name: Setup Python & Poetry Environment
        uses: ./.github/actions/python-environment
        with:
          python-version: ${{ matrix.python-version }}

      - name: Run Tests
        run: poetry run invoke test.coverage
