Skip to content

Commit f8696c4

Browse files
ccpp.yml: Copy CI build from kousu/ANTs
This is a duplication of kousu/ANTs#5. It will not work out of the box, because we're missing the ANTs repository. However, I plan to add a preceding `actions/checkout` step that will fill that gap. That way, we're not intermingling our own CI workflow files with the CI workflow files containd within the original ANTSx/ANTs repository.
1 parent ac7ef93 commit f8696c4

File tree

1 file changed

+279
-0
lines changed

1 file changed

+279
-0
lines changed

.github/workflows/ccpp.yml

Lines changed: 279 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,279 @@
1+
name: C/C++ CI
2+
3+
on:
4+
push:
5+
branches: [ master, matrix-build ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
11+
build:
12+
strategy:
13+
matrix:
14+
os: [ubuntu-16.04, ubuntu-18.04, macos-latest]
15+
runs-on: ${{ matrix.os }}
16+
steps:
17+
# first, rewrite OS names to be safe for github artifacts.
18+
- name: names
19+
run: |
20+
OS="${{ matrix.os }}"
21+
OS=$(echo "$OS" | sed s/://)
22+
# https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
23+
echo "::set-env name=ARTIFACT::$OS"
24+
- name: Downgrade OS X Version
25+
if: matrix.os == 'macos-latest'
26+
run: |
27+
echo "::set-env name=CMAKE_CXX_FLAGS::-mmacosx-version-min=10.12"
28+
- uses: actions/checkout@v1
29+
- name: context
30+
run: |
31+
set -x
32+
set
33+
pwd
34+
whoami
35+
hostname || true
36+
df -h || true
37+
uname -a
38+
gcc -v
39+
cmake --version
40+
ifconfig
41+
curl ifconfig.me
42+
continue-on-error: true
43+
- name: cmake generate
44+
run: |
45+
mkdir antsbin
46+
cd antsbin
47+
# TODO: check if cmake picks up CMAKE_CXX_FLAGS without being told about it
48+
cmake \
49+
-DBUILD_SHARED_LIBS=OFF \
50+
-DCMAKE_CXX_FLAGS="$CMAKE_CXX_FLAGS" \
51+
../
52+
- name: make
53+
working-directory: antsbin
54+
run: |
55+
make VERBOSE=1 -j 4
56+
timeout-minutes: 300
57+
# for debugging, don't let a crash/timeout here fail the whole build
58+
# (github CI seems glitchy about giving reliable output about what happened on timeouts)
59+
continue-on-error: true
60+
- name: pre-package
61+
run: |
62+
mkdir fakeroot/
63+
cd antsbin/ANTS-build
64+
make VERBOSE=1 -j 4 DESTDIR="../../fakeroot" install
65+
continue-on-error: true
66+
- name: package
67+
run: |
68+
# snip out the apps we need for https://github.com/neuropoly/spinalcordtoolbox, since including all of ANTS is too much
69+
mkdir sct-apps/
70+
cp antsbin/ANTS-build/Examples/{antsRegistration,antsSliceRegularizedRegistration,antsApplyTransforms,ComposeMultiTransform} sct-apps
71+
(cd sct-apps; for i in `ls`; do mv $i isct_$i; done)
72+
tar -zcvf sct-apps_${{ env.ARTIFACT }}.tar.gz sct-apps/
73+
continue-on-error: true
74+
- name: results (DEBUG)
75+
run: find .
76+
- name: Upload result
77+
uses: actions/upload-artifact@v2-preview
78+
with:
79+
name: sct-apps_${{ env.ARTIFACT }}
80+
#path: fakeroot/ # this is 2.3G large in this build
81+
path: sct-apps_${{ env.ARTIFACT }}.tar.gz
82+
83+
build-manylinuxes: # Github only supports Ubuntu natively; for other Linuxes, we need to use Docker
84+
strategy:
85+
matrix:
86+
os: ['centos:7', 'centos:8', 'archlinux']
87+
runs-on: ubuntu-latest
88+
container: ${{ matrix.os }}
89+
steps:
90+
- name: install centos toolchain
91+
if: contains(matrix.os, 'centos')
92+
run: |
93+
yum install -y make gcc gcc-c++ git zlib-devel
94+
- name: install centos toolchain
95+
if: contains(matrix.os, 'centos:8')
96+
run: |
97+
yum install -y cmake
98+
- name: install centos toolchain
99+
if: contains(matrix.os, 'centos:7')
100+
run: |
101+
# centos7 has a new enough cmake available, but it's not in the default repo
102+
yum install -y epel-release
103+
yum install -y cmake3
104+
ln -s /usr/bin/cmake3 /usr/bin/cmake # make it the default
105+
- name: install archlinux toolchain
106+
if: contains(matrix.os, 'archlinux')
107+
run: |
108+
pacman -Syy --noconfirm make cmake gcc git libffi
109+
# first, rewrite OS names to be safe for github artifacts.
110+
- name: names
111+
run: |
112+
OS="${{ matrix.os }}"
113+
OS=$(echo "$OS" | sed s/://)
114+
# https://help.github.com/en/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
115+
echo "::set-env name=ARTIFACT::$OS"
116+
- uses: actions/checkout@v1
117+
- name: context
118+
run: |
119+
set -x
120+
set
121+
pwd
122+
whoami
123+
hostname || true
124+
df -h || true
125+
uname -a
126+
gcc -v
127+
cmake --version
128+
ifconfig
129+
curl ifconfig.me
130+
continue-on-error: true
131+
- name: cmake generate
132+
run: |
133+
mkdir antsbin
134+
cd antsbin
135+
cmake \
136+
-DBUILD_SHARED_LIBS=OFF \
137+
../
138+
- name: make
139+
working-directory: antsbin
140+
run: |
141+
make VERBOSE=1 -j 4
142+
timeout-minutes: 300
143+
# for debugging, don't let a crash/timeout here fail the whole build
144+
# (github CI seems glitchy about giving reliable output about what happened on timeouts)
145+
continue-on-error: true
146+
- name: pre-package
147+
run: |
148+
mkdir fakeroot/
149+
cd antsbin/ANTS-build
150+
make VERBOSE=1 -j 4 DESTDIR="../../fakeroot" install
151+
continue-on-error: true
152+
- name: package
153+
run: |
154+
# snip out the apps we need for https://github.com/neuropoly/spinalcordtoolbox, since including all of ANTS is too much
155+
mkdir sct-apps/
156+
cp antsbin/ANTS-build/Examples/{antsRegistration,antsSliceRegularizedRegistration,antsApplyTransforms,ComposeMultiTransform} sct-apps
157+
(cd sct-apps; for i in `ls`; do mv $i isct_$i; done)
158+
tar -zcvf sct-apps_${{ env.ARTIFACT }}.tar.gz sct-apps/
159+
continue-on-error: true
160+
- name: results (DEBUG)
161+
run: find .
162+
- name: Upload result
163+
uses: actions/upload-artifact@v2-preview
164+
with:
165+
name: sct-apps_${{ env.ARTIFACT }}
166+
#path: fakeroot/ # this is 2.3G large in this build
167+
path: sct-apps_${{ env.ARTIFACT }}.tar.gz
168+
169+
release:
170+
needs: [build, build-manylinuxes]
171+
runs-on: ubuntu-latest
172+
steps:
173+
- name: Create Release
174+
id: create_release
175+
uses: actions/create-release@v1
176+
env:
177+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
178+
with:
179+
# name the release with the run_id to allow multiple builds on the same branch/tag
180+
# https://github.com/actions/create-release/issues/2#issuecomment-613591846
181+
tag_name: ${{ github.ref }}-${{github.run_id }}
182+
release_name: Release ${{ github.sha }}
183+
draft: true
184+
prerelease: true
185+
186+
187+
- uses: actions/download-artifact@v1
188+
with:
189+
name: sct-apps_centos7
190+
continue-on-error: true
191+
- name: checkin # DEBUG
192+
run: find .
193+
- name: Upload Release Asset
194+
uses: actions/upload-release-asset@v1
195+
env:
196+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
197+
with:
198+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
199+
asset_path: ./sct-apps_centos7/sct-apps_centos7.tar.gz
200+
asset_name: sct-apps_centos7.tar.gz
201+
asset_content_type: application/gzip
202+
continue-on-error: true
203+
204+
- uses: actions/download-artifact@v1
205+
with:
206+
name: sct-apps_centos8
207+
continue-on-error: true
208+
- name: checkin # DEBUG
209+
run: find .
210+
- name: Upload Release Asset
211+
uses: actions/upload-release-asset@v1
212+
env:
213+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
214+
with:
215+
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
216+
asset_path: ./sct-apps_centos8/sct-apps_centos8.tar.gz
217+
asset_name: sct-apps_centos8.tar.gz
218+
asset_content_type: application/gzip
219+
continue-on-error: true
220+
221+
- uses: actions/download-artifact@v1
222+
with:
223+
name: sct-apps_archlinux
224+
continue-on-error: true
225+
- name: Upload Release Asset
226+
uses: actions/upload-release-asset@v1
227+
env:
228+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
229+
with:
230+
upload_url: ${{ steps.create_release.outputs.upload_url }}
231+
asset_path: ./sct-apps_archlinux/sct-apps_archlinux.tar.gz
232+
asset_name: sct-apps_archlinux.tar.gz
233+
asset_content_type: application/gzip
234+
continue-on-error: true
235+
236+
- uses: actions/download-artifact@v1
237+
with:
238+
name: sct-apps_ubuntu-16.04
239+
continue-on-error: true
240+
- name: Upload Release Asset
241+
uses: actions/upload-release-asset@v1
242+
env:
243+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
244+
with:
245+
upload_url: ${{ steps.create_release.outputs.upload_url }}
246+
asset_path: ./sct-apps_ubuntu-16.04/sct-apps_ubuntu-16.04.tar.gz
247+
asset_name: sct-apps_ubuntu-16.04.tar.gz
248+
asset_content_type: application/gzip
249+
continue-on-error: true
250+
251+
- uses: actions/download-artifact@v1
252+
with:
253+
name: sct-apps_ubuntu-18.04
254+
continue-on-error: true
255+
- name: Upload Release Asset
256+
uses: actions/upload-release-asset@v1
257+
env:
258+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
259+
with:
260+
upload_url: ${{ steps.create_release.outputs.upload_url }}
261+
asset_path: ./sct-apps_ubuntu-18.04/sct-apps_ubuntu-18.04.tar.gz
262+
asset_name: sct-apps_ubuntu-18.04.tar.gz
263+
asset_content_type: application/gzip
264+
continue-on-error: true
265+
266+
- uses: actions/download-artifact@v1
267+
with:
268+
name: sct-apps_macos-latest
269+
continue-on-error: true
270+
- name: Upload Release Asset
271+
uses: actions/upload-release-asset@v1
272+
env:
273+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
274+
with:
275+
upload_url: ${{ steps.create_release.outputs.upload_url }}
276+
asset_path: ./sct-apps_macos-latest/sct-apps_macos-latest.tar.gz
277+
asset_name: sct-apps_macos-latest.tar.gz
278+
asset_content_type: application/gzip
279+
continue-on-error: true

0 commit comments

Comments
 (0)