Skip to content

force floating input for xp.mean #18

force floating input for xp.mean

force floating input for xp.mean #18

Workflow file for this run

name: Unit tests
permissions:
contents: read
on:
push:
pull_request:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
VIRTUALENV: testvenv
TEST_DIR: ${{ github.workspace }}/tmp_folder
CCACHE_DIR: ${{ github.workspace }}/ccache
COVERAGE: 'true'
jobs:
lint:
name: Lint
runs-on: ubuntu-latest
if: github.repository == 'scikit-learn/scikit-learn'
steps:
- name: Checkout
uses: actions/checkout@v5
- uses: actions/setup-python@v6
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
retrieve-commit-message:
name: Retrieve the latest commit message
runs-on: ubuntu-latest
if: github.repository == 'scikit-learn/scikit-learn'
outputs:
message: ${{ steps.git-log.outputs.message }}
steps:
- uses: actions/checkout@v5
with:
ref: ${{ github.event.pull_request.head.sha }}
- id: git-log
name: Retrieve the latest commit message
shell: bash
run: |
set -eu
message=$(git log --format=%B -n 1)
{
echo 'message<<EOF'
echo "${message}"
echo EOF
} >> "${GITHUB_OUTPUT}"
retrieve-selected-tests:
# Parse the commit message to check if `build_tools/azure/test_script.sh` should run
# only specific tests.
#
# If so, selected tests will be run with SKLEARN_TESTS_GLOBAL_RANDOM_SEED="all".
#
# The commit message must take the form:
# <title> [all random seeds]
# <test_name_1>
# <test_name_2>
# ...
name: Retrieve the selected tests
runs-on: ubuntu-latest
if: github.repository == 'scikit-learn/scikit-learn'
outputs:
tests: ${{ steps.selected-tests.outputs.tests }}
needs: [retrieve-commit-message]
steps:
- id: selected-tests
name: Retrieve the selected tests
shell: python
env:
COMMIT_MESSAGE: ${{ needs.retrieve-commit-message.outputs.message }}
run: |
import os
commit_message = os.environ["COMMIT_MESSAGE"]
# Retrieve selected tests from commit message
if "[all random seeds]" in commit_message:
selected_tests = commit_message.split("[all random seeds]")[1].strip()
selected_tests = selected_tests.replace("\n", " or ")
# quote 'selected_tests' to cover the case of multiple selected tests
selected_tests = f"{selected_tests!r}"
else:
selected_tests = ""
# Write selected tests to `GITHUB_OUTPUT`
with open(os.environ["GITHUB_OUTPUT"], "a") as file:
file.write(f"tests={selected_tests}\n")
unit-tests:
name: ${{ matrix.name }}
runs-on: ${{ matrix.os }}
if: github.repository == 'scikit-learn/scikit-learn'
needs: [lint, retrieve-commit-message, retrieve-selected-tests]
strategy:
# Ensures that all builds run to completion even if one of them fails
fail-fast: false
matrix:
include:
- name: Linux pymin_conda_forge_arm
os: ubuntu-24.04-arm
DISTRIB: conda
LOCK_FILE: build_tools/github/pymin_conda_forge_arm_linux-aarch64_conda.lock
- name: macOS pylatest_conda_forge_arm
os: macOS-15
DISTRIB: conda
LOCK_FILE: build_tools/azure/pylatest_conda_forge_osx-arm64_conda.lock
SKLEARN_TESTS_GLOBAL_RANDOM_SEED: 5 # non-default seed
SCIPY_ARRAY_API: 1
PYTORCH_ENABLE_MPS_FALLBACK: 1
env: ${{ matrix }}
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Create cache for ccache
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-v1-${{ matrix.name }}-${{ hashFiles('**/*.pyx*', '**/*.pxd*', '**/*.pxi*', '**/*.h', '**/*.c', '**/*.cpp', format('{0}', matrix.LOCK_FILE)) }}
restore-keys: ccache-${{ matrix.name }}
- name: Set up conda
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-version: latest
auto-activate-base: true
activate-environment: ""
- name: Build scikit-learn
run: bash -l build_tools/azure/install.sh
- name: Run tests
env:
COMMIT_MESSAGE: ${{ needs.retrieve-commit-message.outputs.message }}
SELECTED_TESTS: ${{ needs.retrieve-selected-tests.outputs.tests }}
COVERAGE: ${{ env.COVERAGE == 'true' && needs.retrieve-selected-tests.outputs.tests == ''}}
run: bash -l build_tools/azure/test_script.sh
- name: Combine coverage reports from parallel test runners
run: bash -l build_tools/azure/combine_coverage_reports.sh
if: ${{ env.COVERAGE == 'true' && needs.retrieve-selected-tests.outputs.tests == ''}}
- name: Upload coverage report to Codecov
uses: codecov/codecov-action@v5
if: ${{ env.COVERAGE == 'true' && needs.retrieve-selected-tests.outputs.tests == ''}}
with:
files: ./coverage.xml
token: ${{ secrets.CODECOV_TOKEN }}
disable_search: true