-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathaction.yml
More file actions
392 lines (367 loc) · 17.4 KB
/
action.yml
File metadata and controls
392 lines (367 loc) · 17.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
# Action description and parameters
name: 'SOFA Setup Action'
description: 'Setup everything needed to build a SOFA plugin'
inputs:
sofa_root:
description: 'SOFA install directory'
required: true
default: '/opt/sofa'
sofa_version:
description: 'Major version of SOFA to install'
required: true
default: 'v21.06'
sofa_scope:
description: 'Choose between: minimal, standard, full'
required: false
default: 'standard'
python_version:
description: 'Python version to install'
required: true
default: '3.9'
workspace_auto_setup:
description: 'Should this action setup your workspace tree?'
required: false
default: 'true'
outputs:
sofa_version:
description: "SOFA version"
value: ${{ inputs.sofa_version }}
sofa_root:
description: "SOFA root directory"
value: ${{ steps.set-sofa-root.outputs.sofa_root }}
exe:
description: "Extension for executable files"
value: ${{ steps.set-env-vars.outputs.exe }}
run_branch:
description: "Pretty git branch of this workflow run"
value: ${{ steps.set-env-vars.outputs.run_branch }}
python_root:
description: "Root directory of the Python installed for SOFA"
value: ${{ steps.set-python-vars.outputs.python_root }}
python_version:
description: "Version of the Python installed for SOFA"
value: ${{ steps.set-python-vars.outputs.python_version }}
vs_install_dir:
description: "VS install directory"
value: ${{ steps.set-env-vars.outputs.vs_install_dir }}
vs_vsdevcmd:
description: "Command to init VS environment"
value: ${{ steps.set-env-vars.outputs.vs_vsdevcmd }}
workspace_src_path:
description: "Directory to checkout your sources after calling this action"
value: ${{ steps.set-env-vars.outputs.workspace_src_path }}
workspace_build_path:
description: "Directory to build your sources after calling this action"
value: ${{ steps.set-env-vars.outputs.workspace_build_path }}
workspace_install_path:
description: "Directory to install your binaries after calling this action"
value: ${{ steps.set-env-vars.outputs.workspace_install_path }}
workspace_artifact_path:
description: "Directory to package your binaries after calling this action"
value: ${{ steps.set-env-vars.outputs.workspace_artifact_path }}
# Action code
runs:
using: "composite"
steps:
- name: Clear tool cache and PATH
shell: bash
run: |
mv "${{ runner.tool_cache }}" "${{ runner.tool_cache }}.old"
mkdir -p "${{ runner.tool_cache }}"
- name: Set env vars
id: set-env-vars
shell: bash
run: |
# Set env vars
echo "------ GITHUB_WORKSPACE/sofa-setup-action ------"
mkdir -p "$GITHUB_WORKSPACE/sofa-setup-action"
cp "${{ github.action_path }}"/*.yml "$GITHUB_WORKSPACE/sofa-setup-action"
ls -la "$GITHUB_WORKSPACE/sofa-setup-action"
echo "------------------------------------------------"
# Set executable extension
EXE=''
if [[ "$RUNNER_OS" == "Windows" ]]; then
EXE='.exe'
fi
echo "EXE=$EXE" | tee -a $GITHUB_ENV
echo "name=exe::$(echo $EXE)" >> $GITHUB_OUTPUT
if [ -n "${{ github.event.number }}" ]; then
RUN_BRANCH="PR-${{ github.event.number }}"
elif [ -n "${{ github.event.pull_request.number }}" ]; then
RUN_BRANCH="PR-${{ github.event.pull_request.number }}"
elif [ -n "${{ github.event.issue.number }}" ]; then
RUN_BRANCH="PR-${{ github.event.issue.number }}"
else
RUN_BRANCH="${GITHUB_REF#refs/heads/}"
fi
echo "RUN_BRANCH=$RUN_BRANCH" | tee -a $GITHUB_ENV
echo "name=run_branch::$(echo $RUN_BRANCH)" >> $GITHUB_OUTPUT
# Auto-setup workspace + env vars
if [[ "${{ inputs.workspace_auto_setup }}" == "true" ]]; then
mkdir -p "$GITHUB_WORKSPACE/src" "$GITHUB_WORKSPACE/build" "$GITHUB_WORKSPACE/install" "$GITHUB_WORKSPACE/artifact"
WORKSPACE_SRC_PATH="$(cd $GITHUB_WORKSPACE/src && pwd -W 2>/dev/null || pwd)"
WORKSPACE_BUILD_PATH="$(cd $GITHUB_WORKSPACE/build && pwd -W 2>/dev/null || pwd)"
WORKSPACE_INSTALL_PATH="$(cd $GITHUB_WORKSPACE/install && pwd -W 2>/dev/null || pwd)"
WORKSPACE_ARTIFACT_PATH="$(cd $GITHUB_WORKSPACE/artifact && pwd -W 2>/dev/null || pwd)"
else
WORKSPACE_SRC_PATH="$GITHUB_WORKSPACE"
WORKSPACE_BUILD_PATH="$GITHUB_WORKSPACE"
WORKSPACE_INSTALL_PATH="$GITHUB_WORKSPACE"
WORKSPACE_ARTIFACT_PATH="$GITHUB_WORKSPACE"
fi
echo "WORKSPACE_SRC_PATH=$WORKSPACE_SRC_PATH" | tee -a $GITHUB_ENV
echo "WORKSPACE_BUILD_PATH=$WORKSPACE_BUILD_PATH" | tee -a $GITHUB_ENV
echo "WORKSPACE_INSTALL_PATH=$WORKSPACE_INSTALL_PATH" | tee -a $GITHUB_ENV
echo "WORKSPACE_ARTIFACT_PATH=$WORKSPACE_ARTIFACT_PATH" | tee -a $GITHUB_ENV
echo "name=workspace_src_path::$(echo $WORKSPACE_SRC_PATH)" >> $GITHUB_OUTPUT
echo "name=workspace_build_path::$(echo $WORKSPACE_BUILD_PATH)" >> $GITHUB_OUTPUT
echo "name=workspace_install_path::$(echo $WORKSPACE_INSTALL_PATH)" >> $GITHUB_OUTPUT
echo "name=workspace_artifact_path::$(echo $WORKSPACE_ARTIFACT_PATH)" >> $GITHUB_OUTPUT
# Set default settings for ccache
echo "CCACHE_COMPRESS=true" | tee -a $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=6" | tee -a $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" | tee -a $GITHUB_ENV
echo "CCACHE_BASEDIR=$WORKSPACE_BUILD_PATH" | tee -a $GITHUB_ENV
echo "CCACHE_DIR=$GITHUB_WORKSPACE/.ccache" | tee -a $GITHUB_ENV
# TODO: find a better way to handle dependency versions
EIGEN_INSTALL_DIR="/tmp/deps_cache_is_for_windows_only"
BOOST_INSTALL_DIR="/tmp/deps_cache_is_for_windows_only"
SUDO='sudo'
if [[ "$RUNNER_OS" == "Linux" ]]; then
EIGEN_VERSION="apt-latest"
BOOST_VERSION="apt-latest"
elif [[ "$RUNNER_OS" == "macOS" ]]; then
EIGEN_VERSION="brew-latest"
BOOST_VERSION="brew-latest"
elif [[ "$RUNNER_OS" == "Windows" ]]; then
SUDO=''
EIGEN_VERSION=3.3.7
EIGEN_INSTALL_DIR="C:/eigen"
BOOST_VERSION=1.69.0
BOOST_INSTALL_DIR="C:/boost"
# vsdevcmd.bat is here: 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/Common7/Tools/vsdevcmd.bat'
VS_INSTALL_DIR="$(cmd //c 'vswhere -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath')"
VS_VSDEVCMD='cd /d '$VS_INSTALL_DIR'\Common7\Tools && VsDevCmd.bat -host_arch=amd64 -arch=amd64'
fi
echo "SUDO=$SUDO" | tee -a $GITHUB_ENV
echo "EIGEN_VERSION=$EIGEN_VERSION" | tee -a $GITHUB_ENV
echo "EIGEN_INSTALL_DIR=$EIGEN_INSTALL_DIR" | tee -a $GITHUB_ENV
echo "BOOST_VERSION=$BOOST_VERSION" | tee -a $GITHUB_ENV
echo "BOOST_INSTALL_DIR=$BOOST_INSTALL_DIR" | tee -a $GITHUB_ENV
echo "VS_INSTALL_DIR=$VS_INSTALL_DIR" | tee -a $GITHUB_ENV
echo "VS_VSDEVCMD=$VS_VSDEVCMD" | tee -a $GITHUB_ENV
echo "name=vs_install_dir::$(echo $VS_INSTALL_DIR)" >> $GITHUB_OUTPUT
echo "name=vs_vsdevcmd::$(echo $VS_VSDEVCMD)" >> $GITHUB_OUTPUT
- name: Install Python
id: install-python
uses: actions/setup-python@v2
with:
python-version: ${{ inputs.python_version }}
- name: Set python-dependent env vars
id: set-python-vars
shell: bash
run: |
PYTHONUSERBASE='/tmp/pythonuserbase'
if [[ "$RUNNER_OS" == "Windows" ]]; then
PYTHONUSERBASE='C:\pythonuserbase'
fi
mkdir -p "$PYTHONUSERBASE" && chmod -R 777 "$PYTHONUSERBASE"
echo "PYTHONUSERBASE=$PYTHONUSERBASE" | tee -a $GITHUB_ENV
echo "PYTHONIOENCODING=UTF-8" | tee -a $GITHUB_ENV
PYTHON_ROOT="$(find $RUNNER_TOOL_CACHE -maxdepth 3 -type d -path '**/Python/${{ steps.install-python.outputs.python-version }}*/x64')"
PYTHON_ROOT="$(cd $PYTHON_ROOT && pwd -W 2>/dev/null || pwd)"
echo "PYTHON_ROOT=$PYTHON_ROOT" | tee -a $GITHUB_ENV
echo "Python_ROOT=$PYTHON_ROOT" | tee -a $GITHUB_ENV
echo "name=python_root::$(echo $PYTHON_ROOT)" >> $GITHUB_OUTPUT
echo "name=python_version::${{ steps.install-python.outputs.python-version }}" >> $GITHUB_OUTPUT
echo "------- ls -la PYTHON_ROOT -------"
ls -la "$PYTHON_ROOT"
echo "----------------------------------"
SOFA_VERSION_FOR_DEPS="$(echo "${{ inputs.sofa_version }}" | sed 's:[^0-9]*::g')"
if [ -z "$SOFA_VERSION_FOR_DEPS" ]; then
SOFA_VERSION_FOR_DEPS=0
fi
echo "SOFA_VERSION_FOR_DEPS=$SOFA_VERSION_FOR_DEPS" | tee -a $GITHUB_ENV
- name: Install numpy and scipy
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
$PYTHON_ROOT/python -m pip install numpy scipy
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew list | grep python | while read package; do
brew unlink $package
done
$PYTHON_ROOT/python -m pip install numpy scipy
elif [[ "$RUNNER_OS" == "Windows" ]]; then
cmd //c "$PYTHON_ROOT/python.exe -m pip install numpy scipy"
fi
- name: Install build tools
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get update
sudo apt-get -qq install ccache ninja-build
sudo apt-get -qq install freeglut3-dev libopengl0
sudo apt-get -qq install libpng-dev libjpeg-dev libtiff-dev libglew-dev zlib1g-dev
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew update && brew upgrade
brew install ccache ninja
brew install glew
elif [[ "$RUNNER_OS" == "Windows" ]]; then
cmd //c 'choco install -y --no-progress nsis curl ninja'
fi
- name: Setup cache for Boost files
uses: actions/cache@v2
id: boost_cache
with:
path: ${{ env.BOOST_INSTALL_DIR }}
key: boost-${{ env.BOOST_VERSION }}_${{ runner.os }}_for-SOFA-${{ inputs.sofa_version }}_${{ hashFiles('**/*.yml') }}
- name: Install Boost
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get -qq install libboost-dev
if [ "$SOFA_VERSION_FOR_DEPS" -lt 2112 ]; then
sudo apt-get -qq install libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev
fi
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew install boost
elif [[ "$RUNNER_OS" == "Windows" ]]; then
if ! ls -a "$BOOST_INSTALL_DIR"/* >/dev/null 2>&1; then
# directory does not exist or is empty
major="$(echo $BOOST_VERSION | cut -d. -f1)"
minor="$(echo $BOOST_VERSION | cut -d. -f2)"
patch="$(echo $BOOST_VERSION | cut -d. -f3)"
if [ "$SOFA_VERSION_FOR_DEPS" -lt 2112 ]; then
# headers and libs
curl --output "${{ runner.temp }}/boost_tmp.exe" -L \
"https://downloads.sourceforge.net/project/boost/boost-binaries/${BOOST_VERSION}/boost_${major}_${minor}_${patch}-msvc-14.1-64.exe"
cmd //c "${{ runner.temp }}/boost_tmp.exe /NORESTART /VERYSILENT /DIR=$BOOST_INSTALL_DIR"
else
# headers only
curl --output "${{ runner.temp }}/boost_tmp.7z" -L \
"https://downloads.sourceforge.net/project/boost/boost/${BOOST_VERSION}/boost_${major}_${minor}_${patch}.7z"
7z x "${{ runner.temp }}/boost_tmp.7z" -o"${{ runner.temp }}/boost_tmp"
mv "${{ runner.temp }}"/boost_tmp/boost* "$BOOST_INSTALL_DIR"
fi
fi
echo "BOOST_ROOT=$BOOST_INSTALL_DIR" | tee -a $GITHUB_ENV
echo "Boost_ROOT=$BOOST_INSTALL_DIR" | tee -a $GITHUB_ENV
echo "$BOOST_INSTALL_DIR" >> $GITHUB_PATH
fi
- name: Setup cache for Eigen files
uses: actions/cache@v2
id: eigen_cache
with:
path: ${{ env.EIGEN_INSTALL_DIR }}
key: eigen-${{ env.EIGEN_VERSION }}_${{ runner.os }}_${{ hashFiles('**/*.yml') }}
- name: Install Eigen
shell: bash
run: |
if [[ "$RUNNER_OS" == "Linux" ]]; then
sudo apt-get -qq install libeigen3-dev
elif [[ "$RUNNER_OS" == "macOS" ]]; then
brew install eigen
elif [[ "$RUNNER_OS" == "Windows" ]]; then
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
echo "EIGEN3_ROOT=$EIGEN_INSTALL_DIR" | tee -a $GITHUB_ENV
echo "Eigen3_ROOT=$EIGEN_INSTALL_DIR" | tee -a $GITHUB_ENV
echo "$EIGEN_INSTALL_DIR" >> $GITHUB_PATH
fi
- name: Set env vars for pybind11 installation
shell: bash
run: |
# Define pybind11 specs
PYBIND11_VERSION=2.6.2
PYBIND11_INSTALL_PATH="/tmp/deps_cache_is_for_windows_only"
if [[ "$RUNNER_OS" == "Windows" ]]; then
PYBIND11_INSTALL_PATH="C:/pybind11"
fi
echo "PYBIND11_VERSION=$PYBIND11_VERSION" | tee -a $GITHUB_ENV
echo "PYBIND11_INSTALL_PATH=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV
- name: Setup cache for pybind11 files
uses: actions/cache@v2
id: pybind11_cache
with:
path: ${{ env.PYBIND11_INSTALL_PATH }}
key: pybind11-${{ env.PYBIND11_VERSION }}_${{ runner.os }}_python-${{ inputs.python_version }}_${{ hashFiles('**/*.yml') }}
- name: Install pybind11
shell: bash
run: |
# Build and install pybind11
if [[ "$RUNNER_OS" == "Windows" ]]; then
if ! ls -a "$PYBIND11_INSTALL_PATH"/* >/dev/null 2>&1; then
# directory does not exist or is empty
git clone -b v$PYBIND11_VERSION --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp"
cmd //c "${{ steps.set-env-vars.outputs.vs_vsdevcmd }} && \
cd /d ${{ runner.temp }}/pybind11_tmp && \
cmake \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DPYBIND11_TEST=OFF \
-DCMAKE_INSTALL_PREFIX=$PYBIND11_INSTALL_PATH \
-DPYTHON_ROOT=$PYTHON_ROOT \
-DPython_ROOT=$PYTHON_ROOT \
-DPYTHON_EXECUTABLE=$PYTHON_ROOT/python.exe \
-DPython_EXECUTABLE=$PYTHON_ROOT/python.exe \
. && \
ninja install"
fi
echo "pybind11_ROOT=$PYBIND11_INSTALL_PATH" | tee -a $GITHUB_ENV
echo "$PYBIND11_INSTALL_PATH" >> $GITHUB_PATH
else
git clone -b v${PYBIND11_VERSION} --depth 1 https://github.com/pybind/pybind11.git "${{ runner.temp }}/pybind11_tmp"
cd "${{ runner.temp }}/pybind11_tmp"
cmake \
-GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DPYBIND11_TEST=OFF \
-DPYTHON_ROOT=$PYTHON_ROOT \
-DPython_ROOT=$PYTHON_ROOT \
-DPYTHON_EXECUTABLE=$PYTHON_ROOT/python \
-DPython_EXECUTABLE=$PYTHON_ROOT/python \
.
sudo ninja install
fi
- name: Download and install the latest SOFA ${{ inputs.sofa_version }} binaries
shell: bash
run: |
# Download and install the latest SOFA ${{ inputs.sofa_version }} binaries
SOFA_OS="$RUNNER_OS"
if [[ "$SOFA_OS" == "macOS" ]]; then
SOFA_OS="MacOS"
fi
if ! ls -a "${{ inputs.sofa_root }}"/* >/dev/null 2>&1; then
# directory does not exist or is empty
mkdir -p "${{ runner.temp }}/sofa_tmp/zip" "${{ runner.temp }}/sofa_tmp/binaries"
curl --output "${{ runner.temp }}/sofa_tmp/${SOFA_OS}.zip" -L \
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/CI_BRANCH=${{ inputs.sofa_version }},CI_SCOPE=${{ inputs.sofa_scope }}/lastSuccessfulBuild/artifact/${SOFA_OS}/*zip*/${SOFA_OS}.zip
unzip -qq "${{ runner.temp }}"/sofa_tmp/${SOFA_OS}.zip -d "${{ runner.temp }}/sofa_tmp/zip"
unzip -qq "${{ runner.temp }}"/sofa_tmp/zip/${SOFA_OS}/SOFA_*.zip -d "${{ runner.temp }}/sofa_tmp/binaries"
$SUDO mkdir -p "${{ inputs.sofa_root }}"
$SUDO mv "${{ runner.temp }}"/sofa_tmp/binaries/SOFA_*/* "${{ inputs.sofa_root }}"
fi
echo '--------------------------------------------'
echo "SOFA successfully downloaded and installed in ${{ inputs.sofa_root }}"
echo '------------- inputs.sofa_root -------------'
ls -la "${{ inputs.sofa_root }}"
echo '--------------- git-info.txt ---------------'
cat "${{ inputs.sofa_root }}"/git-info.txt 2>&1 || true
- name: Set SOFA_ROOT and outputs.sofa_root
id: set-sofa-root
shell: bash
run: |
SOFA_ROOT='${{ inputs.sofa_root }}'
echo "SOFA_ROOT=$SOFA_ROOT" | tee -a $GITHUB_ENV
echo "$SOFA_ROOT" >> $GITHUB_PATH
if [[ "$RUNNER_OS" == "Windows" ]]; then
echo "$SOFA_ROOT\bin" >> $GITHUB_PATH
fi
echo "name=sofa_root::$(echo $SOFA_ROOT)" >> $GITHUB_OUTPUT