Skip to content

Commit

Permalink
Merge pull request #36 from esa/better-input-sanity
Browse files Browse the repository at this point in the history
Version 3 - Failsafe Polyhedral Gravity Modeling & Polyhedron Class
  • Loading branch information
schuhmaj authored Apr 22, 2024
2 parents 7700182 + bc7c21f commit cb34bbd
Show file tree
Hide file tree
Showing 58 changed files with 2,461 additions and 1,561 deletions.
66 changes: 66 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# Generated from CLion C/C++ Code Style settings
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: None
AlignOperands: Align
AllowAllArgumentsOnNextLine: false
AllowAllConstructorInitializersOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: Always
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: Always
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: true
AlwaysBreakAfterReturnType: None
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Custom
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterUnion: false
BeforeCatch: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeColon
BreakInheritanceList: BeforeColon
ColumnLimit: 0
CompactNamespaces: false
ContinuationIndentWidth: 8
IndentCaseLabels: true
IndentPPDirectives: None
IndentWidth: 4
KeepEmptyLinesAtTheStartOfBlocks: true
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PointerAlignment: Right
ReflowComments: false
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
SpaceBeforeRangeBasedForLoopColon: false
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 0
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Never
54 changes: 24 additions & 30 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,41 @@ on:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# Build & Test on Linux
build-and-test-linux:
runs-on: ubuntu-latest

# Build the C++ library & test that it is working using GoogleTest
build-and-test-cpp:
name: C/C++ Library on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-latest'
- name: Build
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
- name: Test
cmake --build . --config Release
- name: Test (Linux & macOS)
run: cd build/test && ./polyhedralGravity_test
if: matrix.os != 'windows-latest'

# Install the python interface by building from source and run pytest
pytest-linux:
runs-on: ubuntu-latest
# Install the python interface & test that it is working using pytest
build-and-test-python:
name: Python Interface on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
- name: Install Ninja Build
run: |
sudo apt-get install ninja-build -y
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-latest'
- name: Install Conda environment from environment.yml
uses: mamba-org/provision-with-micromamba@main
with:
Expand All @@ -44,22 +57,3 @@ jobs:
pip install . -vv --no-build-isolation
pytest -n 3
# Builds the polyhedral gravity python interface the interface
# No testing on Windows since it takes too long
# Enables the long paths feature on Windows (newer thrust versions require this)
build-windows:
runs-on: windows-latest
steps:
- uses: actions/checkout@v3
- uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: |
New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
git config --system core.longpaths true
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_POLYHEDRAL_PYTHON_INTERFACE=ON ..
cmake --build . --config Release
3 changes: 3 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ jobs:
- uses: actions/checkout@v3
with:
lfs: true
- name: Install polyhedral-gravity from recent source for sphinx.ext.autodoc
shell: bash -l {0}
run: pip install . -vv --no-build-isolation
- id: deployment
uses: sphinx-notes/pages@v3
with:
Expand Down
60 changes: 20 additions & 40 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ jobs:
os: [windows-latest, ubuntu-latest, macos-latest]
steps:
- uses: actions/checkout@v3
############################# LINUX WHEELS #############################
# In case of Linux we need to install compiler and build tools before building the wheels
# We further only build the manylinux wheels, but not the musllinux wheels
- name: Build wheels (Linux)
uses: pypa/cibuildwheel@v2.15.0
uses: pypa/cibuildwheel@v2.17.0
env:
CIBW_BEFORE_BUILD: yum makecache && yum install -y gcc-c++ cmake && pip install ninja
CIBW_BUILD: "*manylinux*"
Expand All @@ -34,23 +35,36 @@ jobs:
package-dir: .
output-dir: dist
if: matrix.os == 'ubuntu-latest'
############################# MACOS WHEELS #############################
# Building on macOS requires an installation of gcc since the default clang compiler
# lacks certain features required for building the package
- name: Build wheels (macOS)
uses: pypa/[email protected]
- name: Build wheels (macOS ARM)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: brew install ninja
CIBW_ARCHS_MACOS: "arm64"
CIBW_TEST_COMMAND: 'python -c "import polyhedral_gravity"'
with:
package-dir: .
output-dir: dist
if: matrix.os == 'macos-latest'
- name: Build wheels (macOS x86_64)
uses: pypa/[email protected]
env:
CIBW_BEFORE_BUILD: brew install ninja gcc@12
CIBW_ENVIRONMENT: "CC=gcc-12 CXX=g++-12"
CIBW_ARCHS_MACOS: "x86_64"
CIBW_TEST_COMMAND: 'python -c "import polyhedral_gravity"'
with:
package-dir: .
output-dir: dist
if: matrix.os == 'macos-latest'
############################# WINDOWS WHEELS #############################
# Set up the Visual Studio environment on Windows (required, so that CMake finds the compiler)
- uses: ilammy/msvc-dev-cmd@v1
if: matrix.os == 'windows-latest'
- name: Build wheels (Windows)
uses: pypa/cibuildwheel@v2.15.0
uses: pypa/cibuildwheel@v2.17.0
env:
CIBW_BEFORE_BUILD: choco install -y ninja cmake
CIBW_ARCHS_WINDOWS: "auto64"
Expand Down Expand Up @@ -94,44 +108,10 @@ jobs:
with:
repository-url: https://test.pypi.org/legacy/

# 3. Check if the package can be installed from testpypi
# Notice, that this is more of an installation test since the
# import check has already been done in the build_wheels job
check_testpypi:
needs: [upload_testpypi]
name: Test import on ${{ matrix.os }} with ${{ matrix.py }}
runs-on: ${{ matrix.os }}
if: always()
strategy:
fail-fast: false
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
py:
[
3.7.x,
3.8.x,
3.9.x,
3.10.x,
3.11.x,
pypy3.7,
pypy3.8,
pypy3.9,
pypy3.10,
]
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py }}
- name: Install package from testpypi
run: pip install --index-url https://test.pypi.org/simple/ polyhedral-gravity
- name: Check import
run: python -c "import polyhedral_gravity"

# 4. Upload the wheels to the actually Python Package Index
# 3. Upload the wheels to the actually Python Package Index
# using trusted publishing
upload_pypi:
needs: [build_wheels, make_sdist, check_testpypi]
needs: [build_wheels, make_sdist, upload_testpypi]
environment:
name: pypi
url: https://pypi.org/p/polyhedral-gravity
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
cmake-build-*
build
polyhedral_gravity.egg-info
dist
dist
docs/Doxyfile
Loading

0 comments on commit cb34bbd

Please sign in to comment.