Skip to content

Commit

Permalink
add clang-tidy build CI for burn_cell_sdc (#1530)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Apr 10, 2024
1 parent 983c8e6 commit d4312a6
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 6 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: "clang-tidy"

on: [pull_request]

concurrency:
group: ${{ github.ref }}-${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true

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

- name: Get AMReX
run: |
mkdir external
cd external
git clone https://github.com/AMReX-Codes/amrex.git
cd amrex
git checkout development
echo 'AMREX_HOME=$(GITHUB_WORKSPACE)/external/amrex' >> $GITHUB_ENV
echo $AMREX_HOME
if [[ -n "${AMREX_HOME}" ]]; then exit 1; fi
cd ../..
- name: Install dependencies
run: |
.github/workflows/dependencies_clang-tidy-apt-llvm.sh 17
- name: Compile burn_cell_sdc
run: |
cd unit_test/burn_cell_sdc
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
2 changes: 1 addition & 1 deletion networks/aprox13/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ namespace RHS {

rhs_t data;

switch (rate) {
switch (rate) { // NOLINT(bugprone-switch-missing-default-case)

case He4_He4_He4_to_C12:
data.species_A = He4;
Expand Down
4 changes: 2 additions & 2 deletions networks/aprox19/actual_network.H
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace network
static_assert(spec >= 1 && spec <= NumSpec);

// Set the binding energy of the element
if constexpr (spec == H1) {
if constexpr (spec == H1) { // NOLINT(bugprone-branch-clone)
return 0.0_rt;
}
else if constexpr (spec == He3) {
Expand Down Expand Up @@ -239,7 +239,7 @@ namespace RHS {

rhs_t data;

switch (rate) {
switch (rate) { // NOLINT(bugprone-switch-missing-default-case)

case P_to_N:
// irpen and irnep in the original aprox19
Expand Down
2 changes: 1 addition & 1 deletion networks/rhs.H
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extern AMREX_GPU_MANAGED amrex::Array3D<amrex::Real, 1, Rates::NumRates, 1, 2, 1

// Calculate an integer factorial.
AMREX_GPU_HOST_DEVICE AMREX_INLINE
constexpr int factorial (int n)
constexpr int factorial (int n) // NOLINT(misc-no-recursion)
{
if (n <= 1) {
return 1;
Expand Down
6 changes: 4 additions & 2 deletions unit_test/burn_cell_sdc/burn_cell.H
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ void burn_cell_c()
case 35:
adv_species[n-1] = Adv_X35;
break;

default:
amrex::Error("invalid species");
}

}
Expand All @@ -184,7 +185,8 @@ void burn_cell_c()
case 3:
adv_aux[n-1] = Adv_Aux3;
break;

default:
amrex::Error("invalid aux component");
}

}
Expand Down

0 comments on commit d4312a6

Please sign in to comment.