|
| 1 | +name: MacOS CI |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + types: [opened, synchronize, reopened, edited] |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: Building with SOFA ${{ matrix.sofa_branch }} |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + fail-fast: false |
| 14 | + matrix: |
| 15 | + os: [macos-10.15] |
| 16 | + sofa_branch: [master] |
| 17 | + env: |
| 18 | + SOFA_ROOT: /opt/sofa |
| 19 | + SOFA_OS: MacOS |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout source code |
| 23 | + uses: actions/checkout@v2 |
| 24 | + |
| 25 | + - name: Set env vars |
| 26 | + run: | |
| 27 | + echo github.event.number = ${{ github.event.number }} |
| 28 | + echo github.event.pull_request.number = ${{ github.event.pull_request.number }} |
| 29 | + echo github.event.issue.number = ${{ github.event.issue.number }} |
| 30 | + if [ -n "${{ github.event.number }}" ]; then |
| 31 | + GIT_BRANCH="PR-${{ github.event.number }}" |
| 32 | + elif [ -n "${{ github.event.pull_request.number }}" ]; then |
| 33 | + GIT_BRANCH="PR-${{ github.event.pull_request.number }}" |
| 34 | + elif [ -n "${{ github.event.issue.number }}" ]; then |
| 35 | + GIT_BRANCH="PR-${{ github.event.issue.number }}" |
| 36 | + else |
| 37 | + GIT_BRANCH="${GITHUB_REF#refs/heads/}" |
| 38 | + fi |
| 39 | + echo "GIT_BRANCH = $GIT_BRANCH" |
| 40 | + if [ -z "$GIT_BRANCH" ]; then exit 1; fi |
| 41 | + echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV |
| 42 | +
|
| 43 | + - name: Set up Python 3.7 |
| 44 | + uses: actions/setup-python@v2 |
| 45 | + with: |
| 46 | + python-version: '3.7' |
| 47 | + |
| 48 | + - name: Install requirements |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + brew install eigen boost |
| 52 | + brew install ccache ninja |
| 53 | + brew list | grep python | while read package; do |
| 54 | + brew unlink $package |
| 55 | + done |
| 56 | + python3 -m pip install numpy scipy |
| 57 | +
|
| 58 | + - name: pybind11 cache files |
| 59 | + uses: actions/cache@v2 |
| 60 | + id: pybind11_cache |
| 61 | + with: |
| 62 | + path: /tmp/pybind11 |
| 63 | + key: pybind11_${{ env.GIT_BRANCH }}_${{ matrix.os }}_${{ hashFiles('.github/workflows/*.yml') }} |
| 64 | + |
| 65 | + - name: Build pybind11 |
| 66 | + if: steps.pybind11_cache.outputs.cache-hit != 'true' |
| 67 | + run: | |
| 68 | + git clone -b v2.4.3 --depth 1 https://github.com/pybind/pybind11.git /tmp/pybind11 |
| 69 | + cd /tmp/pybind11 |
| 70 | + cmake -DCMAKE_BUILD_TYPE=Release -DPYBIND11_TEST=OFF -DPYTHON_EXECUTABLE=$(which python3.7) . |
| 71 | + make --silent |
| 72 | +
|
| 73 | + - name: Install pybind11 |
| 74 | + run: | |
| 75 | + cd /tmp/pybind11 |
| 76 | + sudo make --silent install |
| 77 | +
|
| 78 | + - name: Download and install the latest SOFA ${{ matrix.sofa_branch }} binaries |
| 79 | + shell: bash |
| 80 | + run: | |
| 81 | + mkdir -p /tmp/sofa_zip |
| 82 | + mkdir -p /tmp/sofa_binaries |
| 83 | + curl --output /tmp/sofa_zip/${SOFA_OS}.zip -L \ |
| 84 | + 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 |
| 85 | + unzip -qq /tmp/sofa_zip/${SOFA_OS}.zip -d /tmp/sofa_zip |
| 86 | + unzip -qq /tmp/sofa_zip/${SOFA_OS}/SOFA_*.zip -d /tmp/sofa_binaries |
| 87 | + sudo mv /tmp/sofa_binaries/SOFA_* ${SOFA_ROOT} |
| 88 | + sudo ls -la ${SOFA_ROOT} |
| 89 | + rm -rf /tmp/sofa_* |
| 90 | +
|
| 91 | + - name: ccache cache files |
| 92 | + uses: actions/cache@v2 |
| 93 | + with: |
| 94 | + path: .ccache |
| 95 | + key: ccache_${{ env.GIT_BRANCH }}_${{ matrix.os }}_${{ hashFiles('.github/workflows/*.yml') }} |
| 96 | + |
| 97 | + - name: Build |
| 98 | + env: |
| 99 | + CCACHE_COMPRESS: true |
| 100 | + CCACHE_COMPRESSLEVEL: 6 |
| 101 | + CCACHE_MAXSIZE: "500M" |
| 102 | + run: | |
| 103 | + echo "RUNNER_TOOL_CACHE = $RUNNER_TOOL_CACHE" |
| 104 | + python_root="$(find $RUNNER_TOOL_CACHE -maxdepth 3 -type d -path '**/Python/3.7*/x64')" |
| 105 | + echo "python_root = $python_root" |
| 106 | + export CCACHE_BASEDIR=$GITHUB_WORKSPACE |
| 107 | + export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache |
| 108 | + ccache -z |
| 109 | + cmake \ |
| 110 | + -GNinja \ |
| 111 | + -DCMAKE_C_COMPILER_LAUNCHER=ccache \ |
| 112 | + -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ |
| 113 | + -DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \ |
| 114 | + -DCMAKE_BUILD_TYPE=Release \ |
| 115 | + -DPython_EXECUTABLE=$(which python3.7) \ |
| 116 | + -DPython_ROOT=$python_root \ |
| 117 | + . |
| 118 | + ninja install |
| 119 | + echo ${CCACHE_BASEDIR} |
| 120 | + ccache -s |
| 121 | +
|
| 122 | + - name: Create artifact |
| 123 | + uses: actions/upload-artifact@v2 |
| 124 | + with: |
| 125 | + name: SofaPython3_${{ env.GIT_BRANCH }}_SOFA-${{ matrix.sofa_branch }}_${{ env.SOFA_OS }} |
| 126 | + path: install |
| 127 | + |
| 128 | + tests: |
| 129 | + name: Testing with SOFA ${{ matrix.sofa_branch }} |
| 130 | + needs: [build] |
| 131 | + runs-on: ${{ matrix.os }} |
| 132 | + strategy: |
| 133 | + fail-fast: false |
| 134 | + matrix: |
| 135 | + os: [macos-10.15] |
| 136 | + sofa_branch: [master, v21.06] |
| 137 | + env: |
| 138 | + SOFA_ROOT: /opt/sofa |
| 139 | + SOFA_OS: MacOS |
| 140 | + |
| 141 | + steps: |
| 142 | + - name: Set env vars |
| 143 | + run: | |
| 144 | + echo github.event.number = ${{ github.event.number }} |
| 145 | + echo github.event.pull_request.number = ${{ github.event.pull_request.number }} |
| 146 | + echo github.event.issue.number = ${{ github.event.issue.number }} |
| 147 | + if [ -n "${{ github.event.number }}" ]; then |
| 148 | + GIT_BRANCH="PR-${{ github.event.number }}" |
| 149 | + elif [ -n "${{ github.event.pull_request.number }}" ]; then |
| 150 | + GIT_BRANCH="PR-${{ github.event.pull_request.number }}" |
| 151 | + elif [ -n "${{ github.event.issue.number }}" ]; then |
| 152 | + GIT_BRANCH="PR-${{ github.event.issue.number }}" |
| 153 | + else |
| 154 | + GIT_BRANCH="${GITHUB_REF#refs/heads/}" |
| 155 | + fi |
| 156 | + echo "GIT_BRANCH = $GIT_BRANCH" |
| 157 | + if [ -z "$GIT_BRANCH" ]; then exit 1; fi |
| 158 | + echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV |
| 159 | +
|
| 160 | + - name: Set up Python 3.7 |
| 161 | + uses: actions/setup-python@v2 |
| 162 | + with: |
| 163 | + python-version: '3.7' |
| 164 | + |
| 165 | + - name: Install requirements |
| 166 | + shell: bash |
| 167 | + run: | |
| 168 | + brew install boost |
| 169 | + brew list | grep python | while read package; do |
| 170 | + brew unlink $package |
| 171 | + done |
| 172 | + python3 -m pip install numpy scipy |
| 173 | +
|
| 174 | + - name: Download and install the latest SOFA ${{ matrix.sofa_branch }} binaries |
| 175 | + shell: bash |
| 176 | + run: | |
| 177 | + mkdir -p /tmp/sofa_zip |
| 178 | + mkdir -p /tmp/sofa_binaries |
| 179 | + curl --output /tmp/sofa_zip/${SOFA_OS}.zip -L \ |
| 180 | + 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 |
| 181 | + unzip -qq /tmp/sofa_zip/${SOFA_OS}.zip -d /tmp/sofa_zip |
| 182 | + unzip -qq /tmp/sofa_zip/${SOFA_OS}/SOFA_*.zip -d /tmp/sofa_binaries |
| 183 | + sudo mv /tmp/sofa_binaries/SOFA_* ${SOFA_ROOT} |
| 184 | + sudo ls -la ${SOFA_ROOT} |
| 185 | + rm -rf /tmp/sofa_* |
| 186 | +
|
| 187 | + - name: Install SP3 |
| 188 | + uses: actions/download-artifact@v2 |
| 189 | + with: |
| 190 | + name: SofaPython3_${{ env.GIT_BRANCH }}_SOFA-${{ matrix.sofa_branch }}_${{ env.SOFA_OS }} |
| 191 | + path: SofaPython3 |
| 192 | + |
| 193 | + - name: Binding.Sofa.Tests |
| 194 | + if: ${{ always() }} |
| 195 | + run: | |
| 196 | + export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib |
| 197 | + export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages |
| 198 | + chmod +x SofaPython3/bin/Bindings.Sofa.Tests |
| 199 | + ./SofaPython3/bin/Bindings.Sofa.Tests |
| 200 | + - name: Bindings.SofaRuntime.Tests |
| 201 | + if: ${{ always() }} |
| 202 | + run: | |
| 203 | + export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib |
| 204 | + export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages |
| 205 | + chmod +x SofaPython3/bin/Bindings.SofaRuntime.Tests |
| 206 | + ./SofaPython3/bin/Bindings.SofaRuntime.Tests |
| 207 | + - name: Bindings.SofaTypes.Tests |
| 208 | + if: ${{ always() }} |
| 209 | + run: | |
| 210 | + export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib |
| 211 | + export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages |
| 212 | + chmod +x SofaPython3/bin/Bindings.SofaTypes.Tests |
| 213 | + ./SofaPython3/bin/Bindings.SofaTypes.Tests |
| 214 | + - name: Bindings.Modules.Tests |
| 215 | + if: ${{ always() }} |
| 216 | + run: | |
| 217 | + export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib |
| 218 | + export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/python3/site-packages |
| 219 | + chmod +x SofaPython3/bin/Bindings.Modules.Tests |
| 220 | + ./SofaPython3/bin/Bindings.Modules.Tests |
0 commit comments