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

Add ccache to clang-tidy #916

Merged
merged 16 commits into from
Oct 6, 2023
Merged
136 changes: 86 additions & 50 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
build_type: [RelWithDebInfo, Debug]
build_type: [Release, Debug]
include:
- os: macos-latest
install_deps: brew install mpich ccache
Expand All @@ -41,10 +41,12 @@ jobs:
comp: gnu
procs: $(nproc)
ccache_cache: ~/.cache/ccache
- build_type: RelWithDebInfo
- build_type: Release
ctest_args: -LE no_ci
ccache_size: 150M
- build_type: Debug
ctest_args: -L unit
ccache_size: 500M
exclude:
- os: macos-latest
build_type: Debug
Expand All @@ -59,9 +61,9 @@ jobs:
run: |
echo "NPROCS=${{matrix.procs}}" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=5" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=1" >> $GITHUB_ENV
echo "CCACHE_LOGFILE=${{github.workspace}}/ccache.log.txt" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=${{matrix.ccache_size}}" >> $GITHUB_ENV
- name: Install Ccache
run: |
if [ "${RUNNER_OS}" != "macOS" ]; then
Expand Down Expand Up @@ -96,9 +98,8 @@ jobs:
- name: Ccache Report
run: |
ccache -s
if [ "${RUNNER_OS}" != "macOS" ]; then
du -hs ${HOME}/.cache/ccache
fi
ls ${{matrix.ccache_cache}}
du -hs ${{matrix.ccache_cache}}
- name: Report
working-directory: ${{runner.workspace}}/build-ci-${{matrix.build_type}}
run: |
Expand Down Expand Up @@ -132,9 +133,9 @@ jobs:
run: |
echo "NPROCS=$(nproc)" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=5" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=1" >> $GITHUB_ENV
echo "CCACHE_LOGFILE=${{github.workspace}}/ccache.log.txt" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=200M" >> $GITHUB_ENV
- name: Install Ccache
run: |
wget https://github.com/ccache/ccache/releases/download/v4.8/ccache-4.8-linux-x86_64.tar.xz
Expand Down Expand Up @@ -174,7 +175,8 @@ jobs:
- name: Ccache Report
run: |
ccache -s
du -hs ${HOME}/.cache/ccache
ls ~/.cache/ccache
du -hs ~/.cache/ccache
GPU-AMD:
name: GPU-HIP
needs: Formatting
Expand All @@ -188,9 +190,9 @@ jobs:
run: |
echo "NPROCS=$(nproc)" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=5" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=1" >> $GITHUB_ENV
echo "CCACHE_LOGFILE=${{github.workspace}}/ccache.log.txt" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=50M" >> $GITHUB_ENV
- name: Install Ccache
run: |
wget https://github.com/ccache/ccache/releases/download/v4.8/ccache-4.8-linux-x86_64.tar.xz
Expand Down Expand Up @@ -235,7 +237,8 @@ jobs:
- name: Ccache Report
run: |
ccache -s
du -hs ${HOME}/.cache/ccache
ls ~/.cache/ccache
du -hs ~/.cache/ccache
GPU-Intel:
name: GPU-SYCL
needs: Formatting
Expand All @@ -249,9 +252,9 @@ jobs:
run: |
echo "NPROCS=$(nproc)" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=5" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=1" >> $GITHUB_ENV
echo "CCACHE_LOGFILE=${{github.workspace}}/ccache.log.txt" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=50M" >> $GITHUB_ENV
echo "CCACHE_DEPEND=1" >> $GITHUB_ENV
- name: Install Ccache
run: |
Expand Down Expand Up @@ -292,54 +295,78 @@ jobs:
- name: Ccache Report
run: |
ccache -s
du -hs ${HOME}/.cache/ccache
Lint-cppcheck:
ls ~/.cache/ccache
du -hs ~/.cache/ccache
# Lint-cppcheck:
# needs: Formatting
# runs-on: macos-latest
# steps:
# - name: Clone
# uses: actions/checkout@v3
# with:
# submodules: true
# - name: Dependencies
# run: brew install cppcheck
# - name: Configure
# run: |
# echo "NPROCS=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
# cmake \
# -B ${{runner.workspace}}/build-cppcheck \
# -DAMR_WIND_ENABLE_MPI:BOOL=OFF \
# -DAMR_WIND_ENABLE_TESTS:BOOL=ON \
# -DAMR_WIND_TEST_WITH_FCOMPARE:BOOL=OFF \
# -DAMR_WIND_ENABLE_MASA:BOOL=OFF \
# -DAMR_WIND_ENABLE_CPPCHECK:BOOL=ON \
# ${{github.workspace}}
# - name: Check
# working-directory: ${{runner.workspace}}/build-cppcheck
# run: make cppcheck-ci
# - name: Full report
# working-directory: ${{runner.workspace}}/build-cppcheck
# run: cat cppcheck/cppcheck-full-report.txt
# - name: Short report
# working-directory: ${{runner.workspace}}/build-cppcheck
# run: |
# echo "::add-matcher::.github/problem-matchers/cppcheck.json"
# cat cppcheck-ci-report.txt
# exit $(tail -n 1 cppcheck-ci-report.txt | awk '{print $2}')
Lint-clang-tidy:
needs: Formatting
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
with:
submodules: true
- name: Dependencies
run: brew install cppcheck
- name: Configure
- name: Setup
run: |
echo "NPROCS=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
cmake \
-B ${{runner.workspace}}/build-cppcheck \
-DAMR_WIND_ENABLE_MPI:BOOL=OFF \
-DAMR_WIND_ENABLE_TESTS:BOOL=ON \
-DAMR_WIND_TEST_WITH_FCOMPARE:BOOL=OFF \
-DAMR_WIND_ENABLE_MASA:BOOL=OFF \
-DAMR_WIND_ENABLE_CPPCHECK:BOOL=ON \
${{github.workspace}}
- name: Check
working-directory: ${{runner.workspace}}/build-cppcheck
run: make cppcheck-ci
- name: Full report
working-directory: ${{runner.workspace}}/build-cppcheck
run: cat cppcheck/cppcheck-full-report.txt
- name: Short report
working-directory: ${{runner.workspace}}/build-cppcheck
echo "NPROCS=$(nproc)" >> $GITHUB_ENV
echo "CCACHE_COMPRESS=1" >> $GITHUB_ENV
echo "CCACHE_COMPRESSLEVEL=1" >> $GITHUB_ENV
echo "CCACHE_LOGFILE=${{github.workspace}}/ccache.log.txt" >> $GITHUB_ENV
echo "CCACHE_EXTRAFILES=${{github.workspace}}/.clang-tidy" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=50M" >> $GITHUB_ENV
echo "CTCACHE_DIR=~/.cache/ctcache" >> $GITHUB_ENV
- name: Install Ccache
run: |
echo "::add-matcher::.github/problem-matchers/cppcheck.json"
cat cppcheck-ci-report.txt
exit $(tail -n 1 cppcheck-ci-report.txt | awk '{print $2}')
Lint-clang-tidy:
needs: Formatting
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
wget https://github.com/ccache/ccache/releases/download/v4.8/ccache-4.8-linux-x86_64.tar.xz
sudo curl https://raw.githubusercontent.com/matus-chochlik/ctcache/7fd516e91c17779cbc6fc18bd119313d9532dd90/clang-tidy-cache -Lo /usr/bin/clang-tidy-cache
tar xvf ccache-4.8-linux-x86_64.tar.xz
sudo cp -f ccache-4.8-linux-x86_64/ccache /usr/local/bin/
sudo chmod +x /usr/bin/clang-tidy-cache
mkdir -p ~/.cache/ctcache
- name: Set Up Ccache
uses: actions/cache@v3
with:
submodules: true
path: ~/.cache
key: ccache-${{github.workflow}}-${{github.job}}-git-${{github.sha}}
restore-keys: |
ccache-${{github.workflow}}-${{github.job}}-git-
- name: Configure
run: |
echo "NPROCS=$(nproc)" >> $GITHUB_ENV
cmake \
-B ${{runner.workspace}}/build-clang-tidy \
-DCMAKE_BUILD_TYPE:STRING=Debug \
-DCMAKE_BUILD_TYPE:STRING=Release \
-DCMAKE_CXX_COMPILER:STRING=clang++ \
-DCMAKE_C_COMPILER:STRING=clang \
-DAMR_WIND_ENABLE_MPI:BOOL=OFF \
Expand All @@ -348,13 +375,22 @@ jobs:
-DAMR_WIND_ENABLE_MASA:BOOL=OFF \
-DAMR_WIND_ENABLE_ALL_WARNINGS:BOOL=ON \
-DAMR_WIND_ENABLE_CLANG_TIDY:BOOL=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache \
${{github.workspace}}
- name: Check
working-directory: ${{runner.workspace}}/build-clang-tidy
run: |
cmake --build . --parallel ${{env.NPROCS}} 2>&1 | tee -a clang-tidy-full-report.txt
cat clang-tidy-full-report.txt | grep "warning:" | grep -v "submods" | sort | uniq | \
awk 'BEGIN{i=0}{print $0}{i++}END{print "Warnings: "i}' > clang-tidy-ci-report.txt
- name: Ccache Report
run: |
ls ~/.cache
ls ~/.cache/ccache
du -hs ~/.cache/ccache
ls ~/.cache/ctcache
du -hs ~/.cache/ctcache
ccache -s
- name: Full report
working-directory: ${{runner.workspace}}/build-clang-tidy
run: cat clang-tidy-full-report.txt
Expand Down
6 changes: 6 additions & 0 deletions cmake/amr-wind-utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ macro(init_code_checks)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
if(CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
#find_program (CLANG_TIDY_CACHE_EXE NAMES "clang-tidy-cache")
#if(CLANG_TIDY_CACHE_EXE)
# message(STATUS "clang-tidy-cache found: ${CLANG_TIDY_CACHE_EXE}")
# set(CLANG_TIDY_EXE "${CLANG_TIDY_CACHE_PATH};${CLANG_TIDY_EXE}"
# CACHE STRING "A combined command to run clang-tidy with caching wrapper")
#endif()
else()
message(WARNING "clang-tidy not found.")
endif()
Expand Down
23 changes: 11 additions & 12 deletions unit_tests/utilities/test_free_surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,7 @@ class FreeSurfaceTest : public MeshTest
const amrex::Vector<amrex::Real> pl_end{{128.0, 128.0, 0.0}};
const amrex::Vector<amrex::Real> plnarrow_s{{63.0, 63.0, 0.0}};
const amrex::Vector<amrex::Real> plnarrow_e{{65.0, 65.0, 0.0}};
const int npts = 3;
static constexpr int npts = 3;
const amrex::Real fref_val = 0.5;
const std::string fname = "flag";
int m_nlev = 0;
Expand Down Expand Up @@ -467,18 +467,17 @@ TEST_F(FreeSurfaceTest, sloped)
tool.post_advance_work();

// Calculate expected output values
amrex::Vector<amrex::Real> out_vec;
out_vec.resize(static_cast<long>(npts) * static_cast<long>(npts), 0.0);
amrex::Vector<amrex::Real> out_vec(static_cast<long>(npts * npts), 0.0);
// Step in x, then y
out_vec[0] = water_level2 + slope * (-1.0 - 1.0);
out_vec[1] = water_level2 + slope * (+0.0 - 1.0);
out_vec[2] = water_level2 + slope * (+1.0 - 1.0);
out_vec[3] = water_level2 + slope * (-1.0 + 0.0);
out_vec[4] = water_level2 + slope * (+0.0 + 0.0);
out_vec[5] = water_level2 + slope * (+1.0 + 0.0);
out_vec[6] = water_level2 + slope * (-1.0 + 1.0);
out_vec[7] = water_level2 + slope * (+0.0 + 1.0);
out_vec[8] = water_level2 + slope * (+1.0 + 1.0);
out_vec[0] = (water_level2 + slope * (-1.0 - 1.0));
out_vec[1] = (water_level2 + slope * (+0.0 - 1.0));
out_vec[2] = (water_level2 + slope * (+1.0 - 1.0));
out_vec[3] = (water_level2 + slope * (-1.0 + 0.0));
out_vec[4] = (water_level2 + slope * (+0.0 + 0.0));
out_vec[5] = (water_level2 + slope * (+1.0 + 0.0));
out_vec[6] = (water_level2 + slope * (-1.0 + 1.0));
out_vec[7] = (water_level2 + slope * (+0.0 + 1.0));
out_vec[8] = (water_level2 + slope * (+1.0 + 1.0));
// Check output value
int nout = tool.check_output_vec("~", out_vec);
ASSERT_EQ(nout, npts * npts);
Expand Down
Loading