Skip to content

Commit

Permalink
use sofa action
Browse files Browse the repository at this point in the history
  • Loading branch information
fredroy committed Nov 28, 2024
1 parent 71497b0 commit 9d9c6de
Showing 1 changed file with 64 additions and 150 deletions.
214 changes: 64 additions & 150 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,204 +10,118 @@ on:

jobs:
build:
name: Building with ${{ matrix.sofa_version }}
runs-on: ubuntu-24.04
container: ${{ matrix.CONTAINER }}
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
sofa_version: [ master ]
include:
- sofa_version: master
SOFA_VERSION_I: 999999
CONTAINER: jnbrunet/caribou-ubuntu-2004-builder:latest
PYTHON_VERSION: 3.8
PYBIND11_VERSION: 2.6
env:
SOFA_VERSION: ${{ matrix.sofa_version }}
SOFA_ROOT: /opt/sofa
PYTHON_VERSION: ${{ matrix.PYTHON_VERSION }}
os: [ubuntu-22.04]
sofa_branch: [master]

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- run: |
git config --global user.email "[email protected]"
git config --global user.name "Caribou Github"
git fetch origin
git merge origin/master
- name: Install pybind11
if: ${{ matrix.PYBIND11_VERSION != '2.4' }}
run: |
git clone --depth 1 -b v${{ matrix.PYBIND11_VERSION }} https://github.com/pybind/pybind11.git /tmp/pybind11
cmake -GNinja -S/tmp/pybind11 -B/tmp/pybind11/build -DPYBIND11_TEST=OFF -DCMAKE_BUILD_TYPE=Release
cmake --install /tmp/pybind11/build
rm -rf /tmp/pybind11
- name: Download SOFA Release
run: |
if [ "$SOFA_VERSION" = "master" ]; then
curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastStableBuild/CI_BRANCH=master,CI_SCOPE=standard/artifact/Linux/*zip*/Linux.zip"
unzip sofa.zip -d temp
mv temp/Linux/`ls temp/Linux` sofa.zip
rm -rf temp
unzip sofa.zip -d temp
mv temp/`ls temp` $SOFA_ROOT
else
curl --output sofa.zip -L "https://github.com/sofa-framework/sofa/releases/download/$SOFA_VERSION/SOFA_"$SOFA_VERSION"_Linux.zip"
unzip sofa.zip -d temp
mv temp/`ls temp` $SOFA_ROOT
fi
- name: Get Time
id: time
uses: nanzm/[email protected]
- name: Setup SOFA and environment
id: sofa
uses: sofa-framework/sofa-setup-action@v5
with:
timeZone: 8
format: 'YYYY-MM-DD-HH-mm-ss'

- name: ccache cache files
uses: actions/cache@v2
if: ${{ always() }}
sofa_root: ${{ github.workspace }}/sofa
sofa_version: ${{ matrix.sofa_branch }}
sofa_scope: 'standard'
- name: Checkout source code
uses: actions/checkout@v2
with:
path: .ccache
key: ubuntu-ccache-${{ steps.time.outputs.time }}
restore-keys: |
ubuntu-ccache-
path: ${{ env.WORKSPACE_SRC_PATH }}

- name: Build caribou
env:
CCACHE_COMPRESS: true
CCACHE_COMPRESSLEVEL: 6
CCACHE_MAXSIZE: "500M"
PYTHONEXE: ${{ format('/usr/bin/python{0}', matrix.PYTHON_VERSION) }}
run:
export CCACHE_BASEDIR=$GITHUB_WORKSPACE &&
cmake
-GNinja
-DPYTHON_EXECUTABLE=$PYTHONEXE
-DCARIBOU_BUILD_TESTS=ON
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=SofaCaribou
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake
.
&& cmake --build . && cmake --install .
&& tar czvf SofaCaribou.tar.gz SofaCaribou

- name: Archive production
uses: actions/[email protected]
with:
name: caribou_${{ matrix.sofa_version }}
path: SofaCaribou.tar.gz

test:
name: Testing with ${{ matrix.sofa_version }}
needs: [build]
runs-on: ubuntu-20.04
container: ubuntu:20.04
strategy:
fail-fast: false
matrix:
sofa_version: [ master ]
include:
- sofa_version: master
PYTHON_VERSION: 3.8
sofa_version_int: 211200
env:
SOFA_VERSION: ${{ matrix.sofa_version }}
SOFA_ROOT: /opt/sofa
CARIBOU_ROOT: /opt/sofa/plugins/SofaCaribou

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

