Skip to content

Commit

Permalink
Update to clang-tidy 17, codespell and CI (#29)
Browse files Browse the repository at this point in the history
  • Loading branch information
marchdf authored Apr 26, 2024
1 parent 81cf8fa commit d39d2d6
Show file tree
Hide file tree
Showing 15 changed files with 164 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ Checks: 'bugprone-*,
modernize-*,
-modernize-use-nodiscard,
performance-*,
-performance-avoid-endl,
-performance-inefficient-string-concatenation,
portability-*,
readability-*,
-readability-magic-numbers,
Expand All @@ -19,6 +21,7 @@ Checks: 'bugprone-*,
-readability-function-cognitive-complexity'
WarningsAsErrors: ''
HeaderFilterRegex: '.*'
HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx']
AnalyzeTemporaryDtors: false
FormatStyle: none
User: user
Expand Down
3 changes: 2 additions & 1 deletion .codespell-ignore-words
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
inout
nd
nd
alph
2 changes: 1 addition & 1 deletion .codespellrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[codespell]
skip = .git,*.ipynb,*.bib,*.ps,*.patch,spack-build-*,*/build,,__pycache__,.ccls,.ccls-cache,*.pdf,*.f90,*.f,*.bak
skip = .git,*.ipynb,*.bib,*.ps,*.patch,spack-build-*,*/build,,__pycache__,.ccls,.ccls-cache,*.pdf,*.f90,*.f,*.bak,driver
ignore-words = .codespell-ignore-words
29 changes: 28 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: TIOGA CI
name: TIOGA-CI

on:
push:
Expand Down Expand Up @@ -118,6 +118,18 @@ jobs:
echo "CCACHE_EXTRAFILES=${{github.workspace}}/.clang-tidy" >> $GITHUB_ENV
echo "CCACHE_MAXSIZE=50M" >> $GITHUB_ENV
echo "CTCACHE_DIR=~/.cache/ctcache" >> $GITHUB_ENV
echo "CLANG_TIDY_VERSION=17" >> $GITHUB_ENV
- name: Install clang-tidy
run: |
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}-${CLANG_TIDY_VERSION} main"
sudo apt-get update
sudo apt-get install -y --no-install-recommends clang-tidy-${CLANG_TIDY_VERSION} libomp-${CLANG_TIDY_VERSION}-dev
- 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 @@ -146,6 +158,7 @@ jobs:
-DCMAKE_C_COMPILER:STRING=mpicc \
-DTIOGA_ENABLE_CLANG_TIDY:BOOL=ON \
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache \
-DCLANG_TIDY_EXEC_NAME:STRING=clang-tidy-${CLANG_TIDY_VERSION} \
${{github.workspace}}
- name: Check
working-directory: ${{runner.workspace}}/build-clang-tidy
Expand Down Expand Up @@ -237,3 +250,17 @@ jobs:
pip install codespell
- name: Run codespell
run: codespell
Save-PR-Number:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
37 changes: 37 additions & 0 deletions .github/workflows/cleanup-cache-postpr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: CleanUpCachePostPR

on:
workflow_run:
workflows: [PostPR]
types:
- completed

jobs:
CleanUpCcacheCachePostPR:
name: Clean Up Ccahe Cache Post PR
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Clean up ccahe
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
gh run download ${{ github.event.workflow_run.id }} -n pr_number
pr_number=`cat pr_number.txt`
BRANCH=refs/pull/${pr_number}/merge
# Setting this to not fail the workflow while deleting cache keys.
set +e
keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH | cut -f 1)
for k in $keys
do
gh actions-cache delete $k -R $REPO -B $BRANCH --confirm
done
60 changes: 60 additions & 0 deletions .github/workflows/cleanup-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: CleanUpCache

on:
workflow_run:
workflows: [TIOGA-CI]
types:
- completed

jobs:
CleanUpCcacheCache:
name: Clean Up Ccache Cache for ${{ github.event.workflow_run.name }}
runs-on: ubuntu-latest
permissions:
actions: write
contents: read
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Clean up ccahe
run: |
gh extension install actions/gh-actions-cache
REPO=${{ github.repository }}
# push or pull_request or schedule or ...
EVENT=${{ github.event.workflow_run.event }}
# Triggering workflow run name (e.g., LinuxClang)
WORKFLOW_NAME=${{ github.event.workflow_run.name }}
if [[ $EVENT == "pull_request" ]]; then
gh run download ${{ github.event.workflow_run.id }} -n pr_number
pr_number=`cat pr_number.txt`
BRANCH=refs/pull/${pr_number}/merge
else
BRANCH=refs/heads/${{ github.event.workflow_run.head_branch }}
fi
# Setting this to not fail the workflow while deleting cache keys.
set +e
# In our cache keys, substring after `-git-` is git hash, substring
# before that is a unique id for jobs (e.g., `ccache-LinuxClang-configure-2d`).
# The goal is to keep the last used key of each job and delete all others.
# something like ccache-LinuxClang-
keyprefix=ccache-${WORKFLOW_NAME}-
cached_jobs=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key $keyprefix | awk -F '-git-' '{print $1}' | sort | uniq)
# cached_jobs is something like "ccache-LinuxClang-configure-1d ccache-LinuxClang-configure-2d".
for j in $cached_jobs
do
old_keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key ${j}-git- --sort last-used | cut -f 1 | tail -n +2)
for k in $old_keys
do
gh actions-cache delete $k -R $REPO -B $BRANCH --confirm
done
done
20 changes: 20 additions & 0 deletions .github/workflows/post-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: PostPR
on:
pull_request:
types:
- closed

jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Save PR number
env:
PR_NUMBER: ${{ github.event.number }}
run: |
echo $PR_NUMBER > pr_number.txt
- uses: actions/upload-artifact@v4
with:
name: pr_number
path: pr_number.txt
retention-days: 1
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@ if (BUILD_GRIDGEN_EXE)
endif()

if(TIOGA_ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
set(CLANG_TIDY_EXEC_NAME "clang-tidy" CACHE STRING "Name of the clang-tidy executable")
find_program(CLANG_TIDY_EXE NAMES "${CLANG_TIDY_EXEC_NAME}")
if(CLANG_TIDY_EXE)
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
message(STATUS "${CLANG_TIDY_EXEC_NAME} 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.")
message(WARNING "${CLANG_TIDY_EXEC_NAME} not found.")
endif()
endif()
if(CLANG_TIDY_EXE)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TIOGA - Topology Independent Overset Grid Assembler

[![TIOGA CI](https://github.com/Exawind/tioga/actions/workflows/ci.yml/badge.svg)](https://github.com/Exawind/tioga/actions/workflows/ci.yml)
[![TIOGA-CI](https://github.com/Exawind/tioga/actions/workflows/ci.yml/badge.svg)](https://github.com/Exawind/tioga/actions/workflows/ci.yml)

TIOGA is a library for overset grid assembly on parallel distributed systems
Copyright (C) 2015 Jay Sitaraman
Expand Down
2 changes: 1 addition & 1 deletion src/CartBlock.C
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void CartBlock::getInterpolatedData(int *nints,int *nreals,int **intData,
for(i=0;i<(*nreals);i++) tmpreal[i]=(*realData)[i];
//
TIOGA_FREE((*intData));
TIOGA_FREE((*realData)); // didnt free this before ??
TIOGA_FREE((*realData)); // didn't free this before ??
//
}
(*nints)+=interpCount;
Expand Down
2 changes: 1 addition & 1 deletion src/CartGrid.C
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void CartGrid::registerData(int nfin,int *idata,double *rdata,int ngridsin)

//
// Bare bone preprocessor now
// willl add more support data structures
// will add more support data structures
// to promote efficient search once the concept
// works
//
Expand Down
2 changes: 1 addition & 1 deletion src/cartOps.C
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ void MeshBlock::getInterpolatedSolutionAMR(int *nints,int *nreals,int **intData,
for(i=0;i<(*nreals);i++) tmpreal[i]=(*realData)[i];
//
TIOGA_FREE((*intData));
TIOGA_FREE((*realData)); // didnt free this before ??
TIOGA_FREE((*realData)); // didn't free this before ??
//
}
(*nints)+=interpCount;
Expand Down
2 changes: 1 addition & 1 deletion src/holeMap.C
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace TIOGA;
/**
* Create hole maps for all grids
* this routine is not efficient
* since it does mutiple global reduce ops
* since it does multiple global reduce ops
* have to change it at a later date when
* there is more time to develop code
*/
Expand Down
6 changes: 3 additions & 3 deletions src/tioga.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#define TIOGA_HAS_NGP_IFACE 1

/**
* Topology Indpendent Overset Grid Assembler (TIOGA)
* Topology Independent Overset Grid Assembler (TIOGA)
* Base class and dependencies
* The methods of this class are invoked from tiogaInterface.C
*
Expand Down Expand Up @@ -100,7 +100,7 @@ class tioga {
//! Intersect block unique ID to index lookup mapping
std::map<int, int> intBoxMap;

//! Parallel comms to obblist indicies
//! Parallel comms to obblist indices
std::vector<int> ibsPerProc;
std::vector<std::vector<int>> ibProcMap;
//! q-variables registered
Expand All @@ -111,7 +111,7 @@ class tioga {
int ihighGlobal;
int iamrGlobal;
int mexclude, nfringe;
/** basic constuctor */
/** basic constructor */
tioga()
/*
: mblocks(0),
Expand Down
2 changes: 1 addition & 1 deletion src/tiogaInterface.C
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ extern "C" {
}
else
{
printf("Data udpate between high-order near-body and AMR cartesian Not implemented yet\n");
printf("Data update between high-order near-body and AMR cartesian Not implemented yet\n");
}
}
}
Expand Down

0 comments on commit d39d2d6

Please sign in to comment.