forked from Tudat/tudat
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Add Continuous Integration (CI) using GitHub actions #203
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
33a446c
Trigger automated build and test using GitHub Actions upon push and p…
niketagrawal aee1c8a
Use ccache to speed up the GitHub Actions workflow build process
yiquintero c7628e8
Remove 'Set reusable strings' step from workflow
yiquintero 5c4df5d
Merge pull request #202 from tudat-team/feature/add-ccache
niketagrawal 4582bfe
Ignoring failed test in MacOS was for debugging purposes only.
niketagrawal db5d1e1
This step restores compiler cache form previous runs if available, el…
niketagrawal b6b3f09
Avoid triggering two simultaneous CI workflows upon pushing commits t…
niketagrawal 4427349
remove whitespace
niketagrawal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
# 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@v2 | ||
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 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
name: tudat | ||
channels: | ||
- conda-forge | ||
- tudat-team | ||
dependencies: | ||
- eigen | ||
- boost-cpp | ||
- tudat-resources | ||
- sofa-cmake | ||
- nrlmsise-00 | ||
- cspice-cmake |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if this would cause any problems but according to this: https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners/about-github-hosted-runners#standard-github-hosted-runners-for-public-repositories
macos-latest
only has 3 cores available if I understand correctly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the catch @LeonardoPohl :) ! We had a look and it appears the Apple M1s have 8 cores each. The macos-latest runner has 3 M1 processors, thus giving us a total of 24 cores.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah ok great, good to know thanks :)