Skip to content

Commit 79ffaf2

Browse files
authored
Merge pull request #20 from jnbrunet/ci_macos
Add a MacOS CI workflow
2 parents e659993 + 52ae760 commit 79ffaf2

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

.github/workflows/macos.yml

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,191 @@
1+
name: CI
2+
3+
on: pull_request
4+
5+
jobs:
6+
build:
7+
name: Building on ${{ matrix.os }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [macos-10.15]
12+
env:
13+
TOKEN: ${{ secrets.SOFA_REPO_READ_TOKEN }}
14+
SOFA_ROOT: /opt/sofa
15+
16+
steps:
17+
- name: Checkout source code
18+
uses: actions/checkout@v2
19+
20+
- name: Set up Python 3.7
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: '3.7'
24+
25+
- name: Install requirements
26+
run: |
27+
brew install ccache ninja boost eigen pybind11
28+
python3 -m pip install numpy
29+
30+
- name: Get SOFA nightly build link
31+
id: sofa_nightly_link
32+
shell: python
33+
run: |
34+
import urllib.request, json, sys, re
35+
url = 'https://api.github.com/repos/jnbrunet/sofa/actions/artifacts'
36+
req = urllib.request.Request(url)
37+
req.add_header('authorization', 'Bearer ${{ secrets.GITHUB_TOKEN }}')
38+
r = urllib.request.urlopen(req).read()
39+
artifacts = json.loads(r.decode('utf-8'))['artifacts']
40+
os_artifacts = filter(lambda a:re.search('${{ matrix.os }}', a['name'], re.I), artifacts)
41+
last_artifact_url = sorted(os_artifacts, reverse=False, key=lambda a:a['created_at'])[-1]['archive_download_url']
42+
print(f"::set-output name=link::{last_artifact_url}")
43+
44+
- name: Cache SOFA
45+
uses: actions/cache@v2
46+
id: sofa_cache
47+
with:
48+
path: /opt/sofa
49+
key: ${{ steps.sofa_nightly_link.outputs.link }}
50+
51+
- name: Download SOFA nightly build
52+
if: steps.sofa_cache.outputs.cache-hit != 'true'
53+
run: |
54+
curl --output sofa.zip \
55+
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
56+
-u jnbrunet:$TOKEN -L -o sofa.zip / \
57+
${{ steps.sofa_nightly_link.outputs.link }}
58+
59+
- name: Install SOFA nightly build
60+
if: steps.sofa_cache.outputs.cache-hit != 'true'
61+
run: sudo unzip sofa.zip -d $SOFA_ROOT
62+
63+
- name: Get Time
64+
id: time
65+
uses: nanzm/[email protected]
66+
with:
67+
timeZone: 8
68+
format: 'YYYY-MM-DD-HH-mm-ss'
69+
70+
- name: ccache cache files
71+
uses: actions/cache@v2
72+
with:
73+
path: .ccache
74+
key: ${{ matrix.os }}-ccache-${{ steps.time.outputs.time }}
75+
restore-keys: |
76+
${{ matrix.os }}-ccache-
77+
78+
- name: Build
79+
env:
80+
CCACHE_COMPRESS: true
81+
CCACHE_COMPRESSLEVEL: 6
82+
CCACHE_MAXSIZE: "500M"
83+
run:
84+
export CCACHE_BASEDIR=$GITHUB_WORKSPACE &&
85+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache &&
86+
ccache -z &&
87+
cmake
88+
-GNinja
89+
-DCMAKE_C_COMPILER_LAUNCHER=ccache
90+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
91+
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake
92+
.
93+
&& ninja && ninja install
94+
&& echo ${CCACHE_BASEDIR}
95+
&& ccache -s
96+
97+
- name: Archive production
98+
uses: actions/upload-artifact@v2
99+
with:
100+
name: sp3-${{ matrix.os }}
101+
path: install
102+
103+
tests:
104+
name: Testing on ${{ matrix.os }}
105+
needs: [build]
106+
runs-on: ${{ matrix.os }}
107+
strategy:
108+
matrix:
109+
os: [macos-10.15]
110+
env:
111+
TOKEN: ${{ secrets.SOFA_REPO_READ_TOKEN }}
112+
SOFA_ROOT: /opt/sofa
113+
114+
steps:
115+
116+
- name: Set up Python 3.7
117+
uses: actions/setup-python@v2
118+
with:
119+
python-version: '3.7'
120+
121+
- name: Install requirements
122+
run: |
123+
brew install boost
124+
python3 -m pip install numpy
125+
126+
127+
128+
- name: Get SOFA nightly build link
129+
id: sofa_nightly_link
130+
shell: python
131+
run: |
132+
import urllib.request, json, sys, re
133+
url = 'https://api.github.com/repos/jnbrunet/sofa/actions/artifacts'
134+
req = urllib.request.Request(url)
135+
req.add_header('authorization', 'Bearer ${{ secrets.GITHUB_TOKEN }}')
136+
r = urllib.request.urlopen(req).read()
137+
artifacts = json.loads(r.decode('utf-8'))['artifacts']
138+
os_artifacts = filter(lambda a:re.search('${{ matrix.os }}', a['name'], re.I), artifacts)
139+
last_artifact_url = sorted(os_artifacts, reverse=False, key=lambda a:a['created_at'])[-1]['archive_download_url']
140+
print(f"::set-output name=link::{last_artifact_url}")
141+
142+
- name: Cache SOFA
143+
uses: actions/cache@v2
144+
id: sofa_cache
145+
with:
146+
path: /opt/sofa
147+
key: ${{ steps.sofa_nightly_link.outputs.link }}
148+
149+
- name: Download SOFA nightly build
150+
if: steps.sofa_cache.outputs.cache-hit != 'true'
151+
run: |
152+
curl --output sofa.zip \
153+
--header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \
154+
-u jnbrunet:$TOKEN -L -o sofa.zip / \
155+
${{ steps.sofa_nightly_link.outputs.link }}
156+
157+
- name: Install SOFA nightly build
158+
if: steps.sofa_cache.outputs.cache-hit != 'true'
159+
run: sudo unzip sofa.zip -d $SOFA_ROOT && rm sofa.zip
160+
161+
- name: Install SP3
162+
uses: actions/download-artifact@v2
163+
with:
164+
name: sp3-${{ matrix.os }}
165+
path: SofaPython3
166+
167+
- name: Binding.Sofa.Tests
168+
if: ${{ always() }}
169+
run: |
170+
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaValidation/lib:$SOFA_ROOT/plugins/SofaNonUniformFem/lib:$SOFA_ROOT/plugins/SofaDenseSolver/lib:$LD_LIBRARY_PATH
171+
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/site-packages:$PYTHONPATH
172+
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins/SofaSparseSolver/lib
173+
chmod +x SofaPython3/bin/Bindings.Sofa.Tests
174+
./SofaPython3/bin/Bindings.Sofa.Tests
175+
- name: Bindings.SofaRuntime.Tests
176+
if: ${{ always() }}
177+
run: |
178+
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaValidation/lib:$SOFA_ROOT/plugins/SofaNonUniformFem/lib:$SOFA_ROOT/plugins/SofaDenseSolver/lib:$LD_LIBRARY_PATH
179+
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/site-packages:$PYTHONPATH
180+
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins/SofaSparseSolver/lib
181+
chmod +x SofaPython3/bin/Bindings.SofaRuntime.Tests
182+
./SofaPython3/bin/Bindings.SofaRuntime.Tests
183+
- name: Bindings.SofaTypes.Tests
184+
if: ${{ always() }}
185+
run: |
186+
export DYLD_LIBRARY_PATH=$GITHUB_WORKSPACE/SofaPython3/lib:$SOFA_ROOT/lib:$SOFA_ROOT/plugins/SofaValidation/lib:$SOFA_ROOT/plugins/SofaNonUniformFem/lib:$SOFA_ROOT/plugins/SofaDenseSolver/lib:$LD_LIBRARY_PATH
187+
export PYTHONPATH=$GITHUB_WORKSPACE/SofaPython3/lib/site-packages:$PYTHONPATH
188+
export SOFA_PLUGIN_PATH=$SOFA_ROOT/plugins/SofaSparseSolver/lib
189+
chmod +x SofaPython3/bin/Bindings.SofaTypes.Tests
190+
./SofaPython3/bin/Bindings.SofaTypes.Tests
191+

0 commit comments

Comments
 (0)