-
Notifications
You must be signed in to change notification settings - Fork 17
191 lines (166 loc) · 6.47 KB
/
ubuntu.yml
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
name: Linux
on:
pull_request:
branches:
- master
schedule:
# Runs every day at 23:15
- cron: '15 23 * * *'
jobs:
build:
name: Run on ${{ matrix.os }} with SOFA ${{ matrix.sofa_branch }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
sofa_branch: [master]
steps:
- name: Setup SOFA and environment
id: sofa
uses: sofa-framework/sofa-setup-action@v5
with:
sofa_root: ${{ github.workspace }}/sofa
sofa_version: ${{ matrix.sofa_branch }}
sofa_scope: 'standard'
- name: Checkout source code
uses: actions/checkout@v2
with:
path: ${{ env.WORKSPACE_SRC_PATH }}
- name: Build caribou
run: |
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: |
$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: Install artifact
uses: actions/[email protected]
with:
name: ${{ steps.sanitize.outputs.artifact_name }}
path: ${{ env.WORKSPACE_ARTIFACT_PATH }}
- 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: |
cd $WORKSPACE_BUILD_PATH
./bin/Caribou.unittests.Geometry
- name: Caribou.Geometry.PyTest
if: ${{ always() }}
run: |
cd "$WORKSPACE_BUILD_PATH"/../src
python3 src/Caribou/Python/Geometry/pytest/Caribou_Geometry_Test.py
- name: Caribou.unittests.Topology
if: ${{ always() }}
run: |
cd $WORKSPACE_BUILD_PATH
./bin/Caribou.unittests.Topology
- name: Caribou.Topology.PyTest
if: ${{ always() }}
run: |
cd $${{ env.WORKSPACE_SRC_PATH }}
python3 src/Caribou/Python/Topology/pytest/Caribou_Topology_Test.py
- name: Caribou.unittests.Mechanics
if: ${{ always() }}
run: |
cd $WORKSPACE_BUILD_PATH
./bin/Caribou.unittests.Mechanics
- name: Caribou.unittests.SofaCaribou
if: ${{ always() }}
run: |
cd $WORKSPACE_BUILD_PATH
./bin/Caribou.unittests.SofaCaribou
- name: SofaCaribou.PyTest
if: ${{ always() }}
run: |
cd $WORKSPACE_BUILD_PATH
export PYTHONPATH=$PYTHONPATH:$CARIBOU_ROOT/lib/python3/site-packages:$SOFA_ROOT/plugins/SofaPython3/lib/python3/site-packages
python3 src/SofaCaribou/Python/pytest/SofaCaribou_Forcefield_HyperelasticForcefield.py
deploy:
name: Deploy ${{ matrix.sofa_version }}
needs: [build]
runs-on: ubuntu-20.04
if: github.event_name == 'schedule'
strategy:
matrix:
sofa_version: [ master ]
env:
SOFA_VERSION: ${{ matrix.sofa_version }}
steps:
- name: Download artifact
uses: actions/[email protected]
with:
name: caribou_${{ matrix.sofa_version }}
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y_%m_%d')"
- name: Get SOFA major/minor
id: sofa_version
run: |
if [ "$SOFA_VERSION" = "master" ]; then
echo "::set-output name=value::master"
else
echo "::set-output name=value::${SOFA_VERSION%.*}"
fi
- name: Create artifact directory
uses: appleboy/ssh-action@master
env:
ARTIFACT_TARGET: ${{ format('{0}/linux/{1}', secrets.ARTIFACT_TARGET, steps.sofa_version.outputs.value) }}
with:
host: ${{ secrets.ARTIFACT_HOST }}
username: ${{ secrets.ARTIFACT_USERNAME }}
key: ${{ secrets.ARTIFACT_KEY }}
port: ${{ secrets.ARTIFACT_PORT }}
envs: ARTIFACT_TARGET
script: mkdir -p $ARTIFACT_TARGET
- name: Deploy artifact
uses: appleboy/scp-action@master
with:
host: ${{ secrets.ARTIFACT_HOST }}
username: ${{ secrets.ARTIFACT_USERNAME }}
port: ${{ secrets.ARTIFACT_PORT }}
key: ${{ secrets.ARTIFACT_KEY }}
source: "SofaCaribou.tar.gz"
target: ${{ format('{0}/linux/{1}/SofaCaribou_{2}', secrets.ARTIFACT_TARGET, steps.sofa_version.outputs.value, steps.date.outputs.date) }}
debug: true
- name: Tag as latest
uses: appleboy/ssh-action@master
env:
ARTIFACT_TARGET: ${{ format('{0}/linux/{1}/SofaCaribou_{2}', secrets.ARTIFACT_TARGET, steps.sofa_version.outputs.value, steps.date.outputs.date) }}
ARTIFACT_LATEST: ${{ format('{0}/linux/{1}/SofaCaribou_latest.tar.gz', secrets.ARTIFACT_TARGET, steps.sofa_version.outputs.value) }}
with:
host: ${{ secrets.ARTIFACT_HOST }}
username: ${{ secrets.ARTIFACT_USERNAME }}
key: ${{ secrets.ARTIFACT_KEY }}
port: ${{ secrets.ARTIFACT_PORT }}
envs: ARTIFACT_TARGET,ARTIFACT_LATEST
script: |
mv $ARTIFACT_TARGET/SofaCaribou.tar.gz $ARTIFACT_TARGET.tar.gz
rm -rf $ARTIFACT_TARGET
rm -f $ARTIFACT_LATEST
ln -s $ARTIFACT_TARGET.tar.gz $ARTIFACT_LATEST