Skip to content

Commit 68f1414

Browse files
authored
Merge pull request #3 from InsightSoftwareConsortium/test-reusable-workflow
ENH: Add ITK C++ and Python CI Reusable Workflows
2 parents a6f55fb + d5f3ab7 commit 68f1414

File tree

2 files changed

+318
-0
lines changed

2 files changed

+318
-0
lines changed

.github/workflows/build-test-cxx.yml

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
name: 'Build, Test, Package ITK Remote Module'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cmake-options:
7+
required: false
8+
type: string
9+
itk-cmake-options:
10+
required: false
11+
type: string
12+
itk-git-tag:
13+
required: false
14+
type: string
15+
default: '171fb2ba33a87041f99328a2f26612ff33aa9cc8'
16+
17+
jobs:
18+
build-test-cxx:
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
max-parallel: 3
22+
matrix:
23+
os: [ubuntu-20.04, windows-2019, macos-11]
24+
include:
25+
- os: ubuntu-20.04
26+
c-compiler: "gcc"
27+
cxx-compiler: "g++"
28+
cmake-build-type: "MinSizeRel"
29+
- os: windows-2019
30+
c-compiler: "cl.exe"
31+
cxx-compiler: "cl.exe"
32+
cmake-build-type: "Release"
33+
- os: macos-11
34+
c-compiler: "clang"
35+
cxx-compiler: "clang++"
36+
cmake-build-type: "MinSizeRel"
37+
38+
steps:
39+
- uses: actions/checkout@v2
40+
41+
- name: Set up Python 3.8
42+
uses: actions/setup-python@v2
43+
with:
44+
python-version: 3.8
45+
46+
- name: Install build dependencies
47+
run: |
48+
python -m pip install --upgrade pip
49+
python -m pip install ninja
50+
51+
- name: Get specific version of CMake, Ninja
52+
uses: lukka/[email protected]
53+
54+
- name: Download ITK
55+
run: |
56+
cd ..
57+
git clone https://github.com/InsightSoftwareConsortium/ITK.git
58+
cd ITK
59+
git checkout ${{ inputs.itk-git-tag }}
60+
61+
- name: Build ITK
62+
if: matrix.os != 'windows-2019'
63+
run: |
64+
cd ..
65+
mkdir ITK-build
66+
cd ITK-build
67+
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 ${{ inputs.itk-cmake-options }} -GNinja ../ITK
68+
ninja
69+
70+
- name: Build ITK
71+
if: matrix.os == 'windows-2019'
72+
run: |
73+
cd ..
74+
mkdir ITK-build
75+
cd ITK-build
76+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
77+
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 ${{ inputs.itk-cmake-options }} -GNinja ../ITK
78+
ninja
79+
shell: cmd
80+
81+
- name: Fetch CTest driver script
82+
run: |
83+
curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O
84+
85+
- name: Configure CTest script
86+
shell: bash
87+
run: |
88+
operating_system="${{ matrix.os }}"
89+
cat > dashboard.cmake << EOF
90+
set(CTEST_SITE "GitHubActions")
91+
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/.." CTEST_DASHBOARD_ROOT)
92+
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/" CTEST_SOURCE_DIRECTORY)
93+
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/../build" CTEST_BINARY_DIRECTORY)
94+
set(dashboard_source_name "${GITHUB_REPOSITORY}")
95+
if((ENV{GITHUB_REF_NAME} MATCHES "master" OR ENV{GITHUB_REF_NAME} MATCHES "main"))
96+
set(branch "-master")
97+
set(dashboard_model "Continuous")
98+
else()
99+
set(branch "-${GITHUB_REF}")
100+
set(dashboard_model "Experimental")
101+
endif()
102+
set(CTEST_BUILD_NAME "${GITHUB_REPOSITORY}-${operating_system}-\${branch}")
103+
set(CTEST_UPDATE_VERSION_ONLY 1)
104+
set(CTEST_TEST_ARGS \${CTEST_TEST_ARGS} PARALLEL_LEVEL \${PARALLEL_LEVEL})
105+
set(CTEST_BUILD_CONFIGURATION "Release")
106+
set(CTEST_CMAKE_GENERATOR "Ninja")
107+
set(CTEST_CUSTOM_WARNING_EXCEPTION
108+
\${CTEST_CUSTOM_WARNING_EXCEPTION}
109+
# macOS Azure VM Warning
110+
"ld: warning: text-based stub file"
111+
)
112+
set(dashboard_no_clean 1)
113+
set(ENV{CC} ${{ matrix.c-compiler }})
114+
set(ENV{CXX} ${{ matrix.cxx-compiler }})
115+
if(WIN32)
116+
set(ENV{PATH} "\${CTEST_DASHBOARD_ROOT}/ITK-build/bin;\$ENV{PATH}")
117+
endif()
118+
set(dashboard_cache "
119+
ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-build
120+
BUILD_TESTING:BOOL=ON
121+
${{ inputs.cmake-options }}
122+
")
123+
string(TIMESTAMP build_date "%Y-%m-%d")
124+
message("CDash Build Identifier: \${build_date} \${CTEST_BUILD_NAME}")
125+
message("CTEST_SITE = \${CTEST_SITE}")
126+
include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake)
127+
EOF
128+
cat dashboard.cmake
129+
130+
- name: Build and test
131+
if: matrix.os != 'windows-2019'
132+
run: |
133+
ctest --output-on-failure -j 2 -V -S dashboard.cmake
134+
135+
- name: Build and test
136+
if: matrix.os == 'windows-2019'
137+
run: |
138+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
139+
ctest --output-on-failure -j 2 -V -S dashboard.cmake
140+
shell: cmd
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: 'Build, Test, Package ITK Remote Module'
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
cmake-options:
7+
required: false
8+
type: string
9+
default: ""
10+
itk-wheel-tag:
11+
required: false
12+
type: string
13+
default: 'v5.3rc04.post3'
14+
secrets:
15+
pypi_password:
16+
required: false # Packages will not be uploaded to PyPI if not set
17+
18+
jobs:
19+
build-linux-python-packages:
20+
runs-on: ubuntu-20.04
21+
strategy:
22+
max-parallel: 2
23+
matrix:
24+
python-version: [37, 38, 39, 310]
25+
26+
steps:
27+
- uses: actions/checkout@v2
28+
29+
- name: 'Free up disk space'
30+
run: |
31+
# Workaround for https://github.com/actions/virtual-environments/issues/709
32+
df -h
33+
sudo apt-get clean
34+
sudo rm -rf "/usr/local/share/boost"
35+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
36+
df -h
37+
38+
- name: 'Fetch build script'
39+
run: |
40+
curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/dockcross-manylinux-download-cache-and-build-module-wheels.sh -O
41+
chmod u+x dockcross-manylinux-download-cache-and-build-module-wheels.sh
42+
43+
- name: 'Build 🐍 Python 📦 package'
44+
shell: bash
45+
run: |
46+
export ITK_PACKAGE_VERSION=${{ inputs.itk-wheel-tag }}
47+
if [ -z ${{ inputs.cmake-options }}]; then
48+
CMAKE_OPTIONS=""
49+
else
50+
CMAKE_OPTIONS="--cmake_options ${{ inputs.cmake-options }}"
51+
fi
52+
53+
for tarball in "-manylinux_2_28" "-manylinux2014"; do
54+
rm -rf ITKPythonPackage
55+
export TARBALL_SPECIALIZATION=${tarball}
56+
./dockcross-manylinux-download-cache-and-build-module-wheels.sh cp${{ matrix.python-version }} $CMAKE_OPTIONS
57+
done
58+
59+
- name: Publish Python package as GitHub Artifact
60+
uses: actions/upload-artifact@v1
61+
with:
62+
name: LinuxWheel${{ matrix.python-version }}
63+
path: dist
64+
65+
build-macos-python-packages:
66+
runs-on: macos-11
67+
strategy:
68+
max-parallel: 2
69+
70+
steps:
71+
- uses: actions/checkout@v2
72+
73+
- name: 'Specific XCode version'
74+
run: |
75+
sudo xcode-select -s "/Applications/Xcode_13.2.1.app"
76+
77+
- name: Get specific version of CMake, Ninja
78+
uses: lukka/[email protected]
79+
80+
- name: 'Fetch build script'
81+
run: |
82+
curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITKPythonPackage/master/scripts/macpython-download-cache-and-build-module-wheels.sh -O
83+
chmod u+x macpython-download-cache-and-build-module-wheels.sh
84+
85+
- name: 'Build 🐍 Python 📦 package'
86+
shell: bash
87+
run: |
88+
export ITK_PACKAGE_VERSION=${{ inputs.itk-wheel-tag }}
89+
export MACOSX_DEPLOYMENT_TARGET=10.9
90+
if [ -z ${{ inputs.cmake-options }}]; then
91+
CMAKE_OPTIONS=""
92+
else
93+
CMAKE_OPTIONS="--cmake_options ${{ inputs.cmake-options }}"
94+
fi
95+
./macpython-download-cache-and-build-module-wheels.sh $CMAKE_OPTIONS
96+
97+
- name: Publish Python package as GitHub Artifact
98+
uses: actions/upload-artifact@v1
99+
with:
100+
name: MacOSWheels
101+
path: dist
102+
103+
build-windows-python-packages:
104+
runs-on: windows-2019
105+
strategy:
106+
max-parallel: 2
107+
matrix:
108+
python-version-minor: [7, 8, 9, 10]
109+
110+
steps:
111+
- name: Get specific version of CMake, Ninja
112+
uses: lukka/[email protected]
113+
114+
- uses: actions/checkout@v2
115+
with:
116+
path: "im"
117+
118+
- name: 'Install Python'
119+
run: |
120+
$pythonArch = "64"
121+
$pythonVersion = "3.${{ matrix.python-version-minor }}"
122+
iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/scikit-build/scikit-ci-addons/master/windows/install-python.ps1'))
123+
124+
- name: 'Fetch build dependencies'
125+
shell: bash
126+
run: |
127+
mv im ../../
128+
cd ../../
129+
curl -L "https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/download/${{ inputs.itk-wheel-tag }}/ITKPythonBuilds-windows.zip" -o "ITKPythonBuilds-windows.zip"
130+
7z x ITKPythonBuilds-windows.zip -o/c/P -aoa -r
131+
curl -L "https://data.kitware.com/api/v1/file/5c0ad59d8d777f2179dd3e9c/download" -o "doxygen-1.8.11.windows.bin.zip"
132+
7z x doxygen-1.8.11.windows.bin.zip -o/c/P/doxygen -aoa -r
133+
curl -L "https://data.kitware.com/api/v1/file/5bbf87ba8d777f06b91f27d6/download/grep-win.zip" -o "grep-win.zip"
134+
7z x grep-win.zip -o/c/P/grep -aoa -r
135+
136+
- name: 'Build 🐍 Python 📦 package'
137+
shell: cmd
138+
run: |
139+
cd ../../im
140+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
141+
set PATH=C:\P\grep;%PATH%
142+
set CC=cl.exe
143+
set CXX=cl.exe
144+
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" --no-cleanup
145+
146+
- name: Publish Python package as GitHub Artifact
147+
uses: actions/upload-artifact@v1
148+
with:
149+
name: WindowsWheel3.${{ matrix.python-version-minor }}
150+
path: ../../im/dist
151+
152+
publish-python-packages-to-pypi:
153+
needs:
154+
- build-linux-python-packages
155+
- build-macos-python-packages
156+
- build-windows-python-packages
157+
runs-on: ubuntu-18.04
158+
159+
steps:
160+
- name: Download Python Packages
161+
uses: actions/download-artifact@v2
162+
163+
- name: Prepare packages for upload
164+
run: |
165+
ls -R
166+
for d in */; do
167+
mv ${d}/*.whl .
168+
done
169+
mkdir dist
170+
mv *.whl dist/
171+
ls dist
172+
173+
- name: Publish 🐍 Python 📦 package to PyPI
174+
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
175+
uses: pypa/gh-action-pypi-publish@master
176+
with:
177+
user: __token__
178+
password: ${{ secrets.pypi_password }}

0 commit comments

Comments
 (0)