Skip to content

Commit

Permalink
Enforce clang-tidy via CI (#2802)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Mar 27, 2024
1 parent 21c2bc5 commit 931e173
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 15 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: "clang-tidy"

on: [pull_request]
jobs:
clang_tidy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Get submodules
run: |
git submodule update --init
cd external/Microphysics
git fetch; git checkout development
echo "MICROPHYSICS_HOME=$(pwd)" >> $GITHUB_ENV
cd ../amrex
git fetch; git checkout development
echo "AMREX_HOME=$(pwd)" >> $GITHUB_ENV
cd ../..
- name: Install dependencies
run: |
.github/workflows/dependencies_clang-tidy-apt-llvm.sh 17
- name: Compile flame_wave
run: |
echo $AMREX_HOME
echo $MICROPHYSICS_HOME
cd Exec/science/subchandra
make USE_MPI=FALSE USE_CLANG_TIDY=TRUE CLANG_TIDY=clang-tidy-17 CLANG_TIDY_WARN_ERROR=TRUE -j 4
22 changes: 22 additions & 0 deletions .github/workflows/dependencies_clang-tidy-apt-llvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash

set -eu -o pipefail

# `man apt.conf`:
# Number of retries to perform. If this is non-zero APT will retry
# failed files the given number of times.
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries

if [[ ! -f /etc/apt/trusted.gpg.d/apt.llvm.org.asc ]]; then
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
fi

source /etc/os-release # set UBUNTU_CODENAME

sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME} main"
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-$1 main"

sudo apt-get update

sudo apt-get install -y --no-install-recommends \
clang-tidy-$1 libomp-$1-dev
12 changes: 6 additions & 6 deletions Exec/hydro_tests/Sedov/problem_initialize.H
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ void problem_initialize ()
}
}

Real xn_zone[NumSpec];
for (int n = 0; n < NumSpec; ++n) {
xn_zone[n] = 0.0_rt;
}
Real xn_zone[NumSpec] = {0.0};
xn_zone[0] = 1.0_rt;

eos_t eos_state;
Expand Down Expand Up @@ -96,17 +93,20 @@ void problem_initialize ()
vctr = (4.0_rt / 3.0_rt) * M_PI * problem::r_init * problem::r_init * problem::r_init;

#else

amrex::Abort("Sedov problem unsupported in 3D axisymmetric geometry.");

#endif

}
else if (coord_type == 2) {


#if AMREX_SPACEDIM == 1
// Must have AMREX_SPACEDIM == 1 for this coord_type.

vctr = (4.0_rt / 3.0_rt) * M_PI * problem::r_init * problem::r_init * problem::r_init;
#else
amrex::Abort("Sedov problem unsupported in 2-D or 3-D spherical geometry.");
#endif

}

Expand Down
2 changes: 1 addition & 1 deletion Source/hydro/Castro_mol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ Castro::mol_ppm_reconstruct(const Box& bx,


void
Castro::mol_consup(const Box& bx,
Castro::mol_consup(const Box& bx, // NOLINT(readability-convert-member-functions-to-static)
#ifdef SHOCK_VAR
Array4<Real const> const& shk,
#endif
Expand Down
4 changes: 2 additions & 2 deletions Source/hydro/trans.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ Castro::trans_single(const Box& bx,


void
Castro::actual_trans_single(const Box& bx,
Castro::actual_trans_single(const Box& bx, // NOLINT(readability-convert-member-functions-to-static)
int idir_t, int idir_n, int d,
Array4<Real const> const& q_arr,
Array4<Real> const& qo_arr,
Expand Down Expand Up @@ -521,7 +521,7 @@ Castro::trans_final(const Box& bx,


void
Castro::actual_trans_final(const Box& bx,
Castro::actual_trans_final(const Box& bx, // NOLINT(readability-convert-member-functions-to-static)
int idir_n, int idir_t1, int idir_t2, int d,
Array4<Real const> const& q_arr,
Array4<Real> const& qo_arr,
Expand Down
12 changes: 6 additions & 6 deletions Source/sources/Castro_sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ Castro::print_all_source_changes(Real dt, bool is_new)
// and the hydro advance.

advance_status
Castro::pre_advance_operators (Real time, Real dt)
Castro::pre_advance_operators (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static)
{
amrex::ignore_unused(time);
amrex::ignore_unused(dt);
Expand Down Expand Up @@ -560,7 +560,7 @@ Castro::pre_advance_operators (Real time, Real dt)
// but before the hydro advance.

advance_status
Castro::pre_hydro_operators (Real time, Real dt)
Castro::pre_hydro_operators (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static)
{
amrex::ignore_unused(time);
amrex::ignore_unused(dt);
Expand All @@ -585,7 +585,7 @@ Castro::pre_hydro_operators (Real time, Real dt)
// but before the corrector sources.

advance_status
Castro::post_hydro_operators (Real time, Real dt)
Castro::post_hydro_operators (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static)
{
amrex::ignore_unused(time);
amrex::ignore_unused(dt);
Expand All @@ -602,13 +602,13 @@ Castro::post_hydro_operators (Real time, Real dt)
// Perform all operations that occur after the corrector sources.

advance_status
Castro::post_advance_operators (Real time, Real dt)
Castro::post_advance_operators (Real time, Real dt) // NOLINT(readability-convert-member-functions-to-static)
{
advance_status status {};

amrex::ignore_unused(time);
amrex::ignore_unused(dt);

advance_status status {};

#ifndef TRUE_SDC
#ifdef REACTIONS
status = do_new_reactions(time, dt);
Expand Down

0 comments on commit 931e173

Please sign in to comment.