name: Unit test for ARM
permissions:
  contents: read

on:
  push:
  pull_request:

concurrency:
  group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
  cancel-in-progress: true

jobs:
  lint:
    name: Lint
    runs-on: ubuntu-latest
    if: github.repository == 'jax-sklearn/jax-sklearn'

    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - uses: actions/setup-python@v5
        with:
          python-version: '3.12'
          cache: 'pip'
      - name: Install linters
        run: |
          source build_tools/shared.sh
          # Include pytest compatibility with mypy
          pip install pytest $(get_dep ruff min) $(get_dep mypy min) cython-lint
      - name: Run linters
        run: ./build_tools/linting.sh
      - name: Run Meson OpenMP checks
        run: |
          pip install ninja meson scipy
          python build_tools/check-meson-openmp-dependencies.py

  run-unit-tests:
    name: Run unit tests
    runs-on: ubuntu-24.04-arm
    if: github.repository == 'jax-sklearn/jax-sklearn'
    needs: [lint]
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - uses: mamba-org/setup-micromamba@v2
        with:
          environment-file: build_tools/github/pymin_conda_forge_arm_linux-aarch64_conda.lock
          environment-name: ci
          cache-environment: true

      - name: Build and run tests
        shell: bash -el {0}
        run: bash build_tools/github/build_test_arm.sh
