Skip to content

Commit d39d2d6

Browse files
authored
Update to clang-tidy 17, codespell and CI (#29)
1 parent 81cf8fa commit d39d2d6

File tree

15 files changed

+164
-15
lines changed

15 files changed

+164
-15
lines changed

.clang-tidy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Checks: 'bugprone-*,
99
modernize-*,
1010
-modernize-use-nodiscard,
1111
performance-*,
12+
-performance-avoid-endl,
13+
-performance-inefficient-string-concatenation,
1214
portability-*,
1315
readability-*,
1416
-readability-magic-numbers,
@@ -19,6 +21,7 @@ Checks: 'bugprone-*,
1921
-readability-function-cognitive-complexity'
2022
WarningsAsErrors: ''
2123
HeaderFilterRegex: '.*'
24+
HeaderFileExtensions: ['', "H", 'h', 'hh', 'hpp', 'hxx']
2225
AnalyzeTemporaryDtors: false
2326
FormatStyle: none
2427
User: user

.codespell-ignore-words

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
inout
2-
nd
2+
nd
3+
alph

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[codespell]
2-
skip = .git,*.ipynb,*.bib,*.ps,*.patch,spack-build-*,*/build,,__pycache__,.ccls,.ccls-cache,*.pdf,*.f90,*.f,*.bak
2+
skip = .git,*.ipynb,*.bib,*.ps,*.patch,spack-build-*,*/build,,__pycache__,.ccls,.ccls-cache,*.pdf,*.f90,*.f,*.bak,driver
33
ignore-words = .codespell-ignore-words

.github/workflows/ci.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: TIOGA CI
1+
name: TIOGA-CI
22

33
on:
44
push:
@@ -118,6 +118,18 @@ jobs:
118118
echo "CCACHE_EXTRAFILES=${{github.workspace}}/.clang-tidy" >> $GITHUB_ENV
119119
echo "CCACHE_MAXSIZE=50M" >> $GITHUB_ENV
120120
echo "CTCACHE_DIR=~/.cache/ctcache" >> $GITHUB_ENV
121+
echo "CLANG_TIDY_VERSION=17" >> $GITHUB_ENV
122+
- name: Install clang-tidy
123+
run: |
124+
echo 'Acquire::Retries "3";' | sudo tee /etc/apt/apt.conf.d/80-retries
125+
if [[ ! -f /etc/apt/trusted.gpg.d/apt.llvm.org.asc ]]; then
126+
wget -qO- https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc
127+
fi
128+
source /etc/os-release # set UBUNTU_CODENAME
129+
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME} main"
130+
sudo add-apt-repository "deb http://apt.llvm.org/${UBUNTU_CODENAME}/ llvm-toolchain-${UBUNTU_CODENAME}-${CLANG_TIDY_VERSION} main"
131+
sudo apt-get update
132+
sudo apt-get install -y --no-install-recommends clang-tidy-${CLANG_TIDY_VERSION} libomp-${CLANG_TIDY_VERSION}-dev
121133
- name: Install Ccache
122134
run: |
123135
wget https://github.com/ccache/ccache/releases/download/v4.8/ccache-4.8-linux-x86_64.tar.xz
@@ -146,6 +158,7 @@ jobs:
146158
-DCMAKE_C_COMPILER:STRING=mpicc \
147159
-DTIOGA_ENABLE_CLANG_TIDY:BOOL=ON \
148160
-DCMAKE_CXX_COMPILER_LAUNCHER:STRING=ccache \
161+
-DCLANG_TIDY_EXEC_NAME:STRING=clang-tidy-${CLANG_TIDY_VERSION} \
149162
${{github.workspace}}
150163
- name: Check
151164
working-directory: ${{runner.workspace}}/build-clang-tidy
@@ -237,3 +250,17 @@ jobs:
237250
pip install codespell
238251
- name: Run codespell
239252
run: codespell
253+
Save-PR-Number:
254+
if: github.event_name == 'pull_request'
255+
runs-on: ubuntu-latest
256+
steps:
257+
- name: Save PR number
258+
env:
259+
PR_NUMBER: ${{ github.event.number }}
260+
run: |
261+
echo $PR_NUMBER > pr_number.txt
262+
- uses: actions/upload-artifact@v4
263+
with:
264+
name: pr_number
265+
path: pr_number.txt
266+
retention-days: 1
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: CleanUpCachePostPR
2+
3+
on:
4+
workflow_run:
5+
workflows: [PostPR]
6+
types:
7+
- completed
8+
9+
jobs:
10+
CleanUpCcacheCachePostPR:
11+
name: Clean Up Ccahe Cache Post PR
12+
runs-on: ubuntu-latest
13+
permissions:
14+
actions: write
15+
contents: read
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Clean up ccahe
21+
run: |
22+
gh extension install actions/gh-actions-cache
23+
24+
REPO=${{ github.repository }}
25+
26+
gh run download ${{ github.event.workflow_run.id }} -n pr_number
27+
pr_number=`cat pr_number.txt`
28+
BRANCH=refs/pull/${pr_number}/merge
29+
30+
# Setting this to not fail the workflow while deleting cache keys.
31+
set +e
32+
33+
keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH | cut -f 1)
34+
for k in $keys
35+
do
36+
gh actions-cache delete $k -R $REPO -B $BRANCH --confirm
37+
done
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: CleanUpCache
2+
3+
on:
4+
workflow_run:
5+
workflows: [TIOGA-CI]
6+
types:
7+
- completed
8+
9+
jobs:
10+
CleanUpCcacheCache:
11+
name: Clean Up Ccache Cache for ${{ github.event.workflow_run.name }}
12+
runs-on: ubuntu-latest
13+
permissions:
14+
actions: write
15+
contents: read
16+
env:
17+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Clean up ccahe
21+
run: |
22+
gh extension install actions/gh-actions-cache
23+
24+
REPO=${{ github.repository }}
25+
26+
# push or pull_request or schedule or ...
27+
EVENT=${{ github.event.workflow_run.event }}
28+
29+
# Triggering workflow run name (e.g., LinuxClang)
30+
WORKFLOW_NAME=${{ github.event.workflow_run.name }}
31+
32+
if [[ $EVENT == "pull_request" ]]; then
33+
gh run download ${{ github.event.workflow_run.id }} -n pr_number
34+
pr_number=`cat pr_number.txt`
35+
BRANCH=refs/pull/${pr_number}/merge
36+
else
37+
BRANCH=refs/heads/${{ github.event.workflow_run.head_branch }}
38+
fi
39+
40+
# Setting this to not fail the workflow while deleting cache keys.
41+
set +e
42+
43+
# In our cache keys, substring after `-git-` is git hash, substring
44+
# before that is a unique id for jobs (e.g., `ccache-LinuxClang-configure-2d`).
45+
# The goal is to keep the last used key of each job and delete all others.
46+
47+
# something like ccache-LinuxClang-
48+
keyprefix=ccache-${WORKFLOW_NAME}-
49+
50+
cached_jobs=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key $keyprefix | awk -F '-git-' '{print $1}' | sort | uniq)
51+
52+
# cached_jobs is something like "ccache-LinuxClang-configure-1d ccache-LinuxClang-configure-2d".
53+
for j in $cached_jobs
54+
do
55+
old_keys=$(gh actions-cache list -L 100 -R $REPO -B $BRANCH --key ${j}-git- --sort last-used | cut -f 1 | tail -n +2)
56+
for k in $old_keys
57+
do
58+
gh actions-cache delete $k -R $REPO -B $BRANCH --confirm
59+
done
60+
done

