Repository navigation
COMP: Widen CI coverage across platforms, linkage, and configurations #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
3312236
5b001ae
6bc54a4
ad5dfad
eb90e6b
4a0d3e0
626f8c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,9 @@ | ||
| # This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. | ||
| # See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml | ||
| # Per-PR build and test matrix; one line per axis: | ||
| # os / c_compiler GNU, Clang, and AppleClang (macOS gcc is a clang shim). | ||
| # shared BUILD_SHARED_LIBS=ON also enables the install and export test. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Google Carbon] Heads-up on two coverage gaps in this matrix:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 4a0d3e0: the matrix now checks out tags (
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correction: the version half is not fixed. This repository has no tags, so |
||
| # fslstyle -DFSLSTYLE changes behavior and on-disk output, so both values run. | ||
| # build_type one static Debug leg makes the library's assert() sites live. | ||
|
|
||
| name: CMake on multiple platforms | ||
|
|
||
| on: | ||
|
|
@@ -10,73 +14,174 @@ on: | |
|
|
||
| jobs: | ||
| build: | ||
| name: ${{ matrix.os }} ${{ matrix.c_compiler }} ${{ matrix.build_type }} shared=${{ matrix.shared }} fslstyle=${{ matrix.fslstyle }} | ||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
| # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. | ||
| fail-fast: false | ||
|
|
||
| # Set up a matrix to run the following 3 configurations: | ||
| # 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator> | ||
| # 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator> | ||
| # 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator> | ||
| # | ||
| # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. | ||
| matrix: | ||
| os: [ubuntu-latest, macos-latest] | ||
| build_type: [Release] | ||
| c_compiler: [gcc, clang] | ||
| # 'default' is what a consumer gets with no options; 'all' turns on | ||
| # the optional libraries and the FSL parity defines, which are the | ||
| # code paths no workflow compiled before. | ||
| options: [default, all] | ||
| build_type: [Release] | ||
| shared: ["OFF", "ON"] | ||
| fslstyle: ["OFF", "ON"] | ||
| include: | ||
| - os: macos-latest | ||
| c_compiler: clang | ||
| cpp_compiler: clang++ | ||
| - os: ubuntu-latest | ||
| c_compiler: gcc | ||
| cpp_compiler: g++ | ||
| - os: ubuntu-latest | ||
| c_compiler: clang | ||
| cpp_compiler: clang++ | ||
| exclude: | ||
| - os: macos-latest | ||
| c_compiler: clang | ||
| cpp_compiler: clang++ | ||
| # Single Debug leg; FSLSTYLE=ON reaches the asserts behind those defines. | ||
| - os: ubuntu-latest | ||
| c_compiler: cl | ||
| c_compiler: gcc | ||
| cpp_compiler: g++ | ||
| build_type: Debug | ||
| shared: "OFF" | ||
| fslstyle: "ON" | ||
| exclude: | ||
| # /usr/bin/gcc on macOS is a clang shim, so this would duplicate the clang leg. | ||
| - os: macos-latest | ||
| c_compiler: gcc | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| # Tags set the version that install_linking's find_package(NIFTI 3) checks. | ||
| fetch-depth: 0 | ||
|
|
||
| - name: Install optional dependencies | ||
| # cifti needs expat; only the 'all' configuration builds it. | ||
| if: runner.os == 'Linux' && matrix.options == 'all' | ||
| if: runner.os == 'Linux' | ||
| run: sudo apt-get update && sudo apt-get install -y libexpat1-dev zlib1g-dev | ||
|
|
||
| - name: Set reusable strings | ||
| # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. | ||
| id: strings | ||
| shell: bash | ||
| run: | | ||
| echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
| run: echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Configure CMake | ||
| # Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make. | ||
| # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type | ||
| run: > | ||
| cmake -B ${{ steps.strings.outputs.build-output-dir }} | ||
| -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} | ||
| -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} | ||
| -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} | ||
| ${{ matrix.options == 'all' && '-DUSE_CIFTI_CODE=ON -DUSE_FSL_CODE=ON -DFSLSTYLE=ON' || '' }} | ||
| -DBUILD_SHARED_LIBS=${{ matrix.shared }} | ||
| -DUSE_CIFTI_CODE=ON | ||
| -DUSE_FSL_CODE=ON | ||
| -DFSLSTYLE=${{ matrix.fslstyle }} | ||
| -S ${{ github.workspace }} | ||
|
|
||
| - name: Build | ||
| # Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | ||
| run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} | ||
|
|
||
| - name: Test | ||
| working-directory: ${{ steps.strings.outputs.build-output-dir }} | ||
| # Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator). | ||
| # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail | ||
| run: ctest --build-config ${{ matrix.build_type }} --output-on-failure | ||
|
|
||
| default: | ||
| # What a consumer gets from a plain "cmake -B build" with no options. | ||
| name: default configuration (no options) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Configure CMake | ||
| run: cmake -B ${{ github.workspace }}/build -S ${{ github.workspace }} | ||
| - name: Build | ||
| run: cmake --build ${{ github.workspace }}/build | ||
| - name: Test | ||
| working-directory: ${{ github.workspace }}/build | ||
| run: ctest --output-on-failure | ||
|
|
||
| minimal: | ||
| # The core-reader-only configuration a vendoring project selects. | ||
| name: minimal configuration (znzlib + niftilib only) | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Configure CMake | ||
| run: > | ||
| cmake -B ${{ github.workspace }}/build | ||
| -DCMAKE_BUILD_TYPE=Release | ||
| -DUSE_NIFTI2_CODE=OFF | ||
| -DUSE_NIFTICDF_CODE=OFF | ||
| -DUSE_CIFTI_CODE=OFF | ||
| -DUSE_FSL_CODE=OFF | ||
| -DNIFTI_BUILD_APPLICATIONS=OFF | ||
| -DDOWNLOAD_TEST_DATA=OFF | ||
| -S ${{ github.workspace }} | ||
| - name: Build | ||
| run: cmake --build ${{ github.workspace }}/build | ||
| - name: Test | ||
| working-directory: ${{ github.workspace }}/build | ||
| # No tests are registered without the applications; the job checks configure and build. | ||
| run: ctest --output-on-failure --no-tests=ignore | ||
|
|
||
| oldest-cmake: | ||
| # Builds with the cmake_minimum_required release; the data tests need FetchContent (3.11). | ||
| name: oldest supported CMake (3.10.2, tests without data) | ||
| runs-on: ubuntu-24.04 | ||
| env: | ||
| CMAKE_OLDEST: 3.10.2 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install dependencies | ||
| run: sudo apt-get update && sudo apt-get install -y libexpat1-dev zlib1g-dev | ||
| - name: Install CMake ${{ env.CMAKE_OLDEST }} | ||
| run: | | ||
| curl -sSfL -o "$RUNNER_TEMP/cmake.tar.gz" \ | ||
| "https://github.com/Kitware/CMake/releases/download/v${CMAKE_OLDEST}/cmake-${CMAKE_OLDEST}-Linux-x86_64.tar.gz" | ||
| tar -xzf "$RUNNER_TEMP/cmake.tar.gz" -C "$RUNNER_TEMP" | ||
| echo "$RUNNER_TEMP/cmake-${CMAKE_OLDEST}-Linux-x86_64/bin" >> "$GITHUB_PATH" | ||
| - name: Show CMake version | ||
| run: cmake --version | grep -F "cmake version ${CMAKE_OLDEST}" | ||
| - name: Configure CMake | ||
| run: > | ||
| cmake -B${{ github.workspace }}/build | ||
| -H${{ github.workspace }} | ||
| -DCMAKE_BUILD_TYPE=Release | ||
| -DUSE_CIFTI_CODE=ON | ||
| -DUSE_FSL_CODE=ON | ||
| -DDOWNLOAD_TEST_DATA=OFF | ||
| - name: Build | ||
| run: cmake --build ${{ github.workspace }}/build -- -j4 | ||
| - name: Test | ||
| working-directory: ${{ github.workspace }}/build | ||
| run: ctest --output-on-failure -LE NEEDS_DATA | ||
|
|
||
| exported-symbols: | ||
| # An intended ABI change updates the baseline in the same commit, so review sees it. | ||
| name: exported symbol baseline | ||
| runs-on: ubuntu-24.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: Install dependencies | ||
| run: sudo apt-get update && sudo apt-get install -y libexpat1-dev zlib1g-dev ninja-build | ||
| - name: Configure CMake | ||
| run: > | ||
| cmake -G Ninja -B ${{ github.workspace }}/build | ||
| -DCMAKE_BUILD_TYPE=Release | ||
| -DBUILD_SHARED_LIBS=ON | ||
| -DUSE_CIFTI_CODE=ON | ||
| -DUSE_FSL_CODE=ON | ||
| -S ${{ github.workspace }} | ||
| - name: Build | ||
| run: cmake --build ${{ github.workspace }}/build | ||
| - name: Collect exported symbols | ||
| run: | | ||
| sh cmake/collect_exported_symbols.sh \ | ||
| "${{ github.workspace }}/build" \ | ||
| /tmp/exported_symbols.txt | ||
| - name: Compare against the committed baseline | ||
| run: | | ||
| if ! diff -u cmake/exported_symbols_linux.txt /tmp/exported_symbols.txt; then | ||
| echo "" | ||
| echo "The exported symbol set changed." | ||
| echo "If that is intended, update cmake/exported_symbols_linux.txt" | ||
| echo "in this commit so the ABI change is visible in review:" | ||
| echo " sh cmake/collect_exported_symbols.sh <build-dir> cmake/exported_symbols_linux.txt" | ||
| exit 1 | ||
| fi | ||
| echo "Exported symbols match the baseline." | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| #!/bin/sh | ||
| # Collect the dynamic symbols exported by the built shared libraries. | ||
| # Linux/ELF only: it reads lib*.so with GNU nm -D. | ||
| # | ||
| # collect_exported_symbols.sh <build-dir> <output-file> | ||
| # | ||
| # The output is sorted "<library> <symbol>" lines, so a diff against the | ||
| # committed baseline names both the library and the symbol that moved. | ||
| # | ||
| # The library name is reported with any version suffix stripped, so a | ||
| # SOVERSION bump does not rewrite every line of the baseline: | ||
| # libniftiio.so.3.0.0 is reported as libniftiio.so. | ||
| # | ||
| # Regenerate the baseline after an intended ABI change: | ||
| # cmake -B build -DBUILD_SHARED_LIBS=ON -DUSE_CIFTI_CODE=ON -DUSE_FSL_CODE=ON | ||
| # cmake --build build | ||
| # sh cmake/collect_exported_symbols.sh build cmake/exported_symbols_linux.txt | ||
|
|
||
| set -eu | ||
|
|
||
| if [ $# -ne 2 ]; then | ||
| echo "usage: $0 <build-dir> <output-file>" >&2 | ||
| exit 2 | ||
| fi | ||
|
|
||
| build_dir=$1 | ||
| output=$2 | ||
|
|
||
| if [ ! -d "$build_dir" ]; then | ||
| echo "$0: no such build directory: $build_dir" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Match versioned sonames too (libfoo.so.3.0.0), and resolve symlinks so | ||
| # libfoo.so -> libfoo.so.3.0.0 is not counted twice. | ||
| find "$build_dir" -name 'lib*.so*' -exec readlink -f {} \; \ | ||
| | LC_ALL=C sort -u > "$output.libs" | ||
|
|
||
| if [ ! -s "$output.libs" ]; then | ||
| rm -f "$output.libs" | ||
| echo "$0: no shared libraries under $build_dir;" \ | ||
| "configure with -DBUILD_SHARED_LIBS=ON" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| : > "$output.tmp" | ||
|
|
||
| # nm writes to a file, not a pipe, so set -e sees its exit status. | ||
| while IFS= read -r lib; do | ||
| name=$(basename "$lib" | sed -E 's/\.so(\.[0-9]+)*$/.so/') | ||
| nm -D --defined-only "$lib" > "$output.nm" | ||
| awk -v name="$name" 'NF >= 3 && $3 != "" { print name, $3 }' \ | ||
| "$output.nm" >> "$output.tmp" | ||
| done < "$output.libs" | ||
|
|
||
| LC_ALL=C sort -u "$output.tmp" > "$output" | ||
| rm -f "$output.tmp" "$output.nm" "$output.libs" | ||
|
|
||
| echo "$0: wrote $(wc -l < "$output") symbols from" \ | ||
| "$(awk '{print $1}' "$output" | LC_ALL=C sort -u | wc -l) libraries to $output" |
Uh oh!
There was an error while loading. Please reload this page.