Skip to content

Commit 34f6603

Browse files
committed
CI: Add runners that test building with only static libraries
1 parent 4ea161b commit 34f6603

File tree

2 files changed

+57
-16
lines changed

2 files changed

+57
-16
lines changed

.github/workflows/build.yaml

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
2424
runs-on: ubuntu-latest
2525

26-
name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA ${{ matrix.openmp }} OpenMP)
26+
name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA ${{ matrix.openmp }} OpenMP, ${{ matrix.link }})
2727

2828
strategy:
2929
# Allow other runners in the matrix to continue if some fail
@@ -33,6 +33,7 @@ jobs:
3333
compiler: [gcc, clang]
3434
cuda: [with, without]
3535
openmp: [with]
36+
link: [both]
3637
include:
3738
- compiler: gcc
3839
compiler-pkgs: "g++ gcc"
@@ -61,6 +62,22 @@ jobs:
6162
cuda: without
6263
openmp: without
6364
openmp-cmake-flags: "-DNOPENMP=ON"
65+
- compiler: gcc
66+
compiler-pkgs: "g++ gcc"
67+
cc: "gcc"
68+
cxx: "g++"
69+
ccache-max: 600M
70+
cuda: with
71+
cuda-pkgs: "nvidia-cuda-dev nvidia-cuda-toolkit"
72+
cuda-cmake-flags:
73+
-DENABLE_CUDA=On
74+
-DCUDAToolkit_INCLUDE_DIR="/usr/include"
75+
-DCMAKE_CUDA_COMPILER_LAUNCHER="ccache"
76+
openmp: with
77+
link: static
78+
link-cmake-flags:
79+
-DBUILD_SHARED_LIBS=OFF
80+
-DBUILD_STATIC_LIBS=ON
6481

6582
env:
6683
CC: ${{ matrix.cc }}
@@ -85,7 +102,7 @@ jobs:
85102
# used in action/cache/restore and action/cache/save steps
86103
id: ccache-prepare
87104
run: |
88-
echo "key=ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT
105+
echo "key=ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ matrix.link }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT
89106
90107
- name: restore ccache
91108
# setup the GitHub cache used to maintain the ccache from one job to the next
@@ -95,8 +112,8 @@ jobs:
95112
key: ${{ steps.ccache-prepare.outputs.key }}
96113
# Prefer caches from the same branch. Fall back to caches from the dev branch.
97114
restore-keys: |
98-
ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ github.ref }}
99-
ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:
115+
ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ matrix.link }}:${{ github.ref }}
116+
ccache:ubuntu:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.openmp }}:${{ matrix.link }}:
100117
101118
- name: create empty libraries
102119
# This is to work around a bug in nvlink.
@@ -138,6 +155,7 @@ jobs:
138155
-DBLA_VENDOR="OpenBLAS" \
139156
${{ matrix.cuda-cmake-flags }} \
140157
${{ matrix.openmp-cmake-flags }} \
158+
${{ matrix.link-cmake-flags }} \
141159
..
142160
echo "::endgroup::"
143161
echo "::group::Build $lib"
@@ -186,16 +204,19 @@ jobs:
186204
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake" \
187205
-DBLA_VENDOR="OpenBLAS" \
188206
${{ matrix.cuda-cmake-flags }} \
207+
${{ matrix.link-cmake-flags }} \
189208
..
190209
echo "::endgroup::"
191210
printf "::group::\033[0;32m==>\033[0m Building example\n"
192211
cmake --build .
193212
echo "::endgroup::"
194213
printf "::group::\033[0;32m==>\033[0m Executing example\n"
195-
printf "\033[1;35m C binary with shared libraries\033[0m\n"
196-
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
197-
printf "\033[1;35m C++ binary with shared libraries\033[0m\n"
198-
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo
214+
if [ -f ./my_demo -a -f ./my_cxx_demo ]; then
215+
printf "\033[1;35m C binary with shared libraries\033[0m\n"
216+
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
217+
printf "\033[1;35m C++ binary with shared libraries\033[0m\n"
218+
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo
219+
fi
199220
printf "\033[1;35m C binary with statically linked libraries\033[0m\n"
200221
./my_demo_static
201222
printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n"

