Continuous Integration #98
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: Continuous Integration | |
on: | |
push: | |
branches: | |
- main | |
- develop | |
pull_request: | |
branches-ignore: | |
- documentation | |
workflow_dispatch: | |
defaults: | |
run: | |
# Enable Conda environment by using the login shell: | |
shell: bash -leo pipefail {0} | |
jobs: | |
CI: | |
strategy: | |
fail-fast: false | |
matrix: | |
os: [ubuntu-22.04, macos-13, windows-2022] | |
compiler: [gfortran-10, gfortran-11, gfortran-12, gfortran-13, gfortran-14] | |
use-conda: [true, false] | |
fpmodel: [DP, SP] | |
# Conda does not contain gfortran-10/11/12 for windows and gfortran-14 for macos | |
exclude: | |
- os: windows-2022 | |
compiler: gfortran-10 | |
- os: windows-2022 | |
compiler: gfortran-11 | |
- os: windows-2022 | |
compiler: gfortran-12 | |
- os: macos-13 | |
compiler: gfortran-14 | |
- os: windows-2022 | |
use-conda: false | |
- os: macos-13 | |
use-conda: false | |
env: | |
FC: ${{ matrix.compiler }} | |
FCFLAGS: "-ffree-line-length-none -m64 -std=f2008 -march=native -fbounds-check -fmodule-private -fimplicit-none -finit-real=nan -g" | |
RTE_KERNELS: default | |
RTE_BOOL: C | |
RRTMGP_DATA_VERSION: v1.8.2 | |
FAILURE_THRESHOLD: 7.e-4 | |
BUILD_TYPE: Debug # Debug, Release, RelWithDebInfo, MinSizeRel | |
runs-on: ${{ matrix.os }} | |
steps: | |
# | |
# Relax failure thresholds for single precision | |
# | |
- name: Relax failure threshold for single precision | |
if: matrix.fpmodel == 'SP' | |
run: echo "FAILURE_THRESHOLD=3.5e-1" >> $GITHUB_ENV | |
# | |
# Check out repository under $GITHUB_WORKSPACE | |
# | |
- name: Check out code | |
uses: actions/checkout@v4 | |
# | |
# Cache Conda packages | |
# | |
- name: Cache Conda packages | |
uses: actions/cache@v4 | |
with: | |
path: ~/conda_pkgs_dir | |
key: conda-pkgs-${{ matrix.os }} | |
# | |
# Set up Conda | |
# | |
- name: Set up Conda | |
uses: conda-incubator/setup-miniconda@v3 | |
with: | |
miniforge-version: latest | |
activate-environment: rte_rrtmgp_test | |
environment-file: environment-noplots.yml | |
python-version: 3.11 | |
auto-activate-base: false | |
# Use the cache properly: | |
use-only-tar-bz2: false | |
# | |
# Install dependencies | |
# | |
- name: Install dependencies | |
run: | | |
FC_VERSION="${{ env.FC }}" | |
FC_VERSION="${FC_VERSION##*-}" | |
echo "FC version: $FC_VERSION" | |
conda install -c conda-forge netcdf-fortran ninja -y | |
if ${{ matrix.use-conda }}; then | |
conda install -c conda-forge gfortran=$FC_VERSION | |
fi | |
# | |
# Build libraries, examples, and tests | |
# | |
- name: Build libraries and tests | |
run: | | |
# Set platform-specific variables | |
AR_PATH="$(which ar)" | |
RANLIB_PATH="$(which ranlib)" | |
FC_PATH="$(which gfortran)" | |
if [[ "${{ matrix.os }}" == "windows-2022" ]]; then | |
AR_PATH="$AR_PATH.exe" | |
RANLIB_PATH="$RANLIB_PATH.exe" | |
FC_PATH="$FC_PATH.exe" | |
fi | |
if ! ${{ matrix.use-conda }}; then | |
FC_PATH=$FC | |
fi | |
echo "Using AR: $AR_PATH" | |
echo "Using RANLIB: $RANLIB_PATH" | |
echo "Using FC: $FC_PATH" | |
# Run CMake | |
cmake -S . -B build -G "Ninja" \ | |
-DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} \ | |
-DCMAKE_Fortran_COMPILER="$FC_PATH" \ | |
-DCMAKE_Fortran_FLAGS="${{ env.FCFLAGS }}" \ | |
-DCMAKE_AR="$AR_PATH" \ | |
-DCMAKE_RANLIB="$RANLIB_PATH" \ | |
-DRRTMGP_DATA_VERSION=${{ env.RRTMGP_DATA_VERSION }} \ | |
-DPRECISION=${{ matrix.fpmodel }} \ | |
-DBOOL_TYPE=${{ env.RTE_BOOL }} \ | |
-DKERNEL_MODE=${{ env.RTE_KERNELS }} \ | |
-DENABLE_TESTS=ON \ | |
-DFAILURE_THRESHOLD=${{ env.FAILURE_THRESHOLD }} | |
# Build the project | |
cmake --build build -- -j8 | |
# | |
# Run examples, tests and checks | |
# | |
- name: Run examples, tests and checks | |
working-directory: build | |
run: | | |
ctest -V --output-on-failure |