Merge pull request #912 from DrTimothyAldenDavis/dev2 #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Build SuiteSparse using the root CMakeLists.txt | |
name: root-cmakelists | |
on: | |
workflow_dispatch: | |
push: | |
branches-ignore: | |
- '**/dev2' | |
- '**/*dev2' | |
pull_request: | |
concurrency: ci-root-cmakelists-${{ github.ref }} | |
env: | |
# string with name of libraries that are installed | |
INSTALLED_LIBS: "SuiteSparse_config:Mongoose:AMD:BTF:CAMD:CCOLAMD:COLAMD:CHOLMOD:CXSparse:LDL:KLU:UMFPACK:ParU:RBio:SPQR:SPEX:GraphBLAS:LAGraph" | |
jobs: | |
ubuntu: | |
# For available GitHub-hosted runners, see: | |
# https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners | |
runs-on: ${{ matrix.os }} | |
name: ${{ matrix.os }} (${{ matrix.compiler }} ${{ matrix.cuda }} CUDA, ${{ matrix.link }}) | |
strategy: | |
# Allow other runners in the matrix to continue if some fail | |
fail-fast: false | |
matrix: | |
os: [ubuntu-latest] | |
compiler: [gcc] | |
cuda: [with] | |
link: [both] | |
include: | |
- os: ubuntu-latest | |
compiler: gcc | |
cuda: with | |
link: both | |
- os: ubuntu-latest | |
compiler: gcc | |
cuda: without | |
link: both | |
- os: ubuntu-latest | |
compiler: clang | |
cuda: with | |
link: both | |
- os: ubuntu-latest | |
compiler: gcc | |
cuda: with | |
link: static | |
- os: ubuntu-24.04-arm | |
compiler: gcc | |
cuda: without | |
link: both | |
env: | |
CC: ${{ matrix.compiler == 'gcc' && 'gcc' || 'clang' }} | |
CXX: ${{ matrix.compiler == 'gcc' && 'g++' || 'clang++' }} | |
steps: | |
- name: get CPU information | |
run: lscpu | |
- name: checkout repository | |
uses: actions/checkout@v4 | |
- name: install dependencies | |
run: | | |
sudo apt -qq update | |
sudo apt install -y \ | |
${{ matrix.compiler == 'gcc' && 'g++ gcc' || 'clang' }} \ | |
${{ matrix.compiler == 'clang' && 'libomp-dev' || '' }} \ | |
autoconf automake ccache cmake \ | |
dvipng gfortran libgmp-dev liblapack-dev libmpfr-dev \ | |
libopenblas-dev \ | |
${{ matrix.cuda == 'with' && 'nvidia-cuda-dev nvidia-cuda-toolkit' || '' }} | |
- name: prepare ccache | |
# create key with human readable timestamp | |
# used in action/cache/restore and action/cache/save steps | |
id: ccache-prepare | |
run: | | |
echo "key=ccache:${{ matrix.os }}:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }}:${{ github.ref }}:$(date +"%Y-%m-%d_%H-%M-%S"):${{ github.sha }}" >> $GITHUB_OUTPUT | |
- name: restore ccache | |
# setup the GitHub cache used to maintain the ccache from one job to the next | |
uses: actions/cache/restore@v4 | |
with: | |
path: ~/.ccache | |
key: ${{ steps.ccache-prepare.outputs.key }} | |
# Prefer caches from the same branch. Fall back to caches from the dev branch. | |
restore-keys: | | |
ccache:${{ matrix.os }}:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }}:${{ github.ref }} | |
ccache:${{ matrix.os }}:root:${{ matrix.compiler }}:${{ matrix.cuda }}:${{ matrix.link }} | |
- name: create empty libraries | |
# This is to work around a bug in nvlink. | |
# See: https://forums.developer.nvidia.com/t/nvlink-fatal-could-not-open-input-file-when-linking-with-empty-static-library/208517 | |
if: matrix.cuda == 'with' | |
run: | | |
touch empty.c | |
gcc -fPIC -c empty.c -oempty.o | |
ar rcsv libdl.a empty.o | |
ar rcsv librt.a empty.o | |
ar rcsv libpthread.a empty.o | |
# overwrite system libraries with "valid" empty libraries | |
sudo mv ./libdl.a /usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/libdl.a | |
sudo mv ./librt.a /usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/librt.a | |
sudo mv ./libpthread.a /usr/lib/$(dpkg-architecture -qDEB_HOST_MULTIARCH)/libpthread.a | |
- name: configure ccache | |
run: | | |
test -d ~/.ccache || mkdir ~/.ccache | |
# Clang seems to generally require less cache size (smaller object files?). | |
echo "max_size = ${{ matrix.compiler == 'gcc' && '600M' || '500M' }}" >> ~/.ccache/ccache.conf | |
echo "compression = true" >> ~/.ccache/ccache.conf | |
ccache -s | |
echo "/usr/lib/ccache" >> $GITHUB_PATH | |
- name: check auto-dependency resolution | |
# no need to check this with all runners. One is enough. | |
if: ${{ matrix.cc == 'gcc' && matrix.cuda == 'without' }} | |
run: | | |
mkdir -p ${GITHUB_WORKSPACE}/build-dep && cd ${GITHUB_WORKSPACE}/build-dep | |
IFS=':' read -r -a libs <<< "${INSTALLED_LIBS}" | |
for lib in "${libs[@]}"; do | |
printf "::group:: \033[0;32m==>\033[0m Configuring to build only \033[0;32m${lib}\033[0m\n" | |
cmake --fresh \ | |
-DCMAKE_BUILD_TYPE="Release" \ | |
-DBLA_VENDOR="OpenBLAS" \ | |
-DSUITESPARSE_ENABLE_PROJECTS="${lib,,}" \ | |
.. | |
echo "::endgroup::" | |
done | |
- name: configure | |
run: | | |
mkdir -p ${GITHUB_WORKSPACE}/build && cd ${GITHUB_WORKSPACE}/build | |
cmake -DCMAKE_BUILD_TYPE='Release' \ | |
-DCMAKE_INSTALL_PREFIX=".." \ | |
-DCMAKE_C_COMPILER_LAUNCHER="ccache" \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER="ccache" \ | |
-DCMAKE_Fortran_COMPILER_LAUNCHER="ccache" \ | |
-DBLA_VENDOR="OpenBLAS" \ | |
-DSUITESPARSE_DEMOS=OFF \ | |
-DBUILD_TESTING=OFF \ | |
${{ matrix.cuda == 'with' | |
&& '-DSUITESPARSE_USE_CUDA=ON \ | |
-DSUITESPARSE_USE_STRICT=ON \ | |
-DCUDAToolkit_INCLUDE_DIRS="/usr/include" \ | |
-DCMAKE_CUDA_COMPILER_LAUNCHER="ccache"' | |
|| '' }} \ | |
${{ matrix.link == 'static' | |
&& '-DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON' | |
|| '' }} \ | |
.. | |
- name: build libraries | |
run: | | |
cd ${GITHUB_WORKSPACE}/build | |
cmake --build . | |
- name: build demos | |
run: | | |
printf "::group:: \033[0;32m==>\033[0m Configuring for demos\n" | |
cd ${GITHUB_WORKSPACE}/build | |
cmake -DSUITESPARSE_DEMOS=ON -DBUILD_TESTING=ON .. | |
echo "::endgroup::" | |
printf "::group:: \033[0;32m==>\033[0m Building demos\n" | |
cd ${GITHUB_WORKSPACE}/build | |
cmake --build . | |
echo "::endgroup::" | |
# FIXME: How to run the demos without Makefile? | |
- name: ccache status | |
continue-on-error: true | |
run: ccache -s | |
- name: save ccache | |
# Save the cache after we are done (successfully) building. | |
# This helps to retain the ccache even if the subsequent steps are failing. | |
uses: actions/cache/save@v4 | |
with: | |
path: ~/.ccache | |
key: ${{ steps.ccache-prepare.outputs.key }} | |
- name: check | |
run: | | |
cd ${GITHUB_WORKSPACE}/build | |
ctest . || ctest . --rerun-failed --output-on-failure | |
- name: install | |
run: | | |
printf "\033[0;32m==>\033[0m Installing libraries\n" | |
cd ${GITHUB_WORKSPACE}/build | |
cmake --install . | |
- name: build example using CMake | |
run: | | |
cd ${GITHUB_WORKSPACE}/Example/build | |
printf "::group::\033[0;32m==>\033[0m Configuring example\n" | |
cmake \ | |
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake" \ | |
-DBLA_VENDOR="OpenBLAS" \ | |
${{ matrix.cuda == 'with' | |
&& '-DSUITESPARSE_USE_CUDA=ON \ | |
-DSUITESPARSE_USE_STRICT=ON \ | |
-DCUDAToolkit_INCLUDE_DIRS="/usr/include" \ | |
-DCMAKE_CUDA_COMPILER_LAUNCHER="ccache"' | |
|| '' }} \ | |
${{ matrix.link == 'static' | |
&& '-DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON' | |
|| '' }} \ | |
.. | |
echo "::endgroup::" | |
printf "::group::\033[0;32m==>\033[0m Building example\n" | |
cmake --build . | |
echo "::endgroup::" | |
printf "::group::\033[0;32m==>\033[0m Executing example\n" | |
if [ -f ./my_demo -a -f ./my_cxx_demo ]; then | |
printf "\033[1;35m C binary with shared libraries\033[0m\n" | |
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo | |
printf "\033[1;35m C++ binary with shared libraries\033[0m\n" | |
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo | |
fi | |
printf "\033[1;35m C binary with statically linked libraries\033[0m\n" | |
./my_demo_static | |
printf "\033[1;35m C++ binary with statically linked libraries\033[0m\n" | |
./my_cxx_demo_static | |
echo "::endgroup::" | |
- name: test Config | |
run: | | |
IFS=':' read -r -a libs <<< "${INSTALLED_LIBS}" | |
for lib in "${libs[@]}"; do | |
printf "::group:: \033[0;32m==>\033[0m Building Config.cmake with library \033[0;32m${lib}\033[0m\n" | |
cd ${GITHUB_WORKSPACE}/TestConfig/${lib} | |
cd build | |
cmake \ | |
-DCMAKE_PREFIX_PATH="${GITHUB_WORKSPACE}/lib/cmake" \ | |
.. | |
cmake --build . --config Release | |
echo "::endgroup::" | |
done | |
- name: build example using autotools | |
run: | | |
cd ${GITHUB_WORKSPACE}/Example | |
printf "::group::\033[0;32m==>\033[0m Configuring example\n" | |
autoreconf -fi | |
mkdir build-autotools | |
cd build-autotools | |
if [ "${{ matrix.link }}" = static ]; then | |
_extra_config_flags="--enable-static --disable-shared" | |
else | |
_extra_config_flags="--enable-shared --disable-static" | |
fi | |
PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/lib/pkgconfig/ \ | |
../configure ${_extra_config_flags} | |
echo "::endgroup::" | |
printf "::group::\033[0;32m==>\033[0m Building example\n" | |
make all | |
echo "::endgroup::" | |
printf "::group::\033[0;32m==>\033[0m Executing example\n" | |
printf "\033[1;35m C binary\033[0m\n" | |
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_demo | |
printf "\033[1;35m C++ binary\033[0m\n" | |
LD_LIBRARY_PATH=${GITHUB_WORKSPACE}/lib ./my_cxx_demo | |
echo "::endgroup::" | |
IFS=':' read -r -a libs <<< "${INSTALLED_LIBS}" | |
for lib in "${libs[@]}"; do | |
printf "::group:: \033[0;32m==>\033[0m Building test with library \033[0;32m${lib}\033[0m\n" | |
cd ${GITHUB_WORKSPACE}/TestConfig/${lib} | |
autoreconf -fi | |
mkdir build-autotools && cd build-autotools | |
PKG_CONFIG_PATH=${GITHUB_WORKSPACE}/lib/pkgconfig/ \ | |
../configure ${_extra_config_flags} | |
make all | |
echo "::endgroup::" | |
done | |