Skip to content

Commit

Permalink
Merge pull request #154 from imperialCHEPI/ci_clang
Browse files Browse the repository at this point in the history
Add clang and latest gcc to CI system
  • Loading branch information
alexdewar authored Jul 14, 2023
2 parents 3c57ead + fc34609 commit 7341988
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 11 deletions.
53 changes: 43 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,33 +23,65 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04, windows-2022]
include:
- os: ubuntu-22.04
platform: linux
- os: windows-2022
platform: windows
- platform: linux
os: ubuntu-22.04
compiler: gcc-default
is_main: true
- platform: linux
os: ubuntu-22.04
compiler: gcc-latest
is_main: false
- platform: linux
os: ubuntu-22.04
compiler: clang
is_main: false
- platform: windows
os: windows-2022
compiler: msvc
is_main: true

env:
VCPKG_ROOT: "vcpkg"
VCPKG_BINARY_SOURCES: "clear;nuget,GitHub,readwrite"

# Update when there is a new version of gcc available
LATEST_GCC_VERSION: 13

steps:
- uses: actions/checkout@v3

- name: Set up MSVC (Windows)
if: matrix.os == 'windows-2022'
if: matrix.platform == 'windows'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64

- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-22.04'
if: matrix.platform == 'linux'
run: |
sudo apt update
sudo apt upgrade -y
sudo apt install --no-install-recommends build-essential libtbb-dev ninja-build doxygen graphviz
- name: Install latest gcc (Linux)
if: matrix.compiler == 'gcc-latest'
run: |
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install g++-$LATEST_GCC_VERSION
# Use environment variable to tell CMake to compile with this version of gcc
echo CXX=g++-$LATEST_GCC_VERSION >> "$GITHUB_ENV"
- name: Install clang (Linux)
if: matrix.platform == 'linux' && matrix.compiler == 'clang'
run: |
sudo apt install --no-install-recommends clang
# Use environment variable to tell CMake to compile with clang
echo CXX=clang++ >> "$GITHUB_ENV"
- name: Install VCPKG
run: |
git clone https://github.com/Microsoft/vcpkg.git
Expand All @@ -69,6 +101,7 @@ jobs:
cmake --build --preset=release-build-${{ matrix.platform }} --target=install
- name: Upload artifacts
if: matrix.is_main
uses: actions/upload-artifact@v3
with:
name: health-gps-${{ matrix.platform }}
Expand All @@ -79,20 +112,20 @@ jobs:
run: ctest --preset=core-test-${{ matrix.platform }}

- name: Zip output folder
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') && matrix.is_main
working-directory: ${{github.workspace}}/out/install/${{ matrix.platform }}-release/bin/
run: |
mkdir ${{github.workspace}}/artifact
7z a -tzip ${{github.workspace}}/artifact/health_gps_${{ matrix.platform }}.zip *.dll *.Console*
- name: Upload release artifacts
if: startsWith(github.ref, 'refs/tags/')
if: startsWith(github.ref, 'refs/tags/') && matrix.is_main
uses: softprops/action-gh-release@v1
with:
files: artifact/health_gps_${{ matrix.platform }}.zip

- name: Doxygen release API deploy
if: matrix.platform == 'linux' && startsWith(github.ref, 'refs/tags/')
if: matrix.compiler == 'gcc-default' && startsWith(github.ref, 'refs/tags/')
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 4 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ repos:
- id: check-merge-conflict
- id: check-json
- id: check-yaml
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.3
hooks:
- id: check-github-workflows
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v16.0.6
hooks:
Expand Down
2 changes: 1 addition & 1 deletion src/HealthGPS/energy_balance_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void EnergyBalanceModel::update_risk_factors(RuntimeContext &context) {
current_risk_factors.at(age_key) = model_age;
}

double energy_intake = 0.0;
[[maybe_unused]] double energy_intake = 0.0;
std::unordered_map<core::Identifier, double> nutrient_intakes;

// Initialise nutrients to zero.
Expand Down

0 comments on commit 7341988

Please sign in to comment.