link to Python::MODULE on macos too? #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Test | |
on: push | |
jobs: | |
build-and-test: | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- os: ubuntu | |
os_ver: "24.04" | |
config: Release | |
coverage: false | |
cc: gcc-14 | |
cxx: g++-14 | |
- os: ubuntu | |
os_ver: "22.04" | |
config: Release | |
coverage: false | |
cc: gcc-10 | |
cxx: g++-10 | |
- os: windows | |
os_ver: "2022" | |
config: Release | |
coverage: false | |
cc: cl | |
cxx: cl | |
- os: macos | |
os_ver: "14" | |
config: Release | |
coverage: false | |
cc: clang | |
cxx: clang++ | |
- os: macos | |
os_ver: "13" | |
config: Release | |
coverage: false | |
cc: clang | |
cxx: clang++ | |
- os: ubuntu | |
os_ver: "22.04" | |
config: Debug | |
coverage: true | |
cc: gcc-10 | |
cxx: g++-10 | |
defaults: | |
run: | |
shell: bash | |
name: ${{ matrix.os }}-${{ matrix.os_ver }} ${{ matrix.cxx }} ${{ matrix.config }} coverage=${{ matrix.coverage }} | |
env: | |
CC: ${{ matrix.cc }} | |
CXX: ${{ matrix.cxx }} | |
runs-on: ${{ matrix.os }}-${{ matrix.os_ver }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Project Name | |
run: echo "REPOSITORY_NAME=$(echo '${{ github.repository }}' | awk -F '/' '{print $2}')" >> $GITHUB_ENV | |
- name: Create Build Directory | |
run: cmake -E make_directory ${{github.workspace}}/build | |
- name: Set coverage variables | |
id: cov | |
run: | | |
if ${{matrix.coverage}}; then | |
echo "COVERAGE=ON" >> $GITHUB_OUTPUT | |
echo "STATIC_LIB=OFF" >> $GITHUB_OUTPUT | |
else | |
echo "COVERAGE=OFF" >> $GITHUB_OUTPUT | |
echo "STATIC_LIB=ON" >> $GITHUB_OUTPUT | |
fi | |
- name: Set up Python 3.12 | |
id: setup-python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Install System dependencies | |
shell: bash | |
run: | | |
set -x | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
echo "Using Apt to install swig" | |
sudo apt update | |
sudo apt install swig | |
elif [ "$RUNNER_OS" == "macOS" ]; then | |
echo "Using brew to install swig" | |
brew install swig | |
elif [ "$RUNNER_OS" == "Windows" ]; then | |
echo "Using chocolatey to swig" | |
choco install swig | |
fi; | |
- name: Configure CMake | |
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=${{ matrix.config }} -D${{ env.REPOSITORY_NAME }}_BUILD_TESTING=ON -D${{ env.REPOSITORY_NAME }}_STATIC_LIB=${{ steps.cov.outputs.STATIC_LIB }} -D${{ env.REPOSITORY_NAME }}_COVERAGE=${{ steps.cov.outputs.COVERAGE }} | |
- name: Build | |
run: | | |
cmake --build build --config ${{ matrix.config }} | |
- name: Test | |
run: ctest -C ${{ matrix.config }} --output-on-failure | |
working-directory: build | |
- name: Code Coverage Analysis | |
if: "matrix.coverage" | |
run: make gcov | |
working-directory: build | |
- name: Upload Code Coverage Report | |
if: "matrix.coverage" | |
uses: codecov/codecov-action@v3 | |
with: | |
flags: integration | |
functionalities: "gcov" | |
move_coverage_to_trash: true | |
- name: Build Python Wheel | |
working-directory: ./build/ | |
run: | | |
begin_group() { echo -e "::group::\033[93m$1\033[0m"; } | |
begin_group "Install other python dependencies" | |
python -m pip install --upgrade pip | |
pip install setuptools wheel twine requests packaging pytest | |
echo -e "::endgroup::" | |
begin_group "Build target" | |
cmake -DBUILD_PYTHON_BINDINGS:BOOL=ON . | |
cmake --build . --config ${{ matrix.config }} --target python_package | |
echo -e "::endgroup::" | |
- name: Zip the wheel to maintain case sensitivy and file permissions | |
working-directory: ./build/python | |
shell: bash | |
run: | | |
tar -cvzf btwxt-${{ matrix.os }}-${{ matrix.os_ver }}-{{ matrix.config }}.tar.gz dist/ | |
- name: Upload .whl to artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: btwxt-${{ matrix.os }}-${{ matrix.os_ver }}-{{ matrix.config }} | |
path: ./build/python/btwxt-${{ matrix.os }}-${{ matrix.os_ver }}-{{ matrix.config }}..tar.gz |