-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI for unit tests, flake8, wheels/sdist. (#2)
- Loading branch information
Showing
8 changed files
with
348 additions
and
8 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Cache Boost | ||
description: Caches Boost for an OS and a Boost minor version | ||
inputs: | ||
boost_minor: | ||
required: true | ||
os: | ||
required: true | ||
outputs: | ||
cache-hit: | ||
description: "Indicates if caching was successful" | ||
value: ${{ steps.cache-boost.outputs.cache-hit }} | ||
location: | ||
description: "The path where Boost ends up" | ||
value: "${{ github.workspace }}/boost" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Cache Boost | ||
uses: actions/cache@v3 | ||
id: cache-boost | ||
env: | ||
cache-name: cache-boost | ||
with: | ||
path: ${{ github.workspace }}/boost | ||
key: ${{ inputs.os }}-boost-${{ inputs.boost_minor }} | ||
|
||
- name: Install Boost | ||
if: steps.cache-boost.outputs.cache-hit != 'true' | ||
shell: bash | ||
run: | | ||
wget -qO- https://boostorg.jfrog.io/artifactory/main/release/1.${{ inputs.boost_minor }}.0/source/boost_1_${{ inputs.boost_minor }}_0.tar.bz2 | tar xjf - | ||
cd boost_1_${{ inputs.boost_minor }}_0 | ||
./bootstrap.sh | ||
./b2 --prefix=../boost --with-serialization --with-filesystem --with-test install |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
name: Set up MPI | ||
description: Allows to use MPI in Github Actions by configuring oversubscription | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Set up MPI for Github Actions | ||
shell: bash | ||
run: | | ||
mkdir -p "$HOME/.openmpi" | ||
cat <<EOF > "$HOME/.openmpi/mca-params.conf" | ||
rmaps_base_oversubscribe = true | ||
rmaps_default_mapping_policy = :oversubscribe | ||
EOF |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
name: Run C++ tests | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: ["ubuntu-latest", "macos-14"] | ||
boost_minor: [85] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
|
||
- name: Install Ubuntu system dependencies | ||
if: startsWith(matrix.os, 'ubuntu-') | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install ninja-build libopenmpi-dev | ||
- name: Install MacOs system dependencies | ||
if: startsWith(matrix.os, 'macos-') | ||
run: | | ||
brew install ninja openmpi | ||
- uses: ./.github/actions/boost-cache | ||
id: cache-boost | ||
with: | ||
os: ${{ matrix.os }} | ||
boost_minor: ${{ matrix.boost_minor }} | ||
|
||
- name: Configure and build | ||
run: | | ||
cmake -B build -G Ninja -DCMAKE_PREFIX_PATH=${{ steps.cache-boost.outputs.location }} . | ||
cmake --build build | ||
- uses: ./.github/actions/mpi-setup | ||
|
||
- name: Run CTest | ||
run: | | ||
ctest --test-dir build --output-on-failure |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Run all tests | ||
|
||
on: | ||
push: | ||
branches: ['main'] | ||
tags: ['v?[0-9]+.[0-9]+.[0-9]+'] | ||
pull_request: | ||
|
||
jobs: | ||
cache_boost: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: ["ubuntu-latest", "macos-14"] | ||
boost_minor: [85] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- uses: ./.github/actions/boost-cache | ||
id: cache-boost | ||
with: | ||
os: ${{ matrix.os }} | ||
boost_minor: ${{ matrix.boost_minor }} | ||
|
||
test_cxx: | ||
uses: ./.github/workflows/ctest.yml | ||
secrets: inherit | ||
needs: [cache_boost] | ||
|
||
test_python: | ||
uses: ./.github/workflows/test.yml | ||
secrets: inherit | ||
needs: [cache_boost] | ||
|
||
publish: | ||
uses: ./.github/workflows/publish.yml | ||
secrets: inherit | ||
needs: [cache_boost] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,142 @@ | ||
name: Publish wheels and sdist tarball to PyPi | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build_sdist: | ||
name: Build source distribution | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Build a source tarball | ||
run: | | ||
python -m pip install build | ||
python -m build -s | ||
- name: Store sdist as artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/*.tar.gz | ||
|
||
test_sdist: | ||
name: Test source distribution | ||
|
||
runs-on: ubuntu-latest | ||
needs: [build_sdist] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
|
||
- name: Download artifacts produced during the build_wheels and build_sdist jobs | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- uses: ./.github/actions/boost-cache | ||
id: cache-boost | ||
with: | ||
os: ubuntu-latest | ||
boost_minor: 85 | ||
|
||
- name: Install system dependencies | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y libopenmpi-dev | ||
- uses: ./.github/actions/mpi-setup | ||
|
||
- name: Install package, clean local directory | ||
run: | | ||
export CMAKE_PREFIX_PATH=${{ steps.cache-boost.outputs.location }} | ||
export SKBUILD_CMAKE_DEFINE="CMAKE_INSTALL_RPATH_USE_LINK_PATH=ON" | ||
python -m pip install dist/* | ||
python -m pip install mock mpi4py pytest pytest-mpi pytest-xdist | ||
- name: Run tests | ||
run: | | ||
pytest -n 3 tests | ||
build_wheels: | ||
name: Build wheels on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
submodules: true | ||
fetch-depth: 0 | ||
|
||
# Used to host cibuildwheel | ||
- uses: actions/setup-python@v5 | ||
|
||
- name: Install cibuildwheel | ||
run: python -m pip install cibuildwheel==2.18.1 | ||
|
||
- name: Build wheels | ||
run: python -m cibuildwheel --output-dir dist | ||
env: | ||
CIBW_TEST_COMMAND: "pytest {project}/tests" | ||
|
||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: cibw-wheels-${{ matrix.os }}-${{ strategy.job-index }} | ||
path: ./dist/*.whl | ||
|
||
publish: | ||
name: Publish package to PyPI | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags') | ||
|
||
runs-on: ubuntu-latest | ||
needs: [build_wheels, build_sdist, test_sdist] | ||
|
||
environment: | ||
name: publish_pypi | ||
url: https://pypi.org/p/brain-indexer | ||
|
||
permissions: | ||
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | ||
|
||
steps: | ||
- name: Download artifacts produced by the build_sdist job | ||
uses: actions/download-artifact@v3 | ||
with: | ||
name: dist | ||
path: dist/ | ||
|
||
- name: Download artifacts produced by the build_wheels job | ||
uses: actions/download-artifact@v3 | ||
with: | ||
pattern: cibw-wheels-* | ||
path: dist/ | ||
merge-multiple: true | ||
|
||
- name: Display structure of downloaded files | ||
run: ls -R | ||
working-directory: dist | ||
|
||
- name: Publish source distribution package to PyPI | ||
uses: pypa/gh-action-pypi-publish@release/v1 | ||
with: | ||
packages_dir: dist/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: Run Python tests and lint | ||
|
||
on: | ||
workflow_call: | ||
|
||
jobs: | ||
build: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
os: ["ubuntu-latest", "macos-14"] | ||
boost_minor: [85] | ||
python-version: ['3.11', '3.12'] | ||
toxenv: ['py3'] | ||
include: | ||
- os: 'ubuntu-latest' | ||
python-version: '3.12' | ||
toxenv: 'flake8' | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: true | ||
|
||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Install Ubuntu system dependencies | ||
if: startsWith(matrix.os, 'ubuntu-') | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install libopenmpi-dev | ||
- name: Install MacOs system dependencies | ||
if: startsWith(matrix.os, 'macos-') | ||
run: | | ||
brew install openmpi | ||
- uses: ./.github/actions/boost-cache | ||
id: cache-boost | ||
with: | ||
os: ${{ matrix.os }} | ||
boost_minor: ${{ matrix.boost_minor }} | ||
|
||
- name: Install Python dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
python -m pip install tox | ||
- name: Test with tox | ||
run: | | ||
export CMAKE_PREFIX_PATH=${{ steps.cache-boost.outputs.location }} | ||
export SKBUILD_CMAKE_DEFINE="CMAKE_INSTALL_RPATH_USE_LINK_PATH=ON" | ||
tox -e ${{ matrix.toxenv }} |
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
Oops, something went wrong.