Skip to content
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

Enforce clang-tidy via CI #2802

Merged
merged 28 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
fa8374a
make clang-tidy recognize .H as a header
zingale Mar 21, 2024
bc01cf2
remove static headers
zingale Mar 24, 2024
7dd8e15
almost there...
zingale Mar 24, 2024
63dfc98
this seems to work
zingale Mar 24, 2024
437ebcb
fix spelling
zingale Mar 25, 2024
4c9cfb6
change MAX_LEV to constexpr
zingale Mar 25, 2024
40b05b9
sort the struct entries by type to reduce padding
zingale Mar 25, 2024
6125f11
use ranged-for for problem parameter array init
zingale Mar 25, 2024
fd7f880
Merge branch 'max_lev' into enforce_clang_tidy_ci
zingale Mar 25, 2024
98b5666
Merge branch 'params_in_cpp_instead_of_header' into enforce_clang_tid…
zingale Mar 25, 2024
9a8e70f
Merge branch 'clang-tidy-header' into enforce_clang_tidy_ci
zingale Mar 25, 2024
11ef0db
fix another repeated branch in the logs
zingale Mar 25, 2024
84479fd
Merge branch 'one_more_log_fix' into enforce_clang_tidy_ci
zingale Mar 25, 2024
a95f4fb
address some clang-tidy warnings in gravity
zingale Mar 25, 2024
3553c3d
Merge branch 'clang-tidy-gravity' into enforce_clang_tidy_ci
zingale Mar 25, 2024
bc4c68c
fix a fix
zingale Mar 25, 2024
f2829e7
Merge branch 'clang-tidy-gravity' into enforce_clang_tidy_ci
zingale Mar 25, 2024
58631f1
add a clang-tidy check
zingale Mar 25, 2024
6592d23
fix path
zingale Mar 25, 2024
5931fb3
disable MPI
zingale Mar 25, 2024
1476d4c
fix ignores
zingale Mar 25, 2024
0b549c6
fix again
zingale Mar 25, 2024
d9225e0
Merge branch 'development' into enforce_clang_tidy_ci
zingale Mar 26, 2024
3958073
Merge branch 'development' into enforce_clang_tidy_ci
zingale Mar 27, 2024
52ec7e0
Merge branch 'development' into enforce_clang_tidy_ci
zingale Mar 27, 2024
89df2c1
fix merge error
zingale Mar 27, 2024
e93d57e
revert
zingale Mar 27, 2024
7d8bc8f
fix
zingale Mar 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,5 @@ Checks: >
openmp-*

HeaderFilterRegex: '(/Source/*/|/Util/model_parser|^\./|^tmp_build_dir/castro_sources/*/).*\.H$'

HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx']
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
1 change: 1 addition & 0 deletions Source/driver/parse_castro_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ def write_headers_and_source(params, out_directory, struct_name):
print("namespace = ", nm)
for ifdef in ifdefs:
params_if = [q for q in params_nm if q.ifdef == ifdef]
types = set(q.dtype for q in params_if)
yut23 marked this conversation as resolved.
Show resolved Hide resolved
types = sorted(set(q.dtype for q in params_if))

if ifdef is None:
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
11 changes: 7 additions & 4 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,8 +602,11 @@ 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)
{
amrex::ignore_unused(time);
amrex::ignore_unused(dt);

yut23 marked this conversation as resolved.
Show resolved Hide resolved
advance_status status {};

amrex::ignore_unused(time);
Expand Down
Loading