name: XGBoost CI (Python tests)

on: [push, pull_request]

permissions:
  contents: read # to fetch code (actions/checkout)

defaults:
  run:
    shell: bash -l {0}

concurrency:
  group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
  cancel-in-progress: true

jobs:
  python-sdist-test:
    runs-on: ${{ matrix.os }}
    name: Test installing Python XGBoost from the source distribution (${{ matrix.os }})
    strategy:
      fail-fast: false
      matrix:
        os: [macos-13, windows-latest, ubuntu-latest]
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: 'true'
      - uses: dmlc/xgboost-devops/actions/miniforge-setup@main
        with:
          environment-name: sdist_test
          environment-file: ops/conda_env/sdist_test.yml
      - name: Install extra package for MacOS
        run: |
          mamba install -c conda-forge llvm-openmp
        if: matrix.os == 'macos-13'
      - name: Build and install XGBoost
        run: bash ops/pipeline/test-python-sdist.sh

  python-tests-on-macos:
    name: Test XGBoost Python package on macos-13
    runs-on: macos-13
    timeout-minutes: 60
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: 'true'
      - uses: dmlc/xgboost-devops/actions/miniforge-setup@main
        with:
          environment-name: macos_cpu_test
          environment-file: ops/conda_env/macos_cpu_test.yml
      - run: bash ops/pipeline/test-python-macos.sh

  python-system-installation-on-ubuntu:
    name: Test XGBoost Python package System Installation on Ubuntu
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: 'true'
      - name: Set up Python 3.10
        uses: actions/setup-python@v5
        with:
          python-version: "3.10"
      - run: bash ops/pipeline/test-python-with-sysprefix.sh