.github/workflows/root-cmakelists.yaml

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners
2020
runs-on: ubuntu-latest
2121

22-
name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA)
22+
name: ubuntu (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA, ${{ matrix.link }})
2323

2424
strategy:
2525
# Allow other runners in the matrix to continue if some fail
@@ -28,6 +28,7 @@ jobs:
2828
matrix:
2929
compiler: [gcc, clang]
3030
cuda: [with, without]
31+
link: [both]
3132
include:
3233
- compiler: gcc
3334
compiler-pkgs: "g++ gcc"
@@ -48,6 +49,21 @@ jobs:
4849
-DENABLE_CUDA=ON
4950
-DCUDAToolkit_INCLUDE_DIR="/usr/include"
5051
-DCMAKE_CUDA_COMPILER_LAUNCHER="ccache"
52+
- compiler: gcc
53+
compiler-pkgs: "g++ gcc"
54+
cc: "gcc"
55+
cxx: "g++"
56+
ccache-max: 600M
57+
cuda: with
58+
cuda-pkgs: "nvidia-cuda-dev nvidia-cuda-toolkit"
59+
cuda-cmake-flags:
60+
-DENABLE_CUDA=ON
61+
-DCUDAToolkit_INCLUDE_DIR="/usr/include"
62+
-DCMAKE_CUDA_COMPILER_LAUNCHER="ccache"
63+
link: static
64+
link-cmake-flags:
65+
-DBUILD_SHARED_LIBS=OFF
66+
-DBUILD_STATIC_LIBS=ON
5167

5268
env:
5369
CC: ${{ matrix.cc }}
@@ -72,7 +88,7 @@ jobs:
7288
# used in action/cache/restore and action/cache/save steps
7389
id: ccache-prepare
7490
run: |
75-
echo "key=ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT
91+
echo "key=ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT
7692
7793
- name: restore ccache
7894
# setup the GitHub cache used to maintain the ccache from one job to the next
@@ -82,8 +98,8 @@ jobs:
8298
key: ${{ steps.ccache-prepare.outputs.key }}
8399
# Prefer caches from the same branch. Fall back to caches from the dev branch.
84100
restore-keys: |
85-
ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ github.ref }}
86-
ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}
101+
ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }}:${{ github.ref }}
102+
ccache:ubuntu:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }}
87103
88104
- name: create empty libraries
89105
# This is to work around a bug in nvlink.
@@ -120,6 +136,7 @@ jobs:
120136
-DCMAKE_Fortran_COMPILER_LAUNCHER="ccache" \
121137
-DBLA_VENDOR="OpenBLAS" \
122138
${{ matrix.cuda-cmake-flags }} \
139+
${{ matrix.link-cmake-flags }} \
123140
..
124141
125142
- name: build libraries
@@ -170,16 +187,19 @@ jobs:
170187
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake" \
171188
-DBLA_VENDOR="OpenBLAS" \
172189
${{ matrix.cuda-cmake-flags }} \
190+
${{ matrix.link-cmake-flags }} \
173191
..
174192
echo "::endgroup::"
175193
printf "::group::\033[0;32m==>\033[0m Building example\n"
176194
cmake --build .
177195
echo "::endgroup::"
178196
printf "::group::\033[0;32m==>\033[0m Executing example\n"
179-
printf "\033[1;35m C binary with shared libraries\033[0m\n"
180-
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
181-
printf "\033[1;35m C++ binary with shared libraries\033[0m\n"
182-
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo
197+
if [ -f ./my_demo -a -f ./my_cxx_demo ]; then
198+
printf "\033[1;35m C binary with shared libraries\033[0m\n"
199+
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo
200+
printf "\033[1;35m C++ binary with shared libraries\033[0m\n"
201+
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo
202+
fi
183203
printf "\033[1;35m C binary with statically linked libraries\033[0m\n"
184204
./my_demo_static
185205
printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n"

0 commit comments

Comments
 (0)