Skip to content

Commit 2b6ae9e

Browse files
authored
Merge pull request #30 from InsightSoftwareConsortium/github-actions
2 parents 1779487 + ef01cad commit 2b6ae9e

File tree

8 files changed

+368
-83
lines changed

8 files changed

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

README.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ITKLabelErodeDilate
22
===================
33

4+
.. image:: https://github.com/InsightSoftwareConsortium/ITKLabelErodeDilate/workflows/Build,%20test,%20package/badge.svg
5+
46
.. |CircleCI| image:: https://circleci.com/gh/InsightSoftwareConsortium/ITKLabelErodeDilate.svg?style=shield
57
:target: https://circleci.com/gh/InsightSoftwareConsortium/ITKLabelErodeDilate
68

include/itkLabelSetDilateImageFilter.hxx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,32 @@ namespace itk
3232
template <typename TInputImage, typename TOutputImage>
3333
void
3434
LabelSetDilateImageFilter<TInputImage, TOutputImage>::ThreadedGenerateData(
35-
const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId)
35+
const OutputImageRegionType & outputRegionForThread,
36+
ThreadIdType threadId)
3637
{
37-
// compute the number of rows first, so we can setup a progress reporter
38-
typename std::vector< unsigned int > NumberOfRows;
39-
InputSizeType size = outputRegionForThread.GetSize();
38+
// compute the number of rows first, so we can setup a progress reporter
39+
typename std::vector<unsigned int> NumberOfRows;
40+
InputSizeType size = outputRegionForThread.GetSize();
4041

41-
for ( unsigned int i = 0; i < InputImageDimension; i++ )
42+
for (unsigned int i = 0; i < InputImageDimension; i++)
43+
{
44+
NumberOfRows.push_back(1);
45+
for (unsigned int d = 0; d < InputImageDimension; d++)
4246
{
43-
NumberOfRows.push_back(1);
44-
for ( unsigned int d = 0; d < InputImageDimension; d++ )
45-
{
46-
if ( d != i )
47-
{
48-
NumberOfRows[i] *= size[d];
49-
}
50-
}
47+
if (d != i)
48+
{
49+
NumberOfRows[i] *= size[d];
50+
}
5151
}
52-
float progressPerDimension = 1.0 / ImageDimension;
53-
54-
auto *progress = new ProgressReporter(this,
55-
threadId,
56-
NumberOfRows[this->m_CurrentDimension],
57-
30,
58-
this->m_CurrentDimension * progressPerDimension,
59-
progressPerDimension);
52+
}
53+
float progressPerDimension = 1.0 / ImageDimension;
54+
55+
auto * progress = new ProgressReporter(this,
56+
threadId,
57+
NumberOfRows[this->m_CurrentDimension],
58+
30,
59+
this->m_CurrentDimension * progressPerDimension,
60+
progressPerDimension);
6061

6162
// this is where the work happens. We use a distance image with
6263
// floating point pixel to perform the parabolic operations. The

include/itkLabelSetErodeImageFilter.hxx

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ namespace itk
3232
template <typename TInputImage, typename TOutputImage>
3333
void
3434
LabelSetErodeImageFilter<TInputImage, TOutputImage>::ThreadedGenerateData(
35-
const OutputImageRegionType & outputRegionForThread, ThreadIdType threadId)
35+
const OutputImageRegionType & outputRegionForThread,
36+
ThreadIdType threadId)
3637
{
3738
// this is where the work happens. We use a distance image with
3839
// floating point pixel to perform the parabolic operations. The
@@ -43,28 +44,28 @@ LabelSetErodeImageFilter<TInputImage, TOutputImage>::ThreadedGenerateData(
4344
// Similarly, the thresholding on output needs to be integrated
4445
// with the last processing stage.
4546

46-
typename std::vector< unsigned int > NumberOfRows;
47-
InputSizeType size = outputRegionForThread.GetSize();
47+
typename std::vector<unsigned int> NumberOfRows;
48+
InputSizeType size = outputRegionForThread.GetSize();
4849

49-
for ( unsigned int i = 0; i < InputImageDimension; i++ )
50+
for (unsigned int i = 0; i < InputImageDimension; i++)
5051
{
51-
NumberOfRows.push_back(1);
52-
for ( unsigned int d = 0; d < InputImageDimension; d++ )
52+
NumberOfRows.push_back(1);
53+
for (unsigned int d = 0; d < InputImageDimension; d++)
54+
{
55+
if (d != i)
5356
{
54-
if ( d != i )
55-
{
56-
NumberOfRows[i] *= size[d];
57-
}
57+
NumberOfRows[i] *= size[d];
5858
}
59+
}
5960
}
6061
float progressPerDimension = 1.0 / ImageDimension;
6162

62-
auto *progress = new ProgressReporter(this,
63-
threadId,
64-
NumberOfRows[this->m_CurrentDimension],
65-
30,
66-
this->m_CurrentDimension * progressPerDimension,
67-
progressPerDimension);
63+
auto * progress = new ProgressReporter(this,
64+
threadId,
65+
NumberOfRows[this->m_CurrentDimension],
66+
30,
67+
this->m_CurrentDimension * progressPerDimension,
68+
progressPerDimension);
6869

6970
using InputConstIteratorType = ImageLinearConstIteratorWithIndex<TInputImage>;
7071
using OutputIteratorType = ImageLinearIteratorWithIndex<TOutputImage>;

0 commit comments

Comments
 (0)