Skip to content

Commit

Permalink
V21.12 (#16)
Browse files Browse the repository at this point in the history
* FIX: add ci.yml workflow to compile plugin for different platforms and build/test corrections
  • Loading branch information
sergeiNikolaev authored Jul 8, 2022
1 parent 4cd8b3b commit 7586b47
Show file tree
Hide file tree
Showing 15 changed files with 309 additions and 80 deletions.
202 changes: 202 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,202 @@
name: Benchmark_tests

on:
workflow_dispatch:
pull_request:
push:
#schedule:
# - cron: '00 2 * * *'


jobs:
build_and_test:
name: Building on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-20.04, macos-10.15, windows-2019]
sofa_branch: [v21.12] # master
python-version: ['3.10']

steps:
- name: Setup SOFA and environment
id: sofa
uses: sofa-framework/sofa-setup-action@v4
with:
sofa_root: /opt/sofa
sofa_version: ${{ matrix.sofa_branch }}
sofa_scope: 'standard'

- name: Checkout source code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}

- name: Install requirements
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
EIGEN_VERSION=3.4.0
EIGEN_INSTALL_DIR="C:/eigen"
if ! ls -a "$EIGEN_INSTALL_DIR"/* >/dev/null 2>&1; then
# directory does not exist or is empty
mkdir -p "$EIGEN_INSTALL_DIR"
curl --output "${{ runner.temp }}/eigen_tmp.zip" -L \
"https://gitlab.com/libeigen/eigen/-/archive/${EIGEN_VERSION}/eigen-${EIGEN_VERSION}.zip"
unzip -qq "${{ runner.temp }}/eigen_tmp.zip" -d "${{ runner.temp }}/eigen_tmp"
mv "${{ runner.temp }}"/eigen_tmp/eigen-*/* $EIGEN_INSTALL_DIR
fi
mkdir $EIGEN_INSTALL_DIR/build_release \
&& cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
&& cd /d $EIGEN_INSTALL_DIR/build_release \
&& cmake -GNinja -DCMAKE_BUILD_TYPE=Release .. \
&& ninja install"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew install eigen
elif [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt install -qq libeigen3-dev libblas-dev libglew-dev
fi
python3 -m pip install --upgrade pip
python3 -m pip install numpy pyyaml
- name: Build pybind11
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
PYBIND_INSTALL_PATH="C:/pybind11" \
&& git clone -b v2.8 --depth 1 https://github.com/pybind/pybind11.git $PYBIND_INSTALL_PATH \
&& cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
&& cd /d $PYBIND_INSTALL_PATH \
&& cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPYBIND11_TEST=OFF . \
&& ninja install"
else
PYBIND_INSTALL_PATH="/tmp/pybind11"
git clone -b v2.8 --depth 1 https://github.com/pybind/pybind11.git $PYBIND_INSTALL_PATH
cd $PYBIND_INSTALL_PATH
echo "Curent plugin branch is:" && git branch --show-current
cmake -DCMAKE_BUILD_TYPE=Release -DPYBIND11_TEST=OFF .
make
sudo make install
fi
- name: Build python3 plugin
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
SOFA_PYTHON3_ROOT="C:/SofaPython3" \
&& git clone --branch ${{ steps.sofa.outputs.sofa_version }} https://github.com/sofa-framework/SofaPython3.git $SOFA_PYTHON3_ROOT \
&& mkdir $SOFA_PYTHON3_ROOT/build_release \
&& cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
&& cd /d $SOFA_PYTHON3_ROOT/build_release \
&& cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPYTHON_ROOT=$PYTHON_ROOT -DPython_ROOT=$PYTHON_ROOT -DPYTHON_EXECUTABLE=$PYTHON_ROOT/python.exe \
-DPython_EXECUTABLE=$PYTHON_ROOT/python.exe -DCMAKE_PREFIX_PATH="$SOFA_ROOT/build_release/install" .. \
&& ninja install"
else
export SOFA_PYTHON3_ROOT=/tmp/SofaPython3
git clone --branch ${{ steps.sofa.outputs.sofa_version }} https://github.com/sofa-framework/SofaPython3.git $SOFA_PYTHON3_ROOT
mkdir $SOFA_PYTHON3_ROOT/build_release
cd $SOFA_PYTHON3_ROOT/build_release
echo "Curent plugin branch is:" && git branch --show-current
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$SOFA_ROOT/build_release/install ..
make -j 8
make install
fi
- name: Build Optimus
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
EIGEN_INSTALL_DIR="C:/eigen" \
&& echo "GITHUB_WORKSPACE = $GITHUB_WORKSPACE" \
&& mkdir $GITHUB_WORKSPACE/build_release \
&& cmd //c "${{ steps.sofa.outputs.vs_vsdevcmd }} \
&& cd /d $GITHUB_WORKSPACE/build_release \
&& cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DUSE_BLAS_FOR_OPTIMUS=0 \
-DCMAKE_PREFIX_PATH="$SOFA_ROOT/build_release/install";$EIGEN_INSTALL_DIR/build_release .. \
&& ninja install"
else
mkdir $GITHUB_WORKSPACE/build_release
cd $GITHUB_WORKSPACE/build_release
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=$SOFA_ROOT/build_release/install ..
make -j 8
make install
fi
- name: Create artifact
uses: actions/upload-artifact@v2
with:
name: Optimus_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
path: ${{ github.workspace }}/build_release/install

- name: Install artifact
uses: actions/download-artifact@v2
with:
name: Optimus_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}
path: ${{ github.workspace }}/build_release/install

