-
Notifications
You must be signed in to change notification settings - Fork 12
131 lines (121 loc) · 3.77 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
# SPDX-FileCopyrightText: 2024 OGL authors
#
# SPDX-License-Identifier: GPL-3.0-or-later
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
- name: Add clang repo
run: |
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main'
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
- name: Create Compilation Database
run: |
cmake --preset ninja-cpuonly-release \
-DCMAKE_CXX_COMPILER=clang++-16 \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
cmake --build --preset ninja-cpuonly-release
- 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
- name: Add clang repo
run: |
sudo add-apt-repository 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main'
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 \
clang-tidy-16 \
libomp-16-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
formatting-check:
name: Formatting check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/[email protected]
with:
clang-format-version: '17'
check-path: '.'
fallback-style: 'Mozilla' # optional
- 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
typos-check:
name: Spell check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for typos
uses: crate-ci/typos@master
check-spdx-headers:
name: License header check
runs-on: ubuntu-latest
steps:
- name: Checkout to repository
uses: actions/checkout@v4
- name: install reuse linter
run: |
pip3 install reuse
- name: Execute reuse linter
run: |
reuse lint
changelog:
name: Changelog check
runs-on: ubuntu-latest
steps:
- uses: dangoslen/changelog-enforcer@v3
with:
changeLogPath: CHANGELOG.md