Skip to content

Specular and diffuse #200

Specular and diffuse

Specular and diffuse #200

# This workflow builds and tests the tudat source code on Windows, Linux, and MacOS using GitHub Actions. It is triggered upon push and pull requests to master, develop, and feature branches.
# This Github actions workflow automates the build and test process of the tudat source code on Windows, Linux, and MacOS. The workflow is triggered upon push and pull requests to master, develop, and feature branches. The workflow is built on top of the GitHub starter workflow for CMake on multiple platforms.
# ccache is used to cache previous compilation results to speed up the build process across s
# The workflow is built on top of the GitHub starter workflow for CMake on multiple platforms https://github.com/actions/starter-workflows/blob/main/ci/cmake-multi-platform.yml
name: Build and Test
on:
push:
branches: [ "master", "develop"]
pull_request:
branches: [ "master", "develop"]
jobs:
build-and-test:
env:
CACHE_NUMBER: 0
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, windows-latest, macos-latest]
build_type: [Release]
c_compiler: [gcc, clang, cl]
include:
- os: windows-latest
c_compiler: cl
cpp_compiler: cl
label: win-64
path_conda_env: C:\Miniconda3\envs\tudat
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
label: linux-64
path_conda_env: /usr/share/miniconda3/envs/tudat
- os: macos-latest
c_compiler: clang
cpp_compiler: clang++
label: osx-64
path_conda_env: /Users/runner/miniconda3/envs/tudat
exclude:
- os: windows-latest
c_compiler: gcc
- os: windows-latest
c_compiler: clang
- os: ubuntu-latest
c_compiler: cl
- os: macos-latest
c_compiler: gcc
- os: macos-latest
c_compiler: cl
- os: ubuntu-latest
c_compiler: clang
steps:
- uses: actions/checkout@v4
- name: Setup conda environment using mamba
# This step sets up a conda environment using mamba, a faster alternative to conda. It creates an empty conda environment with the name 'tudat' and activates it. The environment is created using the latest version of Mambaforge, a conda distribution that includes mamba.
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Mambaforge
miniforge-version: latest
activate-environment: tudat
use-mamba: true
- name: Get date
# Get the current date and time in UTC format. This step is used to create a unique cache key for the conda environment cache by appending the date to the cache key.
# GitHub cache action doucmentation recommends refreshing the cache every 24 hours to avoid inconsistencies of package versions between the CI pipeline and local installations. This is ensured by appending the date to the cache key.See https://github.com/marketplace/actions/setup-miniconda#caching-environments for more detail.
id: get-date
run: echo "today=$(/bin/date -u '+%Y%m%d')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache conda environment
# Cache the conda environment to avoid re-installing the same packages every time the workflow runs. The cache key is based on the environment.yml file, the operating system, and the date. The cache is restored if the cache key matches the cache key of the previous run.
uses: actions/cache@v4
with:
path: ${{ matrix.path_conda_env }}
key: ${{ runner.os }}-conda-${{ env.CACHE_NUMBER }}-${{ hashFiles('environment.yml') }}-${{steps.get-date.outputs.today}}
id: cache
- name: Create conda environment from environment.yml
# Update the tudat conda environment created using the environment.yml file if the cache is not restored
run: mamba env update -n tudat -f environment.yml
if: steps.cache.outputs.cache-hit != 'true'
- name: Download tudat resources data files for Linux and MacOS
# The data files in tudat-resources are downloaded upon the installation of
# the tudat-resources conda package in the previous step, but the data files are
# not cached by the cache action. When the cache is hit, the update environment
# step is skipped, skipping the installation of the tudat-resources package,
# thereby skipping the download of the data files. Therefore, the data files must
# be downloaded manually when the cache is hit.
# This step downloads the data files in the tudat-resources package by running
# the post-link scripts in https://github.com/tudat-team/tudat-resources-feedstock/blob/master/recipe/
if: (runner.os == 'Linux' || runner.os == 'MacOS') && steps.cache.outputs.cache-hit == 'true'
run: bash -c "$(curl -fsSL https://raw.githubusercontent.com/tudat-team/tudat-resources-feedstock/master/recipe/post-link.sh)"
- name: Download tudat-resources data files for Windows
if: runner.os == 'Windows' && steps.cache.outputs.cache-hit == 'true'
run: cmd /c "curl -fsSL https://raw.githubusercontent.com/tudat-team/tudat-resources-feedstock/master/recipe/post-link.bat | cmd"
- name: Restore cached compilation results
# This third party action will setup ccache on the runner and restore any previously saved cache. Caches are saved automatically by the action after a build.
uses: hendrikmuhs/[email protected]
with:
key: ${{ matrix.os }}-${{ matrix.build_type }}
- 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
shell: bash -l {0}
run: >
cmake -B "${{ github.workspace }}/build"
-S "${{ github.workspace }}"
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DTUDAT_BUILD_GITHUB_ACTIONS=ON
- 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). Use multiple cpu cores available in the runner.
shell: bash -l {0}
run: cmake --build "${{ github.workspace }}/build" --config "${{ matrix.build_type }}" -j4
- name: Test
working-directory: "${{ github.workspace }}/build"
# 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 -j4