.github/workflows/post-pr.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: PostPR
2+
on:
3+
pull_request:
4+
types:
5+
- closed
6+
7+
jobs:
8+
cleanup:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Save PR number
12+
env:
13+
PR_NUMBER: ${{ github.event.number }}
14+
run: |
15+
echo $PR_NUMBER > pr_number.txt
16+
- uses: actions/upload-artifact@v4
17+
with:
18+
name: pr_number
19+
path: pr_number.txt
20+
retention-days: 1

CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,18 @@ if (BUILD_GRIDGEN_EXE)
6666
endif()
6767

6868
if(TIOGA_ENABLE_CLANG_TIDY)
69-
find_program(CLANG_TIDY_EXE NAMES "clang-tidy")
69+
set(CLANG_TIDY_EXEC_NAME "clang-tidy" CACHE STRING "Name of the clang-tidy executable")
70+
find_program(CLANG_TIDY_EXE NAMES "${CLANG_TIDY_EXEC_NAME}")
7071
if(CLANG_TIDY_EXE)
71-
message(STATUS "clang-tidy found: ${CLANG_TIDY_EXE}")
72+
message(STATUS "${CLANG_TIDY_EXEC_NAME} found: ${CLANG_TIDY_EXE}")
7273
#find_program (CLANG_TIDY_CACHE_EXE NAMES "clang-tidy-cache")
7374
#if(CLANG_TIDY_CACHE_EXE)
7475
# message(STATUS "clang-tidy-cache found: ${CLANG_TIDY_CACHE_EXE}")
7576
# set(CLANG_TIDY_EXE "${CLANG_TIDY_CACHE_PATH};${CLANG_TIDY_EXE}"
7677
# CACHE STRING "A combined command to run clang-tidy with caching wrapper")
7778
#endif()
7879
else()
79-
message(WARNING "clang-tidy not found.")
80+
message(WARNING "${CLANG_TIDY_EXEC_NAME} not found.")
8081
endif()
8182
endif()
8283
if(CLANG_TIDY_EXE)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# TIOGA - Topology Independent Overset Grid Assembler
22

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

55
TIOGA is a library for overset grid assembly on parallel distributed systems
66
Copyright (C) 2015 Jay Sitaraman

src/CartBlock.C

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void CartBlock::getInterpolatedData(int *nints,int *nreals,int **intData,
7373
for(i=0;i<(*nreals);i++) tmpreal[i]=(*realData)[i];
7474
//
7575
TIOGA_FREE((*intData));
76-
TIOGA_FREE((*realData)); // didnt free this before ??
76+
TIOGA_FREE((*realData)); // didn't free this before ??
7777
//
7878
}
7979
(*nints)+=interpCount;

0 commit comments

Comments
 (0)