-
Notifications
You must be signed in to change notification settings - Fork 2
131 lines (122 loc) · 3.99 KB
/
static_checks.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: Static checks
run-name: Static checks
on:
pull_request:
types: [opened, synchronize]
jobs:
build-compilation-db:
name: Build with IWYU
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true # Recursively clone submodules
- name: Add repos
run: |
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main'
wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash
wget https://apt.llvm.org/llvm-snapshot.gpg.key
sudo apt-key add llvm-snapshot.gpg.key
- name: Install dependencies
run: |
sudo apt update
sudo apt install \
ninja-build \
iwyu \
clang-16 \
libomp-16-dev \
libopenmpi-dev \
openmpi-bin \
openfoam2406-dev
- name: Create Compilation Database
run: |
source /usr/lib/openfoam/openfoam2406/etc/bashrc || true
cmake --preset ninja-cpuonly-all \
-DNEOFOAM_DEVEL_TOOLS=OFF \
-DCMAKE_CXX_COMPILER=clang++-16 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DNEOFOAM_ENABLE_MPI_WITH_THREAD_SUPPORT=OFF \
-DNEOFOAM_ENABLE_IWYU=ON
cmake --build --preset ninja-cpuonly-all
- uses: actions/upload-artifact@v4
with:
name: build-artifact
path: build
clang-tidy-check:
name: Clang-tidy Check
runs-on: ubuntu-latest
needs: [build-compilation-db]
steps:
- uses: actions/checkout@v4
with:
submodules: true # Recursively clone submodules
- name: Add repos
run: |
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main'
wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash
wget https://apt.llvm.org/llvm-snapshot.gpg.key
sudo apt-key add llvm-snapshot.gpg.key
- name: Install dependencies
run: |
sudo apt update
sudo apt install \
ninja-build \
iwyu \
clang-16 \
libomp-16-dev \
libopenmpi-dev \
openmpi-bin \
openfoam2406-dev
- uses: actions/download-artifact@v4
with:
name: build-artifact
path: build
- name: Run clang-tidy
run: |
# Create list of .cpp files belonging to this repository
git ls-files | grep -E "\.(cpp)" > pattern
# Create list of .cpp files that are in this repository and part of the
# compilation database
# also filters out " at the begin and end of the filename
jq ".[] | .file" build/ReleaseAll/compile_commands.json \
| sed 's/^"\(.*\)"$/\1/' \
| grep -F -f pattern - > files
# run clang-tidy on all specified files
clang-tidy-16 --fix --extra-arg=-w -p build/ReleaseAll $(cat files)
- name: Check for fixes
run: |
if [[ $(git ls-files -m | wc -l) -eq 0 ]]; then
exit 0
fi
echo "There are fixes available from clang-tidy."
echo "Please use your local clang-tidy or apply the following patch:"
git diff -p
exit 1
pre-commit-run:
name: Pre-commit run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true # Recursively clone submodules
- name: Install dependencies
run: |
sudo apt update
sudo apt install \
pre-commit
pip install identify --upgrade
pre-commit install
- name: Run pre-commit on all files
run: pre-commit run --all --color always --verbose
- name: check for todo fixme note
run: |
NTODOS="$(grep -r 'TODO DONT MERGE' --exclude-dir=.github | wc -l)"
echo "Found $NTODOS TODO DONT MERGE notes"
! grep -q -r "TODO DONT MERGE" --exclude-dir=.github
changelog:
name: Changelog check
runs-on: ubuntu-latest
steps:
- uses: dangoslen/changelog-enforcer@v3
with:
changeLogPath: CHANGELOG.md