- name: Optimus tests
shell: bash
run: |
if [[ "$RUNNER_OS" == "Windows" ]]; then
echo "Skip tests for windows system"
else
export SOFA_PYTHON3_ROOT=/tmp/SofaPython3
export LD_LIBRARY_PATH=$GITHUB_WORKSPACE/build_release
export SOFA_PLUGIN_PATH=$GITHUB_WORKSPACE/build_release
FOLDER_LIST=`find $GITHUB_WORKSPACE/benchmarks -maxdepth 1`
for FOLDER in $FOLDER_LIST; do
if [ -f $FOLDER/verify.sh ]; then
cd $FOLDER
echo "Perform test: $FOLDER"
if [[ "$RUNNER_OS" == "macOS" ]]; then
$FOLDER/verify.sh $SOFA_ROOT/bin/runSofa $SOFA_PYTHON3_ROOT/build_release/lib/libSofaPython3.dylib
else
$FOLDER/verify.sh $SOFA_ROOT/bin/runSofa $SOFA_PYTHON3_ROOT/build_release/lib/libSofaPython3.so
fi
fi
done
echo "All tests have been executed"
fi
deploy:
name: Deploy artifacts
if: always() && startsWith(github.ref, 'refs/heads/') # we are on a branch (not a PR)
needs: [build_and_test]
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Get artifacts
uses: actions/download-artifact@v2
with:
path: artifacts