- name: Install dependencies
run: |
apt-get update
apt-get -qq --no-install-recommends install \
libgl1-mesa-glx libglib2.0-0 libglx0 libopengl0 libharfbuzz0b libgomp1 curl ca-certificates unzip
python -m pip install numpy meshio scipy
- name: Install SOFA
sudo apt install libeigen3-dev
cd "$WORKSPACE_BUILD_PATH"
cmake \
-GNinja \
-DCARIBOU_BUILD_TESTS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$WORKSPACE_INSTALL_PATH" \
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
../src
cmake --build . && cmake --install .
- name: Sanitize artifact name
id: sanitize
# This step removes special characters from the artifact name to ensure compatibility with upload-artifact
# Characters removed: " : < > | * ? \r \n \ /
# Spaces are replaced with underscores
# This sanitization prevents errors in artifact creation and retrieval
shell: pwsh
run: |
if [ "$SOFA_VERSION" = "master" ]; then
curl --output sofa.zip -L "https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastStableBuild/CI_BRANCH=master,CI_SCOPE=standard/artifact/Linux/*zip*/Linux.zip"
unzip sofa.zip -d temp
mv temp/Linux/`ls temp/Linux` sofa.zip
rm -rf temp
unzip sofa.zip -d temp
mv temp/`ls temp` $SOFA_ROOT
else
curl --output sofa.zip -L "https://github.com/sofa-framework/sofa/releases/download/$SOFA_VERSION/SOFA_"$SOFA_VERSION"_Linux.zip"
unzip sofa.zip -d temp
mv temp/`ls temp` $SOFA_ROOT
fi
$originalName = "BeamAdapter_${{ steps.sofa.outputs.run_branch }}_for-SOFA-${{ steps.sofa.outputs.sofa_version }}_${{ runner.os }}"
$artifact_name = $originalName -replace '[":;<>|*?\r\n\\/]', '' -replace ' ', '_'
echo "artifact_name=$artifact_name" >> $env:GITHUB_OUTPUT
- name: Create artifact
uses: actions/[email protected]
with:
name: ${{ steps.sanitize.outputs.artifact_name }}
path: ${{ env.WORKSPACE_INSTALL_PATH }}

- name: Download caribou
- name: Install artifact
uses: actions/[email protected]
with:
name: caribou_${{ matrix.sofa_version }}
path: /tmp
name: ${{ steps.sanitize.outputs.artifact_name }}
path: ${{ env.WORKSPACE_ARTIFACT_PATH }}

- name: Unpack caribou
run: tar xzf /tmp/SofaCaribou.tar.gz -C /opt/sofa/plugins
- name: Set env vars for tests
shell: bash
run: |
echo "LD_LIBRARY_PATH=$WORKSPACE_ARTIFACT_PATH/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaPython3/lib:$LD_LIBRARY_PATH" | tee -a $GITHUB_ENV
# export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages
- name: Caribou.unittests.Geometry
if: ${{ always() }}
run: |
export LD_LIBRARY_PATH="$SOFA_ROOT/lib:$LD_LIBRARY_PATH"
$CARIBOU_ROOT/bin/Caribou.unittests.Geometry
cd $WORKSPACE_BUILD_PATH
./bin/Caribou.unittests.Geometry
- name: Caribou.Geometry.PyTest
if: ${{ always() }}
run: |
export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages
python $CARIBOU_ROOT/bin/pytest/Caribou_Geometry_Test.py
cd $${{ env.WORKSPACE_SRC_PATH }}
python3 src/Caribou/Python/Geometry/pytest/Caribou_Geometry_Test.py
- name: Caribou.unittests.Topology
if: ${{ always() }}
run: |
[ "$SOFA_VERSION" = "v20.06.01" ] && export LD_LIBRARY_PATH="$SOFA_ROOT/lib:$LD_LIBRARY_PATH"
$CARIBOU_ROOT/bin/Caribou.unittests.Topology
cd $WORKSPACE_BUILD_PATH
./bin/Caribou.unittests.Topology
- name: Caribou.Topology.PyTest
if: ${{ always() }}
run: |
export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages
python $CARIBOU_ROOT/bin/pytest/Caribou_Topology_Test.py
cd $${{ env.WORKSPACE_SRC_PATH }}
python3 src/Caribou/Python/Topology/pytest/Caribou_Topology_Test.py
- name: Caribou.unittests.Mechanics
if: ${{ always() }}
run: |
export LD_LIBRARY_PATH="$SOFA_ROOT/lib:$LD_LIBRARY_PATH"
$CARIBOU_ROOT/bin/Caribou.unittests.Mechanics
cd $WORKSPACE_BUILD_PATH
./bin/Caribou.unittests.Mechanics
- name: Caribou.unittests.SofaCaribou
if: ${{ always() }}
run: |
[ "$SOFA_VERSION" = "v20.06.01" ] && export LD_LIBRARY_PATH="$SOFA_ROOT/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$SOFA_ROOT/collections/SofaBaseMechanics/lib:$LD_LIBRARY_PATH"
export LD_LIBRARY_PATH="$SOFA_ROOT/collections/SofaBaseUtils/lib:$LD_LIBRARY_PATH"
$CARIBOU_ROOT/bin/Caribou.unittests.SofaCaribou
cd $WORKSPACE_BUILD_PATH
./bin/Caribou.unittests.SofaCaribou
- name: SofaCaribou.PyTest
if: ${{ matrix.sofa_version_int >= '201200' }}
if: ${{ always() }}
run: |
cd $WORKSPACE_BUILD_PATH
export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages:$SOFA_ROOT/plugins/SofaPython3/lib/python3/site-packages
python $CARIBOU_ROOT/bin/pytest/SofaCaribou_Forcefield_HyperelasticForcefield.py
python3 src/SofaCaribou/Python/pytest/SofaCaribou_Forcefield_HyperelasticForcefield.py
deploy:
name: Deploy ${{ matrix.sofa_version }}
needs: [test]
needs: [build]
runs-on: ubuntu-20.04
if: github.event_name == 'schedule'
strategy:
Expand Down

0 comments on commit 9d9c6de

Please sign in to comment.