C: Guard file creation in tests #75
Workflow file for this run
This file contains 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
name: Tests | |
on: [push, pull_request] | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
C-tests: | |
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] | |
build_type: [Release, Debug] | |
compiler: [gcc, llvm] | |
asan: ["ON"] | |
ipo: ["ON"] | |
include: | |
- os: windows-latest | |
build_type: Debug | |
compiler: msvc | |
asan: "OFF" | |
ipo: "OFF" | |
steps: | |
- uses: actions/checkout@v4 | |
- 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" | |
- name: Install dependencies | |
if: ${{ matrix.os == 'ubuntu-latest' }} | |
run: sudo apt update && | |
sudo apt install -y libnetcdf-dev libnetcdf-c++4-dev netcdf-bin | |
- name: Install dependencies (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
uses: mamba-org/setup-micromamba@v1 | |
with: | |
environment-name: build | |
init-shell: bash powershell | |
create-args: >- | |
python=3.11 libnetcdf=4.9.2 --channel conda-forge | |
- name: Setup Cpp | |
uses: aminya/setup-cpp@v1 | |
with: | |
compiler: ${{ matrix.compiler }} | |
vcvarsall: ${{ contains(matrix.os, 'windows' )}} | |
cmake: true | |
ninja: true | |
- name: Update PATH (Windows) | |
if: ${{ matrix.os == 'windows-latest' }} | |
shell: bash | |
run: | | |
echo "C:/Users/runneradmin/micromamba/envs/build/Library/bin" >> $GITHUB_PATH | |
echo "netCDF_ROOT=C:/Users/runneradmin/micromamba/envs/build/Library/cmake" >> $GITHUB_ENV | |
- name: Check netCDF config | |
shell: bash | |
run: echo "$PATH" && echo $netCDF_ROOT && nc-config --all | |
- 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_BUILD_TYPE=${{ matrix.build_type }} | |
-Dnc_complex_ENABLE_IPO=${{ matrix.ipo }} | |
-Dnc_complex_ENABLE_SANITIZER_ADDRESS=${{ matrix.asan }} | |
-S "${{ github.workspace }}" | |
-G Ninja | |
- 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 }} --verbose | |
- 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 |