- name: Zip artifacts
shell: bash
run: |
cd $GITHUB_WORKSPACE/artifacts
for artifact in *; do
zip $artifact.zip -r $artifact/*
done
- name: Delete old release
uses: dev-drprasad/[email protected]
with:
delete_release: true
tag_name: release-${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
tag_name: release-${{ github.ref_name }}
fail_on_unmatched_files: true
files: |
artifacts/Optimus_*_Linux.zip
artifacts/Optimus_*_macOS.zip
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
if [ -f $FOLDER/verify.sh ]; then
cd $FOLDER
echo "Perform test: $FOLDER"
$FOLDER/verify.sh $SOFA_BUILD_DIRECTORY/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib
$FOLDER/verify.sh $SOFA_BUILD_DIRECTORY/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib/libSofaPython3.so
fi
done
echo "All tests have been executed"
38 changes: 28 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
cmake_minimum_required(VERSION 3.1)
project(Optimus)
cmake_minimum_required(VERSION 3.8)

set(OPTIMUS_MAJOR_VERSION 1)
set(OPTIMUS_MINOR_VERSION 1)
set(OPTIMUS_VERSION ${OPTIMUS_MAJOR_VERSION}.${OPTIMUS_MINOR_VERSION})

project(Optimus VERSION ${OPTIMUS_VERSION})

# required standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -171,9 +172,9 @@ else()
message("SofaPardisoSolver not found, PardisoSolver component will not work")
endif()

target_include_directories(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>")
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>")
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION "${OPTIMUS_VERSION}")
set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${COMPILATION_FLAGS}")
set_target_properties(${PROJECT_NAME} PROPERTIES PUBLIC_HEADER "${HEADER_FILES}")
Expand All @@ -183,9 +184,26 @@ include_directories("${CMAKE_CURRENT_SOURCE_DIR}/src")
get_target_property(compile_defs ${PROJECT_NAME} COMPILE_FLAGS)
message(STATUS "Compile definitions: ${compile_defs}")

install(TARGETS Optimus
EXPORT OptimusTargets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include/Optimus)

# install rules
if( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/install CACHE PATH "Install path prefix, prepended onto install directories." FORCE)
endif()
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")

sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
PACKAGE_VERSION ${PROJECT_VERSION}
TARGETS ${PROJECT_NAME} AUTO_SET_TARGET_PROPERTIES
INCLUDE_SOURCE_DIR "src"
INCLUDE_INSTALL_DIR ${PROJECT_NAME}
EXAMPLE_INSTALL_DIR "examples"
RELOCATABLE "plugins"
)

#install(TARGETS Optimus
# EXPORT OptimusTargets
# RUNTIME DESTINATION bin
# LIBRARY DESTINATION lib
# ARCHIVE DESTINATION lib
# PUBLIC_HEADER DESTINATION include/Optimus)
9 changes: 9 additions & 0 deletions OptimusConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Optimus plugin configuration file

@PACKAGE_INIT@

if(NOT TARGET @PROJECT_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
endif()

check_required_components(@PROJECT_NAME@)
2 changes: 1 addition & 1 deletion benchmarks/assimBC_liver_geomagic_cutting_yaml/verify.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ $# == "2" ]; then
SOFA_EXEC="$1 -l $2/libSofaPython3.so"
SOFA_EXEC="$1 -l $2"
elif [ $# == "1" ]; then
SOFA_EXEC="$1 -l libSofaPython3.so"
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ $# == "2" ]; then
SOFA_EXEC="$1 -l $2/libSofaPython3.so"
SOFA_EXEC="$1 -l $2"
elif [ $# == "1" ]; then
SOFA_EXEC="$1 -l libSofaPython3.so"
else
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/assimBC_synthBrick/verify.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ $# == "2" ]; then
SOFA_EXEC="$1 -l $2/libSofaPython3.so"
SOFA_EXEC="$1 -l $2"
elif [ $# == "1" ]; then
SOFA_EXEC="$1 -l libSofaPython3.so"
else
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ $# == "2" ]; then
SOFA_EXEC="$1 -l $2/libSofaPython3.so"
SOFA_EXEC="$1 -l $2"
elif [ $# == "1" ]; then
SOFA_EXEC="$1 -l libSofaPython3.so"
else
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/assimStiffness_cylinder_geomagic_yaml/verify.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ $# == "2" ]; then
SOFA_EXEC="$1 -l $2/libSofaPython3.so"
SOFA_EXEC="$1 -l $2"
elif [ $# == "1" ]; then
SOFA_EXEC="$1 -l libSofaPython3.so"
else
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/assimStiffness_cylinder_python3_yaml/verify.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ $# == "2" ]; then
SOFA_EXEC="$1 -l $2/libSofaPython3.so"
SOFA_EXEC="$1 -l $2"
elif [ $# == "1" ]; then
SOFA_EXEC="$1 -l libSofaPython3.so"
else
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/assimStiffness_cylinder_yaml/verify.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

if [ $# == "2" ]; then
SOFA_EXEC="$1 -l $2/libSofaPython3.so"
SOFA_EXEC="$1 -l $2"
elif [ $# == "1" ]; then
SOFA_EXEC="$1 -l libSofaPython3.so"
else
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/crontask/runOptimusTests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ do
cd $FOLDER
if [ -f $FOLDER/verify.sh ]; then
echo "Perform test: $FOLDER"
$FOLDER/verify.sh $BUILD_DIRECTORY/install/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
$FOLDER/verify.sh $BUILD_DIRECTORY/install/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib/libSofaPython3.so >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
fi
done
echo "All tests have been executed"
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/crontask/runOptimusTests_without_compiling.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ do
cd $FOLDER
if [ -f $FOLDER/verify.sh ]; then
echo "Perform test: $FOLDER"
$FOLDER/verify.sh $BUILD_DIRECTORY/install/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
$FOLDER/verify.sh $BUILD_DIRECTORY/install/bin/runSofa $SOFA_PYTHON3_BUILD_DIRECTORY/lib/libSofaPython3.so >> $GENERAL_DIRECTORY/log_`/bin/date +"%Y_%m_%d"`.txt
fi
done
echo "All tests have been executed"
Expand Down
Loading

0 comments on commit 7586b47

Please sign in to comment.