Skip to content

Commit 976e5cd

Browse files
committed
ENH: Add Build, test, package GitHub Action to run on the template
Adds steps to evaluate the template with cookiecutter and the default parameters.
1 parent 0ae5a8b commit 976e5cd

File tree

1 file changed

+261
-0
lines changed

1 file changed

+261
-0
lines changed
Lines changed: 261 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,261 @@
1+
name: Build, test, package
2+
3+
on: [push,pull_request]
4+
5+
jobs:
6+
build-test-cxx:
7+
runs-on: ${{ matrix.os }}
8+
strategy:
9+
max-parallel: 3
10+
matrix:
11+
os: [ubuntu-18.04, windows-2019, macos-10.15]
12+
include:
13+
- os: ubuntu-18.04
14+
c-compiler: "gcc"
15+
cxx-compiler: "g++"
16+
itk-git-tag: "v5.1.0"
17+
cmake-build-type: "MinSizeRel"
18+
- os: windows-2019
19+
c-compiler: "cl.exe"
20+
cxx-compiler: "cl.exe"
21+
itk-git-tag: "v5.1.0"
22+
cmake-build-type: "Release"
23+
- os: macos-10.15
24+
c-compiler: "clang"
25+
cxx-compiler: "clang++"
26+
itk-git-tag: "v5.1.0"
27+
cmake-build-type: "MinSizeRel"
28+
29+
steps:
30+
- uses: actions/checkout@v1
31+
32+
- name: Set up Python 3.7
33+
uses: actions/setup-python@v1
34+
with:
35+
python-version: 3.7
36+
37+
- name: Install build dependencies
38+
run: |
39+
python -m pip install --upgrade pip
40+
python -m pip install ninja
41+
python -m pip install cookiecutter
42+
43+
- name: Download ITK
44+
run: |
45+
cd ..
46+
git clone https://github.com/InsightSoftwareConsortium/ITK.git
47+
cd ITK
48+
git checkout ${{ matrix.itk-git-tag }}
49+
50+
- name: Build ITK
51+
if: matrix.os != 'windows-2019'
52+
run: |
53+
cd ..
54+
mkdir ITK-build
55+
cd ITK-build
56+
cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK
57+
ninja
58+
59+
- name: Build ITK
60+
if: matrix.os == 'windows-2019'
61+
run: |
62+
cd ..
63+
mkdir ITK-build
64+
cd ITK-build
65+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
66+
cmake -DCMAKE_C_COMPILER:FILEPATH="${{ matrix.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ matrix.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF -GNinja ../ITK
67+
ninja
68+
shell: cmd
69+
70+
- name: Fetch CTest driver script
71+
run: |
72+
curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O
73+
74+
- name: Evaluate template
75+
shell: bash
76+
run: |
77+
python -m cookiecutter --no-input --output-dir "${GITHUB_WORKSPACE}/../ITKModuleTemplateEvaluated" "${GITHUB_WORKSPACE}"
78+
mkdir "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated/.git"
79+
80+
- name: Configure CTest script
81+
shell: bash
82+
run: |
83+
operating_system="${{ matrix.os }}"
84+
cat > dashboard.cmake << EOF
85+
set(CTEST_SITE "GitHubActions")
86+
file(TO_CMAKE_PATH "${GITHUB_WORKSPACE}/.." CTEST_DASHBOARD_ROOT)
87+
file(TO_CMAKE_PATH "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated" CTEST_SOURCE_DIRECTORY)
88+
file(TO_CMAKE_PATH "${GITHUB_WORKSPACE}/../build" CTEST_BINARY_DIRECTORY)
89+
set(dashboard_source_name "${GITHUB_REPOSITORY}")
90+
if(ENV{GITHUB_REF} MATCHES "master")
91+
set(branch "-master")
92+
set(dashboard_model "Continuous")
93+
else()
94+
set(branch "-${GITHUB_REF}")
95+
set(dashboard_model "Experimental")
96+
endif()
97+
set(CTEST_BUILD_NAME "${GITHUB_REPOSITORY}-${operating_system}-\${branch}")
98+
set(CTEST_UPDATE_VERSION_ONLY 1)
99+
set(CTEST_TEST_ARGS \${CTEST_TEST_ARGS} PARALLEL_LEVEL \${PARALLEL_LEVEL})
100+
set(CTEST_BUILD_CONFIGURATION "Release")
101+
set(CTEST_CMAKE_GENERATOR "Ninja")
102+
set(CTEST_CUSTOM_WARNING_EXCEPTION
103+
\${CTEST_CUSTOM_WARNING_EXCEPTION}
104+
# macOS Azure VM Warning
105+
"ld: warning: text-based stub file"
106+
)
107+
set(dashboard_no_clean 1)
108+
set(ENV{CC} ${{ matrix.c-compiler }})
109+
set(ENV{CXX} ${{ matrix.cxx-compiler }})
110+
set(dashboard_cache "
111+
ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-build
112+
BUILD_TESTING:BOOL=ON
113+
")
114+
string(TIMESTAMP build_date "%Y-%m-%d")
115+
message("CDash Build Identifier: \${build_date} \${CTEST_BUILD_NAME}")
116+
message("CTEST_SITE = \${CTEST_SITE}")
117+
include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake)
118+
EOF
119+
cat dashboard.cmake
120+
121+
- name: Build and test
122+
if: matrix.os != 'windows-2019'
123+
run: |
124+
ctest -j 2 -V -S dashboard.cmake
125+
126+
- name: Build and test
127+
if: matrix.os == 'windows-2019'
128+
run: |
129+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
130+
ctest -j 2 -V -S dashboard.cmake
131+
shell: cmd
132+
133+
build-linux-python-packages:
134+
runs-on: ubuntu-18.04
135+
strategy:
136+
max-parallel: 2
137+
matrix:
138+
python-version: [35, 36, 37, 38]
139+
include:
140+
- itk-python-git-tag: "v5.1.0"
141+
142+
steps:
143+
- uses: actions/checkout@v2
144+
145+
- name: 'Free up disk space'
146+
run: |
147+
# Workaround for https://github.com/actions/virtual-environments/issues/709
148+
df -h
149+
sudo apt-get clean
150+
sudo rm -rf "/usr/local/share/boost"
151+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
152+
df -h
153+
154+
- name: Evaluate template
155+
shell: bash
156+
run: |
157+
python -m cookiecutter --no-input --output-dir "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated" "${GITHUB_WORKSPACE}"
158+
mkdir "${GITHUB_WORKSPACE}/ITKModuleTemplate/.git"
159+
160+
- name: 'Fetch build script'
161+
run: |
162+
curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O
163+
chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh
164+
165+
- name: 'Build 🐍 Python 📦 package'
166+
run: |
167+
cd "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated"
168+
export ITK_PACKAGE_VERSION=${{ matrix.itk-python-git-tag }}
169+
../dockcross-manylinux-download-cache-and-build-module-wheels.sh cp${{ matrix.python-version }}
170+
171+
- name: Publish Python package as GitHub Artifact
172+
uses: actions/upload-artifact@v1
173+
with:
174+
name: LinuxWheel${{ matrix.python-version }}
175+
path: ITKModuleTemplateEvaluated/dist
176+
177+
build-macos-python-packages:
178+
runs-on: macos-10.15
179+
strategy:
180+
max-parallel: 2
181+
matrix:
182+
include:
183+
- itk-python-git-tag: "v5.1.0"
184+
185+
steps:
186+
- uses: actions/checkout@v2
187+
188+
- name: 'Fetch build script'
189+
run: |
190+
curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/macpython-download-cache-and-build-module-wheels.sh -O
191+
chmod u+x macpython-download-cache-and-build-module-wheels.sh
192+
193+
- name: Evaluate template
194+
shell: bash
195+
run: |
196+
python -m cookiecutter --no-input --output-dir "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated" "${GITHUB_WORKSPACE}"
197+
mkdir "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated/.git"
198+
199+
- name: 'Build 🐍 Python 📦 package'
200+
run: |
201+
cd "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated"
202+
export ITK_PACKAGE_VERSION=${{ matrix.itk-python-git-tag }}
203+
export MACOSX_DEPLOYMENT_TARGET=10.9
204+
../macpython-download-cache-and-build-module-wheels.sh
205+
206+
- name: Publish Python package as GitHub Artifact
207+
uses: actions/upload-artifact@v1
208+
with:
209+
name: MacOSWheels
210+
path: ITKModuleTemplateEvaluated/dist
211+
212+
build-windows-python-packages:
213+
runs-on: windows-2019
214+
strategy:
215+
max-parallel: 2
216+
matrix:
217+
python-version-minor: [5, 6, 7, 8]
218+
include:
219+
- itk-python-git-tag: "v5.1.0"
220+
221+
steps:
222+
- uses: actions/checkout@v2
223+
224+
- name: 'Install Python'
225+
run: |
226+
$pythonArch = "64"
227+
$pythonVersion = "3.${{ matrix.python-version-minor }}"
228+
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/scikit-build/scikit-ci-addons/master/windows/install-python.ps1'))
229+
230+
- name: Evaluate template
231+
shell: bash
232+
run: |
233+
python -m cookiecutter --no-input --output-dir "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated" "${GITHUB_WORKSPACE}"
234+
mkdir "${GITHUB_WORKSPACE}/ITKModuleTemplateEvaluated/.git"
235+
236+
- name: 'Fetch build dependencies'
237+
shell: bash
238+
run: |
239+
cd ITKModuleTemplate
240+
curl -L "https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${{ matrix.itk-python-git-tag }}/ITKPythonBuilds-windows.zip" -o "ITKPythonBuilds-windows.zip"
241+
7z x ITKPythonBuilds-windows.zip -o/c/P -aoa -r
242+
curl -L "https://data.kitware.com/api/v1/file/5c0ad59d8d777f2179dd3e9c/download" -o "doxygen-1.8.11.windows.bin.zip"
243+
7z x doxygen-1.8.11.windows.bin.zip -o/c/P/doxygen -aoa -r
244+
curl -L "https://data.kitware.com/api/v1/file/5bbf87ba8d777f06b91f27d6/download/grep-win.zip" -o "grep-win.zip"
245+
7z x grep-win.zip -o/c/P/grep -aoa -r
246+
247+
- name: 'Build 🐍 Python 📦 package'
248+
shell: cmd
249+
run: |
250+
cd ITKModuleTemplateEvaluated
251+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
252+
set PATH="C:\P\grep;%PATH%"
253+
set CC=cl.exe
254+
set CXX=cl.exe
255+
C:\Python3${{ matrix.python-version-minor }}-x64\python.exe C:\P\IPP\scripts\windows_build_module_wheels.py --py-envs "3${{ matrix.python-version-minor }}-x64"
256+
257+
- name: Publish Python package as GitHub Artifact
258+
uses: actions/upload-artifact@v1
259+
with:
260+
name: WindowWheel3.${{ matrix.python-version-minor }}
261+
path: ITKModuleTemplateEvaluated/dist

0 commit comments

Comments
 (0)