Skip to content

Commit 1b32d78

Browse files
committed
ENH: Add cxx composite build action
1 parent 04f7525 commit 1b32d78

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed

action.yml

Lines changed: 134 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
name: 'Build, test, package'
2+
description: 'Build, test, and package distributions for an ITK external module.'
3+
inputs:
4+
c-compiler:
5+
required: true
6+
cxx-compiler:
7+
required: true
8+
cmake-build-type:
9+
required: false
10+
default: 'MinSizeRel'
11+
cmake-options:
12+
description: 'Additional CMake arguments to use in building and testing the current remote module.'
13+
required: false
14+
default: ''
15+
itk-cmake-options:
16+
description: 'Additional CMake arguments to use in building ITK, such as enabling certain remote modules.'
17+
required: false
18+
default: ''
19+
itk-git-tag:
20+
required: false
21+
default: '835dc01388d22c4b4c9a46b01dbdfe394ec23511' # v5.3rc04.post2
22+
23+
runs:
24+
using: "composite"
25+
steps:
26+
- name: Set up Python 3.8
27+
uses: actions/setup-python@v2
28+
with:
29+
python-version: 3.8
30+
31+
- name: Install build dependencies
32+
shell: bash
33+
run: |
34+
python -m pip install --upgrade pip
35+
python -m pip install ninja
36+
python -m pip install cookiecutter
37+
38+
- name: Get specific version of CMake, Ninja
39+
uses: lukka/[email protected]
40+
41+
- name: Download ITK
42+
shell: bash
43+
run: |
44+
cd ..
45+
git clone https://github.com/InsightSoftwareConsortium/ITK.git
46+
cd ITK
47+
git checkout ${{ inputs.itk-git-tag }}
48+
pwd
49+
50+
- name: Build ITK
51+
if: runner.os != 'Windows'
52+
shell: bash
53+
run: |
54+
cd ..
55+
mkdir ITK-build
56+
cd ITK-build
57+
cmake -DCMAKE_C_COMPILER:FILEPATH="${{ inputs.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ inputs.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ inputs.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF ${{ inputs.itk-cmake-options }} -GNinja ../ITK
58+
ninja
59+
60+
- name: Build ITK
61+
if: runner.os == 'Windows'
62+
shell: cmd
63+
run: |
64+
cd ..
65+
mkdir ITK-build
66+
cd ITK-build
67+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
68+
cmake -DCMAKE_C_COMPILER:FILEPATH="${{ inputs.c-compiler }}" -DBUILD_SHARED_LIBS:BOOL=ON -DCMAKE_CXX_COMPILER="${{ inputs.cxx-compiler }}" -DCMAKE_BUILD_TYPE:STRING=${{ inputs.cmake-build-type }} -DBUILD_TESTING:BOOL=OFF ${{ inputs.itk-cmake-options }} -GNinja ../ITK
69+
ninja
70+
71+
- name: Fetch CTest driver script
72+
shell: bash
73+
run: |
74+
curl -L https://raw.githubusercontent.com/InsightSoftwareConsortium/ITK/dashboard/itk_common.cmake -O
75+
76+
- name: Configure CTest script
77+
shell: bash
78+
run: |
79+
operating_system="${{ runner.os }}_${{ env.RUNNER_ARCH }}"
80+
echo "CTest dashboard root is at ${{ env.GITHUB_WORKSPACE }}/.."
81+
cat > dashboard.cmake << EOF
82+
set(CTEST_SITE "GitHubActions")
83+
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/.." CTEST_DASHBOARD_ROOT)
84+
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/" CTEST_SOURCE_DIRECTORY)
85+
file(TO_CMAKE_PATH "\$ENV{GITHUB_WORKSPACE}/../build" CTEST_BINARY_DIRECTORY)
86+
set(dashboard_source_name "${GITHUB_REPOSITORY}")
87+
if(ENV{GITHUB_REF} MATCHES "master")
88+
set(branch "-master")
89+
set(dashboard_model "Continuous")
90+
else()
91+
set(branch "-${GITHUB_REF}")
92+
set(dashboard_model "Experimental")
93+
endif()
94+
set(CTEST_BUILD_NAME "${GITHUB_REPOSITORY}-${operating_system}-\${branch}")
95+
set(CTEST_UPDATE_VERSION_ONLY 1)
96+
set(CTEST_TEST_ARGS \${CTEST_TEST_ARGS} PARALLEL_LEVEL \${PARALLEL_LEVEL})
97+
set(CTEST_BUILD_CONFIGURATION "Release")
98+
set(CTEST_CMAKE_GENERATOR "Ninja")
99+
set(CTEST_CUSTOM_WARNING_EXCEPTION
100+
\${CTEST_CUSTOM_WARNING_EXCEPTION}
101+
# macOS Azure VM Warning
102+
"ld: warning: text-based stub file"
103+
)
104+
set(dashboard_no_clean 1)
105+
set(ENV{CC} ${{ inputs.c-compiler }})
106+
set(ENV{CXX} ${{ inputs.cxx-compiler }})
107+
if(WIN32)
108+
set(ENV{PATH} "\${CTEST_DASHBOARD_ROOT}/ITK-build/bin;\$ENV{PATH}")
109+
endif()
110+
set(dashboard_cache "
111+
ITK_DIR:PATH=\${CTEST_DASHBOARD_ROOT}/ITK-build
112+
Module_SplitComponents_BUILD_EXAMPLES:BOOL=ON
113+
BUILD_TESTING:BOOL=ON
114+
${{ inputs.cmake-options }}
115+
")
116+
string(TIMESTAMP build_date "%Y-%m-%d")
117+
message("CDash Build Identifier: \${build_date} \${CTEST_BUILD_NAME}")
118+
message("CTEST_SITE = \${CTEST_SITE}")
119+
include(\${CTEST_SCRIPT_DIRECTORY}/itk_common.cmake)
120+
EOF
121+
cat dashboard.cmake
122+
123+
- name: Build and test
124+
if: runner.os != 'Windows'
125+
shell: bash
126+
run: |
127+
ctest --output-on-failure -j 2 -V -S dashboard.cmake
128+
129+
- name: Build and test
130+
if: runner.os == 'Windows'
131+
shell: cmd
132+
run: |
133+
call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvars64.bat"
134+
ctest --output-on-failure -j 2 -V -S dashboard.cmake

0 commit comments

Comments
 (0)