name: Multiple OS tests

on:
  push:
    branches:
      - main
      - 'mq-working-branch**'
  pull_request:
  workflow_dispatch: {}

jobs:
  multiple_os_tests:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
        # Keep this in sync with hatch.toml
        python-version: ["3.8", "3.10", "3.12", "3.14"]

    steps:
      - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
        # Include all history and tags
        with:
          persist-credentials: false
          fetch-depth: 0

      - uses: actions-rust-lang/setup-rust-toolchain@9d7e65c320fdb52dcd45ffaa68deb6c02c8754d9 # v1.12.0
      - name: Install latest stable toolchain and rustfmt
        run: rustup update stable && rustup default stable && rustup component add rustfmt clippy

      - name: Install hatch
        uses: pypa/hatch@257e27e51a6a5616ed08a39a408a21c35c9931bc # install
        with:
          version: "1.12.0"

      - name: Install coreutils for MacOS to get sha256sum
        if: matrix.os == 'macos-latest'
        run: brew install coreutils

      - name: Install dependencies
        if: matrix.os == 'ubuntu-latest' && matrix.python-version == '3.14'
        run: |
          sudo add-apt-repository ppa:deadsnakes/ppa
          sudo apt-get update
          sudo apt-get install -y python3.14 python3.14-dev

      - name: Run tests
        run: hatch run +py=${{ matrix.python-version }} multiple_os_tests:test

  finished:
    name: Multiple OS Tests Finished
    runs-on: ubuntu-latest
    needs: multiple_os_tests
    steps:
      - name: True when successful
        if: needs.multiple_os_tests.result == 'success'
        run: exit 0
      - name: Fails if anything else failed
        if: needs.multiple_os_tests.result != 'success'
        run: exit 1
