Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix macos wheel building and coverage reporting #514

Merged
merged 23 commits into from
Feb 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ jobs:

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: wheelhouse/*.whl

build_wheels_macos:
name: Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash -el {0}
strategy:
fail-fast: false
matrix:
Expand All @@ -56,6 +60,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true

- name: Setup openmp for macOS
run: |
# Make sure to use a libomp version binary compatible with the oldest
Expand All @@ -65,11 +74,13 @@ jobs:
# supported macos version is: High Sierra / 10.13. When upgrading
# this, be sure to update the MACOSX_DEPLOYMENT_TARGET environment
# variable accordingly. Note that Darwin_17 == High Sierra / 10.13.
if [[ "$CIBW_ARCHS_MACOS" == arm64 ]]; then
# arm64 builds must cross compile because the CI instance is x86
# This turns off the computation of the test program in
# tools/build_helpers.py
echo "PYTHON_CROSSENV=1" >> "$GITHUB_ENV"
if [[ "$CIBW_BUILD" == *-macosx_arm64 ]]; then
if [[ $(uname -m) == "x86_64" ]]; then
# arm64 builds must cross compile because the CI instance is x86
# This turns off the computation of the test program in
# tools/build_helpers.py
echo "PYTHON_CROSSENV=1" >> "$GITHUB_ENV"
fi

# SciPy requires 12.0 on arm to prevent kernel panics
# https://github.com/scipy/scipy/issues/14688
Expand All @@ -84,18 +95,22 @@ jobs:
# use conda to install llvm-openmp
# Note that we do NOT activate the conda environment, we just add the
# library install path to CFLAGS/CXXFLAGS/LDFLAGS below.
sudo conda create -n build $OPENMP_URL
PREFIX="/usr/local/miniconda/envs/build"
echo "CC=/usr/bin/clang" >> "$GITHUB_ENV"
echo "CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"" >> "$GITHUB_ENV"
echo "CFLAGS="$CFLAGS -Wno-implicit-function-declaration -I$PREFIX/include"" >> "$GITHUB_ENV"
echo "LDFLAGS="$LDFLAGS -Wl,-S -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"" >> "$GITHUB_ENV"
conda create -n build $OPENMP_URL
PREFIX="$HOME/miniconda/envs/build"

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
export CPPFLAGS="$CPPFLAGS -Xpreprocessor -fopenmp"
export CFLAGS="$CFLAGS -I$PREFIX/include"
export CXXFLAGS="$CXXFLAGS -I$PREFIX/include"
export LDFLAGS="$LDFLAGS -Wl,-rpath,$PREFIX/lib -L$PREFIX/lib -lomp"

- name: Build wheels
uses: pypa/[email protected]

- uses: actions/upload-artifact@v4
with:
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }}
path: wheelhouse/*.whl

build_sdist:
Expand Down
43 changes: 38 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ jobs:
test:
runs-on: ubuntu-latest
strategy:
#max-parallel: 10
matrix:
config:
- python: "3.10"
- python: "3.11"
- python: "3.12"

split: [1, 2, 3, 4, 5, 6, 7, 8]
Expand Down Expand Up @@ -49,10 +47,45 @@ jobs:

- name: Test with pytest
run: |
pytest --splits 8 --group ${{ matrix.split }} --durations-path tests/.test_durations tests
pytest --cov=smol --splits 8 --group ${{ matrix.split }} --durations-path tests/.test_durations tests

- if: ${{ matrix.config.python == '3.11' && github.event_name == 'push' }}
name: codacy-coverage-reporter
- name: Upload coverage
if: ${{ matrix.config.python == '3.12' && github.event_name == 'push' }}
uses: actions/upload-artifact@v4
with:
include-hidden-files: true
name: .coverage${{ matrix.split }}
path: .coverage
if-no-files-found: error

coverage:
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: 3.12

- name: Install coverage
run: |
python -m pip install --upgrade pip
pip install coverage

- name: Download all artifacts
# Downloads coverage1, coverage2, etc.
uses: actions/download-artifact@v4
with:
pattern: .coverage*
merge-multiple: true
path: coverage
- name: Run coverage
run: |
coverage combine coverage/.coverage*
coverage xml
# coverage report --fail-under=85
- name: codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
Expand Down
Loading