diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 6862def2..214754c5 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -1,22 +1,42 @@ -name: CI +name: MacOS CI -on: pull_request +on: [workflow_dispatch, pull_request] jobs: build: - name: Building on ${{ matrix.os }} + name: Building with SOFA ${{ matrix.sofa_branch }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [macos-10.15] + sofa_branch: [master, v21.06] env: - TOKEN: ${{ secrets.SOFA_REPO_READ_TOKEN }} SOFA_ROOT: /opt/sofa + SOFA_OS: MacOS steps: - name: Checkout source code uses: actions/checkout@v2 + - name: Set env vars + run: | + echo github.event.number = ${{ github.event.number }} + echo github.event.pull_request.number = ${{ github.event.pull_request.number }} + echo github.event.issue.number = ${{ github.event.issue.number }} + if [ -n "${{ github.event.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.number }}" + elif [ -n "${{ github.event.pull_request.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.pull_request.number }}" + elif [ -n "${{ github.event.issue.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.issue.number }}" + else + GIT_BRANCH="${GITHUB_REF#refs/heads/}" + fi + echo "GIT_BRANCH = $GIT_BRANCH" + if [ -z "$GIT_BRANCH" ]; then exit 1; fi + echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV + - name: Set up Python 3.7 uses: actions/setup-python@v2 with: @@ -24,76 +44,107 @@ jobs: - name: Install requirements run: | - brew install ccache ninja boost eigen pybind11 - python3 -m pip install numpy + brew install eigen boost + brew install ccache ninja + python3 -m pip install numpy scipy - - name: Download SOFA nightly build - run: | - curl --output sofa.zip -L \ - https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip + - name: pybind11 cache files + uses: actions/cache@v2 + id: pybind11_cache + with: + path: /tmp/pybind11 + key: pybind11_${{ env.GIT_BRANCH }}_${{ matrix.os }}_${{ hashFiles('.github/workflows/*.yml') }} - - name: Install SOFA nightly build + - name: Build pybind11 + if: steps.pybind11_cache.outputs.cache-hit != 'true' run: | - sudo unzip sofa.zip -d temp - sudo unzip temp/MacOS/`ls temp/MacOS/` -d temp - sudo rm -rf temp/MacOS - sudo mv temp/`ls temp` $SOFA_ROOT - rm -rf temp - - - name: Get Time - id: time - uses: nanzm/get-time-action@v1.0 - with: - timeZone: 8 - format: 'YYYY-MM-DD-HH-mm-ss' + git clone -b v2.4.3 --depth 1 https://github.com/pybind/pybind11.git /tmp/pybind11 + cd /tmp/pybind11 + cmake -DCMAKE_BUILD_TYPE=Release -DPYBIND11_TEST=OFF -DPYTHON_EXECUTABLE=$(which python3.7) . + make --silent + + - name: Install pybind11 + run: | + cd /tmp/pybind11 + sudo make --silent install + + - name: Download and install the latest SOFA ${{ matrix.sofa_branch }} binaries + shell: bash + run: | + mkdir -p /tmp/sofa_zip + mkdir -p /tmp/sofa_binaries + curl --output /tmp/sofa_zip/${SOFA_OS}.zip -L \ + https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=${{ matrix.sofa_branch }},CI_SCOPE=minimal/lastSuccessfulBuild/artifact/${SOFA_OS}/*zip*/${SOFA_OS}.zip + unzip -qq /tmp/sofa_zip/${SOFA_OS}.zip -d /tmp/sofa_zip + unzip -qq /tmp/sofa_zip/${SOFA_OS}/SOFA_*.zip -d /tmp/sofa_binaries + sudo mv /tmp/sofa_binaries/SOFA_* ${SOFA_ROOT} + sudo ls -la ${SOFA_ROOT} + rm -rf /tmp/sofa_* - name: ccache cache files uses: actions/cache@v2 with: path: .ccache - key: ${{ matrix.os }}-ccache-${{ steps.time.outputs.time }} - restore-keys: | - ${{ matrix.os }}-ccache- + key: ccache_${{ env.GIT_BRANCH }}_${{ matrix.os }}_${{ hashFiles('.github/workflows/*.yml') }} - name: Build env: CCACHE_COMPRESS: true CCACHE_COMPRESSLEVEL: 6 CCACHE_MAXSIZE: "500M" - run: - export CCACHE_BASEDIR=$GITHUB_WORKSPACE && - export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache && - ccache -z && - cmake - -GNinja - -DCMAKE_C_COMPILER_LAUNCHER=ccache - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake - -DCMAKE_BUILD_TYPE=Release - -DPYTHON_EXECUTABLE=$(which python) - . - && ninja && ninja install - && echo ${CCACHE_BASEDIR} - && ccache -s - - - name: Archive production + run: | + export CCACHE_BASEDIR=$GITHUB_WORKSPACE + export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache + ccache -z + cmake \ + -GNinja \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DPYTHON_EXECUTABLE=$(which python3.7) \ + . + ninja install + echo ${CCACHE_BASEDIR} + ccache -s + + - name: Create artifact uses: actions/upload-artifact@v2 with: - name: sp3-${{ matrix.os }} + name: SofaPython3_${{ env.GIT_BRANCH }}_SOFA-${{ matrix.sofa_branch }}_${{ env.SOFA_OS }} path: install tests: - name: Testing on ${{ matrix.os }} + name: Testing with SOFA ${{ matrix.sofa_branch }} needs: [build] runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [macos-10.15] + sofa_branch: [master, v21.06] env: - TOKEN: ${{ secrets.SOFA_REPO_READ_TOKEN }} SOFA_ROOT: /opt/sofa + SOFA_OS: MacOS steps: + - name: Set env vars + run: | + echo github.event.number = ${{ github.event.number }} + echo github.event.pull_request.number = ${{ github.event.pull_request.number }} + echo github.event.issue.number = ${{ github.event.issue.number }} + if [ -n "${{ github.event.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.number }}" + elif [ -n "${{ github.event.pull_request.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.pull_request.number }}" + elif [ -n "${{ github.event.issue.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.issue.number }}" + else + GIT_BRANCH="${GITHUB_REF#refs/heads/}" + fi + echo "GIT_BRANCH = $GIT_BRANCH" + if [ -z "$GIT_BRANCH" ]; then exit 1; fi + echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV - name: Set up Python 3.7 uses: actions/setup-python@v2 @@ -103,25 +154,25 @@ jobs: - name: Install requirements run: | brew install boost - python3 -m pip install numpy - - - name: Download SOFA nightly build - run: | - curl --output sofa.zip -L \ - https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip + python3 -m pip install numpy scipy - - name: Install SOFA nightly build + - name: Download and install the latest SOFA ${{ matrix.sofa_branch }} binaries + shell: bash run: | - sudo unzip sofa.zip -d temp - sudo unzip temp/MacOS/`ls temp/MacOS/` -d temp - sudo rm -rf temp/MacOS - sudo mv temp/`ls temp` $SOFA_ROOT - rm -rf temp + mkdir -p /tmp/sofa_zip + mkdir -p /tmp/sofa_binaries + curl --output /tmp/sofa_zip/${SOFA_OS}.zip -L \ + https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=${{ matrix.sofa_branch }},CI_SCOPE=minimal/lastSuccessfulBuild/artifact/${SOFA_OS}/*zip*/${SOFA_OS}.zip + unzip -qq /tmp/sofa_zip/${SOFA_OS}.zip -d /tmp/sofa_zip + unzip -qq /tmp/sofa_zip/${SOFA_OS}/SOFA_*.zip -d /tmp/sofa_binaries + sudo mv /tmp/sofa_binaries/SOFA_* ${SOFA_ROOT} + sudo ls -la ${SOFA_ROOT} + rm -rf /tmp/sofa_* - name: Install SP3 uses: actions/download-artifact@v2 with: - name: sp3-${{ matrix.os }} + name: SofaPython3_${{ env.GIT_BRANCH }}_SOFA-${{ matrix.sofa_branch }}_${{ env.SOFA_OS }} path: SofaPython3 - name: Binding.Sofa.Tests diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 41d5455e..e629a37f 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -1,22 +1,42 @@ -name: CI +name: Ubuntu CI -on: pull_request +on: [workflow_dispatch, pull_request] jobs: build: - name: Building on ${{ matrix.os }} + name: Building with SOFA ${{ matrix.sofa_branch }} runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-18.04] + sofa_branch: [master, v21.06] env: - TOKEN: ${{ secrets.SOFA_REPO_READ_TOKEN }} SOFA_ROOT: /opt/sofa + SOFA_OS: Linux steps: - name: Checkout source code uses: actions/checkout@v2 + - name: Set env vars + run: | + echo github.event.number = ${{ github.event.number }} + echo github.event.pull_request.number = ${{ github.event.pull_request.number }} + echo github.event.issue.number = ${{ github.event.issue.number }} + if [ -n "${{ github.event.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.number }}" + elif [ -n "${{ github.event.pull_request.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.pull_request.number }}" + elif [ -n "${{ github.event.issue.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.issue.number }}" + else + GIT_BRANCH="${GITHUB_REF#refs/heads/}" + fi + echo "GIT_BRANCH = $GIT_BRANCH" + if [ -z "$GIT_BRANCH" ]; then exit 1; fi + echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV + - name: Set up Python 3.7 uses: actions/setup-python@v2 with: @@ -26,89 +46,105 @@ jobs: run: | sudo apt install -qq libeigen3-dev libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev sudo apt install -qq ccache ninja-build - python3 -m pip install numpy + python3 -m pip install numpy scipy - - name: Cache pybind11 + - name: pybind11 cache files uses: actions/cache@v2 id: pybind11_cache with: path: /tmp/pybind11 - key: pybind24 + key: pybind11_${{ env.GIT_BRANCH }}_${{ matrix.os }}_${{ hashFiles('.github/workflows/*.yml') }} - name: Build pybind11 if: steps.pybind11_cache.outputs.cache-hit != 'true' - run: git clone -b v2.4 --depth 1 https://github.com/pybind/pybind11.git /tmp/pybind11 && cd /tmp/pybind11 && cmake -DPYBIND11_TEST=OFF . && cmake -DPYBIND11_TEST=OFF . && make + run: | + git clone -b v2.4.3 --depth 1 https://github.com/pybind/pybind11.git /tmp/pybind11 + cd /tmp/pybind11 + cmake -DCMAKE_BUILD_TYPE=Release -DPYBIND11_TEST=OFF -DPYTHON_EXECUTABLE=$(which python3.7) . + make --silent - name: Install pybind11 - run: cd /tmp/pybind11 && sudo make install - - - name: Download SOFA nightly build - run: | - curl --output sofa.zip -L \ - https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip - - - name: Install SOFA nightly build - run: | - sudo unzip sofa.zip -d temp - sudo unzip temp/Linux/`ls temp/Linux/` -d temp - sudo rm -rf temp/Linux - sudo mkdir -p $SOFA_ROOT - sudo mv temp/`ls temp`/* $SOFA_ROOT/ - sudo rm -rf temp - - - name: Get Time - id: time - uses: nanzm/get-time-action@v1.0 - with: - timeZone: 8 - format: 'YYYY-MM-DD-HH-mm-ss' + run: | + cd /tmp/pybind11 + sudo make --silent install + + - name: Download and install the latest SOFA ${{ matrix.sofa_branch }} binaries + shell: bash + run: | + mkdir -p /tmp/sofa_zip + mkdir -p /tmp/sofa_binaries + curl --output /tmp/sofa_zip/${SOFA_OS}.zip -L \ + https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=${{ matrix.sofa_branch }},CI_SCOPE=minimal/lastSuccessfulBuild/artifact/${SOFA_OS}/*zip*/${SOFA_OS}.zip + unzip -qq /tmp/sofa_zip/${SOFA_OS}.zip -d /tmp/sofa_zip + unzip -qq /tmp/sofa_zip/${SOFA_OS}/SOFA_*.zip -d /tmp/sofa_binaries + sudo mv /tmp/sofa_binaries/SOFA_* ${SOFA_ROOT} + sudo ls -la ${SOFA_ROOT} + rm -rf /tmp/sofa_* - name: ccache cache files uses: actions/cache@v2 with: path: .ccache - key: ${{ matrix.os }}-ccache-${{ steps.time.outputs.time }} - restore-keys: | - ${{ matrix.os }}-ccache- + key: ccache_${{ env.GIT_BRANCH }}_${{ matrix.os }}_${{ hashFiles('.github/workflows/*.yml') }} - name: Build env: CCACHE_COMPRESS: true CCACHE_COMPRESSLEVEL: 6 CCACHE_MAXSIZE: "500M" - run: - export CCACHE_BASEDIR=$GITHUB_WORKSPACE && - export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache && - ccache -z && - cmake - -GNinja - -DCMAKE_C_COMPILER_LAUNCHER=ccache - -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake - -DCMAKE_BUILD_TYPE=Release - . - && ninja && ninja install - && echo ${CCACHE_BASEDIR} - && ccache -s - - - name: Archive production + run: | + export CCACHE_BASEDIR=$GITHUB_WORKSPACE + export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache + ccache -z + cmake \ + -GNinja \ + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ + -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \ + -DCMAKE_BUILD_TYPE=Release \ + -DPYTHON_EXECUTABLE=$(which python3.7) \ + . + ninja install + echo ${CCACHE_BASEDIR} + ccache -s + + - name: Create artifact uses: actions/upload-artifact@v2 with: - name: sp3-${{ matrix.os }} + name: SofaPython3_${{ env.GIT_BRANCH }}_SOFA-${{ matrix.sofa_branch }}_${{ env.SOFA_OS }} path: install tests: - name: Testing on ${{ matrix.os }} + name: Testing with SOFA ${{ matrix.sofa_branch }} needs: [build] runs-on: ${{ matrix.os }} strategy: + fail-fast: false matrix: os: [ubuntu-18.04] + sofa_branch: [master, v21.06] env: - TOKEN: ${{ secrets.SOFA_REPO_READ_TOKEN }} SOFA_ROOT: /opt/sofa + SOFA_OS: Linux steps: + - name: Set env vars + run: | + echo github.event.number = ${{ github.event.number }} + echo github.event.pull_request.number = ${{ github.event.pull_request.number }} + echo github.event.issue.number = ${{ github.event.issue.number }} + if [ -n "${{ github.event.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.number }}" + elif [ -n "${{ github.event.pull_request.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.pull_request.number }}" + elif [ -n "${{ github.event.issue.number }}" ]; then + GIT_BRANCH="PR-${{ github.event.issue.number }}" + else + GIT_BRANCH="${GITHUB_REF#refs/heads/}" + fi + echo "GIT_BRANCH = $GIT_BRANCH" + if [ -z "$GIT_BRANCH" ]; then exit 1; fi + echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV - name: Set up Python 3.7 uses: actions/setup-python@v2 @@ -118,25 +154,25 @@ jobs: - name: Install requirements run: | sudo apt install -qq libboost-all-dev - python3 -m pip install numpy - - - name: Download SOFA nightly build - run: | - curl --output sofa.zip -L \ - https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/Linux/*zip*/Linux.zip + python3 -m pip install numpy scipy - - name: Install SOFA nightly build + - name: Download and install the latest SOFA ${{ matrix.sofa_branch }} binaries + shell: bash run: | - sudo unzip sofa.zip -d temp - sudo unzip temp/Linux/`ls temp/Linux/` -d temp - sudo rm -rf temp/Linux - sudo mv temp/`ls temp` $SOFA_ROOT - sudo rm -rf temp + mkdir -p /tmp/sofa_zip + mkdir -p /tmp/sofa_binaries + curl --output /tmp/sofa_zip/${SOFA_OS}.zip -L \ + https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=${{ matrix.sofa_branch }},CI_SCOPE=minimal/lastSuccessfulBuild/artifact/${SOFA_OS}/*zip*/${SOFA_OS}.zip + unzip -qq /tmp/sofa_zip/${SOFA_OS}.zip -d /tmp/sofa_zip + unzip -qq /tmp/sofa_zip/${SOFA_OS}/SOFA_*.zip -d /tmp/sofa_binaries + sudo mv /tmp/sofa_binaries/SOFA_* ${SOFA_ROOT} + sudo ls -la ${SOFA_ROOT} + rm -rf /tmp/sofa_* - name: Install SP3 uses: actions/download-artifact@v2 with: - name: sp3-${{ matrix.os }} + name: SofaPython3_${{ env.GIT_BRANCH }}_SOFA-${{ matrix.sofa_branch }}_${{ env.SOFA_OS }} path: SofaPython3 - name: Binding.Sofa.Tests diff --git a/CMakeLists.txt b/CMakeLists.txt index 6067a250..07c31312 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,10 @@ if (SP3_COMPILED_AS_SOFA_SUBPROJECT) else() option(SP3_BUILD_TEST "Compile the automatic tests for SofaPython3, along with the gtest library." ON) endif() +if(SP3_BUILD_TEST) + # TODO: remove this when SOFA's GTest handles threads correctly + find_package(Threads REQUIRED) +endif() find_package(SofaExporter QUIET) CMAKE_DEPENDENT_OPTION(SP3_WITH_SOFAEXPORTER "Bind the SOFA exporter component." ON "SofaExporter_FOUND" OFF)