diff --git a/.github/workflows/clang-tidy.yml b/.github/workflows/clang-tidy.yml new file mode 100644 index 0000000000..1a4435a650 --- /dev/null +++ b/.github/workflows/clang-tidy.yml @@ -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 + diff --git a/.github/workflows/dependencies_clang-tidy-apt-llvm.sh b/.github/workflows/dependencies_clang-tidy-apt-llvm.sh new file mode 100755 index 0000000000..b64cd619eb --- /dev/null +++ b/.github/workflows/dependencies_clang-tidy-apt-llvm.sh @@ -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 diff --git a/Exec/hydro_tests/Sedov/problem_initialize.H b/Exec/hydro_tests/Sedov/problem_initialize.H index b056e41349..fb0eb76814 100644 --- a/Exec/hydro_tests/Sedov/problem_initialize.H +++ b/Exec/hydro_tests/Sedov/problem_initialize.H @@ -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; @@ -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 } diff --git a/Source/hydro/Castro_mol.cpp b/Source/hydro/Castro_mol.cpp index 23a004c719..eb6314769c 100644 --- a/Source/hydro/Castro_mol.cpp +++ b/Source/hydro/Castro_mol.cpp @@ -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 const& shk, #endif diff --git a/Source/hydro/trans.cpp b/Source/hydro/trans.cpp index 9c85de9df1..acbc4947df 100644 --- a/Source/hydro/trans.cpp +++ b/Source/hydro/trans.cpp @@ -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 const& q_arr, Array4 const& qo_arr, @@ -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 const& q_arr, Array4 const& qo_arr, diff --git a/Source/sources/Castro_sources.cpp b/Source/sources/Castro_sources.cpp index fc5dddce4f..67d736a6d7 100644 --- a/Source/sources/Castro_sources.cpp +++ b/Source/sources/Castro_sources.cpp @@ -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); @@ -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); @@ -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); @@ -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);