Skip to content

Commit 935f1f0

Browse files
authored
[GitHub] Improve workflow for Ubuntu and MacOS (#157)
* [GitHub] Improve workflow for Ubuntu and MacOS * [GitHub] Simpler names for workflows * [GitHub] FIX pybind11 install in Ubuntu workflow * [GitHub] FIX multiline command in workflows * [GitHub] FIX workflow artifact names * [GitHub] Change cache strategy * [GitHub] Clean and simplify * [GitHub] Better branch name for PRs * [GitHub] Better branch name for PRs (2) * [GitHub] CLEAN unify pybind11 install * [GitHub] Set "fail-fast: false" on all strategies * [GitHub] Clean hash in cache keys * [GitHub] FIX pybind11 cache * Quick fix Threads::Threads issue * Fix tests job name on Ubuntu * Fix artifact names
1 parent b4f5dc8 commit 935f1f0

File tree

3 files changed

+215
-124
lines changed

3 files changed

+215
-124
lines changed

.github/workflows/macos.yml

Lines changed: 110 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1,99 +1,150 @@
1-
name: CI
1+
name: MacOS CI
22

3-
on: pull_request
3+
on: [workflow_dispatch, pull_request]
44

55
jobs:
66
build:
7-
name: Building on ${{ matrix.os }}
7+
name: Building with SOFA ${{ matrix.sofa_branch }}
88
runs-on: ${{ matrix.os }}
99
strategy:
10+
fail-fast: false
1011
matrix:
1112
os: [macos-10.15]
13+
sofa_branch: [master, v21.06]
1214
env:
13-
TOKEN: ${{ secrets.SOFA_REPO_READ_TOKEN }}
1415
SOFA_ROOT: /opt/sofa
16+
SOFA_OS: MacOS
1517

1618
steps:
1719
- name: Checkout source code
1820
uses: actions/checkout@v2
1921

22+
- name: Set env vars
23+
run: |
24+
echo github.event.number = ${{ github.event.number }}
25+
echo github.event.pull_request.number = ${{ github.event.pull_request.number }}
26+
echo github.event.issue.number = ${{ github.event.issue.number }}
27+
if [ -n "${{ github.event.number }}" ]; then
28+
GIT_BRANCH="PR-${{ github.event.number }}"
29+
elif [ -n "${{ github.event.pull_request.number }}" ]; then
30+
GIT_BRANCH="PR-${{ github.event.pull_request.number }}"
31+
elif [ -n "${{ github.event.issue.number }}" ]; then
32+
GIT_BRANCH="PR-${{ github.event.issue.number }}"
33+
else
34+
GIT_BRANCH="${GITHUB_REF#refs/heads/}"
35+
fi
36+
echo "GIT_BRANCH = $GIT_BRANCH"
37+
if [ -z "$GIT_BRANCH" ]; then exit 1; fi
38+
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
39+
2040
- name: Set up Python 3.7
2141
uses: actions/setup-python@v2
2242
with:
2343
python-version: '3.7'
2444

2545
- name: Install requirements
2646
run: |
27-
brew install ccache ninja boost eigen pybind11
28-
python3 -m pip install numpy
47+
brew install eigen boost
48+
brew install ccache ninja
49+
python3 -m pip install numpy scipy
2950
30-
- name: Download SOFA nightly build
31-
run: |
32-
curl --output sofa.zip -L \
33-
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip
51+
- name: pybind11 cache files
52+
uses: actions/cache@v2
53+
id: pybind11_cache
54+
with:
55+
path: /tmp/pybind11
56+
key: pybind11_${{ env.GIT_BRANCH }}_${{ matrix.os }}_${{ hashFiles('.github/workflows/*.yml') }}
3457

35-
- name: Install SOFA nightly build
58+
- name: Build pybind11
59+
if: steps.pybind11_cache.outputs.cache-hit != 'true'
3660
run: |
37-
sudo unzip sofa.zip -d temp
38-
sudo unzip temp/MacOS/`ls temp/MacOS/` -d temp
39-
sudo rm -rf temp/MacOS
40-
sudo mv temp/`ls temp` $SOFA_ROOT
41-
rm -rf temp
42-
43-
- name: Get Time
44-
id: time
45-
uses: nanzm/[email protected]
46-
with:
47-
timeZone: 8
48-
format: 'YYYY-MM-DD-HH-mm-ss'
61+
git clone -b v2.4.3 --depth 1 https://github.com/pybind/pybind11.git /tmp/pybind11
62+
cd /tmp/pybind11
63+
cmake -DCMAKE_BUILD_TYPE=Release -DPYBIND11_TEST=OFF -DPYTHON_EXECUTABLE=$(which python3.7) .
64+
make --silent
65+
66+
- name: Install pybind11
67+
run: |
68+
cd /tmp/pybind11
69+
sudo make --silent install
70+
71+
- name: Download and install the latest SOFA ${{ matrix.sofa_branch }} binaries
72+
shell: bash
73+
run: |
74+
mkdir -p /tmp/sofa_zip
75+
mkdir -p /tmp/sofa_binaries
76+
curl --output /tmp/sofa_zip/${SOFA_OS}.zip -L \
77+
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
78+
unzip -qq /tmp/sofa_zip/${SOFA_OS}.zip -d /tmp/sofa_zip
79+
unzip -qq /tmp/sofa_zip/${SOFA_OS}/SOFA_*.zip -d /tmp/sofa_binaries
80+
sudo mv /tmp/sofa_binaries/SOFA_* ${SOFA_ROOT}
81+
sudo ls -la ${SOFA_ROOT}
82+
rm -rf /tmp/sofa_*
4983
5084
- name: ccache cache files
5185
uses: actions/cache@v2
5286
with:
5387
path: .ccache
54-
key: ${{ matrix.os }}-ccache-${{ steps.time.outputs.time }}
55-
restore-keys: |
56-
${{ matrix.os }}-ccache-
88+
key: ccache_${{ env.GIT_BRANCH }}_${{ matrix.os }}_${{ hashFiles('.github/workflows/*.yml') }}
5789

5890
- name: Build
5991
env:
6092
CCACHE_COMPRESS: true
6193
CCACHE_COMPRESSLEVEL: 6
6294
CCACHE_MAXSIZE: "500M"
63-
run:
64-
export CCACHE_BASEDIR=$GITHUB_WORKSPACE &&
65-
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache &&
66-
ccache -z &&
67-
cmake
68-
-GNinja
69-
-DCMAKE_C_COMPILER_LAUNCHER=ccache
70-
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
71-
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake
72-
-DCMAKE_BUILD_TYPE=Release
73-
-DPYTHON_EXECUTABLE=$(which python)
74-
.
75-
&& ninja && ninja install
76-
&& echo ${CCACHE_BASEDIR}
77-
&& ccache -s
78-
79-
- name: Archive production
95+
run: |
96+
export CCACHE_BASEDIR=$GITHUB_WORKSPACE
97+
export CCACHE_DIR=$GITHUB_WORKSPACE/.ccache
98+
ccache -z
99+
cmake \
100+
-GNinja \
101+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
102+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
103+
-DCMAKE_PREFIX_PATH=$SOFA_ROOT/lib/cmake \
104+
-DCMAKE_BUILD_TYPE=Release \
105+
-DPYTHON_EXECUTABLE=$(which python3.7) \
106+
.
107+
ninja install
108+
echo ${CCACHE_BASEDIR}
109+
ccache -s
110+
111+
- name: Create artifact
80112
uses: actions/upload-artifact@v2
81113
with:
82-
name: sp3-${{ matrix.os }}
114+
name: SofaPython3_${{ env.GIT_BRANCH }}_SOFA-${{ matrix.sofa_branch }}_${{ env.SOFA_OS }}
83115
path: install
84116

85117
tests:
86-
name: Testing on ${{ matrix.os }}
118+
name: Testing with SOFA ${{ matrix.sofa_branch }}
87119
needs: [build]
88120
runs-on: ${{ matrix.os }}
89121
strategy:
122+
fail-fast: false
90123
matrix:
91124
os: [macos-10.15]
125+
sofa_branch: [master, v21.06]
92126
env:
93-
TOKEN: ${{ secrets.SOFA_REPO_READ_TOKEN }}
94127
SOFA_ROOT: /opt/sofa
128+
SOFA_OS: MacOS
95129

96130
steps:
131+
- name: Set env vars
132+
run: |
133+
echo github.event.number = ${{ github.event.number }}
134+
echo github.event.pull_request.number = ${{ github.event.pull_request.number }}
135+
echo github.event.issue.number = ${{ github.event.issue.number }}
136+
if [ -n "${{ github.event.number }}" ]; then
137+
GIT_BRANCH="PR-${{ github.event.number }}"
138+
elif [ -n "${{ github.event.pull_request.number }}" ]; then
139+
GIT_BRANCH="PR-${{ github.event.pull_request.number }}"
140+
elif [ -n "${{ github.event.issue.number }}" ]; then
141+
GIT_BRANCH="PR-${{ github.event.issue.number }}"
142+
else
143+
GIT_BRANCH="${GITHUB_REF#refs/heads/}"
144+
fi
145+
echo "GIT_BRANCH = $GIT_BRANCH"
146+
if [ -z "$GIT_BRANCH" ]; then exit 1; fi
147+
echo "GIT_BRANCH=$GIT_BRANCH" >> $GITHUB_ENV
97148
98149
- name: Set up Python 3.7
99150
uses: actions/setup-python@v2
@@ -103,25 +154,25 @@ jobs:
103154
- name: Install requirements
104155
run: |
105156
brew install boost
106-
python3 -m pip install numpy
107-
108-
- name: Download SOFA nightly build
109-
run: |
110-
curl --output sofa.zip -L \
111-
https://ci.inria.fr/sofa-ci-dev/job/nightly-generate-binaries/lastSuccessfulBuild/CI_SCOPE=binaries_minimal/artifact/MacOS/*zip*/MacOS.zip
157+
python3 -m pip install numpy scipy
112158
113-
- name: Install SOFA nightly build
159+
- name: Download and install the latest SOFA ${{ matrix.sofa_branch }} binaries
160+
shell: bash
114161
run: |
115-
sudo unzip sofa.zip -d temp
116-
sudo unzip temp/MacOS/`ls temp/MacOS/` -d temp
117-
sudo rm -rf temp/MacOS
118-
sudo mv temp/`ls temp` $SOFA_ROOT
119-
rm -rf temp
162+
mkdir -p /tmp/sofa_zip
163+
mkdir -p /tmp/sofa_binaries
164+
curl --output /tmp/sofa_zip/${SOFA_OS}.zip -L \
165+
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
166+
unzip -qq /tmp/sofa_zip/${SOFA_OS}.zip -d /tmp/sofa_zip
167+
unzip -qq /tmp/sofa_zip/${SOFA_OS}/SOFA_*.zip -d /tmp/sofa_binaries
168+
sudo mv /tmp/sofa_binaries/SOFA_* ${SOFA_ROOT}
169+
sudo ls -la ${SOFA_ROOT}
170+
rm -rf /tmp/sofa_*
120171
121172
- name: Install SP3
122173
uses: actions/download-artifact@v2
123174
with:
124-
name: sp3-${{ matrix.os }}
175+
name: SofaPython3_${{ env.GIT_BRANCH }}_SOFA-${{ matrix.sofa_branch }}_${{ env.SOFA_OS }}
125176
path: SofaPython3
126177

127178
- name: Binding.Sofa.Tests

0 commit comments

Comments
 (0)