Skip to content

Add building wheels using cibuildwheel #2022

Add building wheels using cibuildwheel

Add building wheels using cibuildwheel #2022

Workflow file for this run

name: NMODL CI
concurrency:
group: ${{ github.workflow }}#${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- master
- release/**
pull_request:
branches:
- master
- release/**
env:
CTEST_PARALLEL_LEVEL: 1
PYTHON_VERSION: 3.8
DESIRED_CMAKE_VERSION: 3.15.0
jobs:
ci:
runs-on: ${{matrix.config.os}}
name: ${{toJson(matrix.config)}}
strategy:
matrix:
include:
- config:
os: ubuntu-20.04
- config:
flag_warnings: ON
os: ubuntu-22.04
- config:
os: macos-12
- config:
os: macos-13
# TODO: might be interesting to add the thread sanitizer too
- config:
os: ubuntu-22.04
# Hyphens here will be replaced with commas before the value is
# passed to NMODL_SANITIZERS
sanitizer: address-leak
- config:
os: ubuntu-22.04
enable_usecases: On
- config:
flag_warnings: ON
os: ubuntu-22.04
sanitizer: undefined
fail-fast: true
steps:
- name: Setup cmake
uses: jwlawson/actions-setup-cmake@v2
with:
cmake-version: ${{ env.DESIRED_CMAKE_VERSION }}
- name: Install homebrew packages
if: startsWith(matrix.config.os, 'macOS')
run: |
brew install ccache coreutils bison boost flex ninja
echo /usr/local/opt/flex/bin:/usr/local/opt/bison/bin >> $GITHUB_PATH
# Taken from https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=3 >> $GITHUB_ENV
shell: bash
- name: Install apt packages
if: startsWith(matrix.config.os, 'ubuntu')
run: |
sudo apt-get install bison ccache flex libfl-dev ninja-build python3-dev python3-pip
# Taken from https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources
echo CMAKE_BUILD_PARALLEL_LEVEL=2 >> $GITHUB_ENV
shell: bash
- name: Set up Python3
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- uses: actions/checkout@v4
- name: Install Python3 dependencies
working-directory: ${{runner.workspace}}/nmodl
run: |
python3 -m pip install -U pip setuptools
python3 -m pip install --user -r requirements.txt
- name: Install neuron-nightly
if: ${{matrix.config.enable_usecases == 'On'}}
run: |
python3 -m pip install neuron-nightly
- name: Register compiler warning problem matcher
if: ${{matrix.config.flag_warnings == 'ON'}}
run: echo "::add-matcher::.github/problem-matchers/gcc.json"
- name: Register sanitizer problem matcher
if: ${{matrix.config.sanitizer}}
run: echo "::add-matcher::.github/problem-matchers/${{matrix.config.sanitizer}}.json"
- name: Configure
shell: bash
working-directory: ${{runner.workspace}}/nmodl
run: |
echo "------- Configure -------"
mkdir build && pushd build
cmake_args=(-G Ninja
-DPYTHON_EXECUTABLE=$(which python3) \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR)
if [[ -n "${{matrix.config.flag_warnings}}" ]]; then
cmake_args+=(-DNMODL_EXTRA_CXX_FLAGS="-Wall \
-Wno-reorder \
-Wno-unknown-pragmas \
-Wno-sign-compare \
-Wno-overloaded-virtual")
fi
if [[ -n "${{matrix.config.enable_usecases}}" ]]; then
cmake_args+=(-DNMODL_ENABLE_USECASES=${{matrix.config.enable_usecases}})
fi
if [[ -n "${{matrix.config.sanitizer}}" ]]; then
cmake_args+=(-DCMAKE_BUILD_TYPE=Custom \
-DCMAKE_CXX_FLAGS="-O1 -g" \
-DNMODL_SANITIZERS=$(echo ${{matrix.config.sanitizer}} | sed -e 's/-/,/g'))
CXX=$(command -v clang++-14)
else
CXX=${CXX:-g++}
fi
cmake_args+=(-DCMAKE_CXX_COMPILER=${CXX} \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
cmake_args+=(-DNMODL_ENABLE_BACKWARD=On)
cmake .. "${cmake_args[@]}"
env:
INSTALL_DIR: ${{ runner.workspace }}/install
- name: Dump config dictionary
run: |
cat << EOF > matrix.json
${{toJSON(matrix.config)}}
EOF
echo matrix.config JSON:
cat matrix.json
echo -----
- name: Restore compiler cache
uses: actions/cache@v4
with:
path: |
${{runner.workspace}}/ccache
key: ${{hashfiles('matrix.json')}}-${{github.ref}}-${{github.sha}}
restore-keys: |
${{hashfiles('matrix.json')}}-${{github.ref}}-
${{hashfiles('matrix.json')}}-
save-always: true
- name: Build
shell: bash
working-directory: ${{runner.workspace}}/nmodl/build
env:
CCACHE_BASEDIR: ${{runner.workspace}}/nmodl
CCACHE_DIR: ${{runner.workspace}}/ccache
PYTHONMALLOC: malloc
run: |
if ccache --version | grep -E '^ccache version 4\.(4|4\.1)$'
then
echo "------- Disable ccache direct mode -------"
# https://github.com/ccache/ccache/issues/935
export CCACHE_NODIRECT=1
fi
echo "------- Building -------"
ccache -z
# Older versions don't support -v (verbose)
ccache -vs 2>/dev/null || ccache -s
cmake --build .
ccache -vs 2>/dev/null || ccache -s
- name: Test
shell: bash
working-directory: ${{runner.workspace}}/nmodl/build
env:
PYTHONMALLOC: malloc
run: |
ctest --output-on-failure -T Test
- name: Install
shell: bash
working-directory: ${{runner.workspace}}/nmodl/build
run: |
cmake --build . --target install
- uses: actions/upload-artifact@v4
with:
name: ctest-results-${{hashfiles('matrix.json')}}
path: ${{runner.workspace}}/nmodl/build/Testing/*/Test.xml
# This step will set up an SSH connection on tmate.io for live debugging.
# To enable it, you have to:
# * add 'live-debug-tests' to your PR title
# * push something to your PR branch (note that just re-running disregards the title update)
- name: live debug session on failure (manual steps required, check `nmodl-ci.yml`)
if: failure() && contains(github.event.pull_request.title, 'live-debug-tests')
uses: mxschmitt/action-tmate@v3
timeout-minutes: 60