-
Notifications
You must be signed in to change notification settings - Fork 0
130 lines (125 loc) · 4.42 KB
/
Copy pathclang-tidy.yaml
File metadata and controls
130 lines (125 loc) · 4.42 KB
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
name: clang-tidy
on:
pull_request:
branches:
- main
paths:
- '**/*.c'
- '**/*.cc'
- '**/*.cpp'
- '**/*.h'
- '**/*.hh'
- 'CMakeLists.txt'
- '**/CMakeLists.txt'
- 'cmake/**'
- 'configure.py'
- '.gitmodules'
- '.github/workflows/clang-tidy.yaml'
- '.github/scripts/clang-tidy-*.sh'
- 'flake.nix'
- 'flake.lock'
workflow_dispatch:
env:
BUILD_TYPE: RelWithDebInfo
BUILD_DIR: build
CLANG_TIDY_CHECKS: '-*,bugprone-use-after-move'
permissions:
contents: read
# cancel the in-progress run upon a repush
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
clang-tidy:
name: Run clang-tidy
runs-on: depot-ubuntu-24.04-8
env:
CCACHE_DIR: ${{ github.workspace }}/.ccache
CCACHE_MAXSIZE: 5G
CCACHE_BASEDIR: ${{ github.workspace }}
CCACHE_NOHASHDIR: true
NODISTCC: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
submodules: true
- uses: DeterminateSystems/nix-installer-action@v3
- uses: DeterminateSystems/magic-nix-cache-action@main
- name: Restore ccache
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ccache-${{ runner.os }}-clang-tidy-${{ env.BUILD_TYPE }}-${{ hashFiles('flake.nix', 'flake.lock', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-${{ github.run_id }}
restore-keys: |
ccache-${{ runner.os }}-clang-tidy-${{ env.BUILD_TYPE }}-${{ hashFiles('flake.nix', 'flake.lock', 'configure.py', 'CMakeLists.txt', 'cmake/**', '.gitmodules') }}-
ccache-${{ runner.os }}-clang-tidy-${{ env.BUILD_TYPE }}-
ccache-${{ runner.os }}-clang-tidy-
- name: Configure ccache
run: |
mkdir -p "$CCACHE_DIR"
nix develop .#cpp -c ccache --max-size="$CCACHE_MAXSIZE"
nix develop .#cpp -c ccache --zero-stats
- name: Generate the building system
env:
GITHUB_BASE_REF: ${{ github.base_ref || 'main' }}
run: |
cmake_args=(
-DCMAKE_BUILD_TYPE=$BUILD_TYPE
-DCMAKE_C_COMPILER=clang
-DCMAKE_C_COMPILER_LAUNCHER=ccache
-DCMAKE_CXX_FLAGS="-Wno-error=deprecated-builtins"
-DScylla_USE_LINKER=ld.lld
-DScylla_SEASTAR_UNUSED_RESULT_ERROR=OFF
-DCMAKE_CXX_COMPILER=clang++
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
-G Ninja
-B "$BUILD_DIR"
-S .
)
if [ "$GITHUB_EVENT_NAME" = "workflow_dispatch" ]; then
cmake_args+=(
-DCMAKE_CXX_CLANG_TIDY="bash;$GITHUB_WORKSPACE/.github/scripts/clang-tidy-nix.sh;--checks=$CLANG_TIDY_CHECKS"
)
fi
nix develop .#cpp -c cmake "${cmake_args[@]}"
- name: Build generated headers
if: github.event_name == 'pull_request'
run: |
nix develop .#cpp -c bash -c '
swagger_targets=""
for f in api/api-doc/*.json; do
if test "${f#*.}" = json; then
name=$(basename "$f" .json)
if test $name != swagger20_header; then
swagger_targets+=" scylla_swagger_gen_$name"
fi
fi
done
cmake \
--build build \
--target seastar_http_request_parser \
--target idl-sources \
--target $swagger_targets
'
# see https://github.com/actions/toolkit/blob/main/docs/problem-matchers.md
- run: |
echo "::add-matcher::.github/clang-matcher.json"
- name: Run clang-tidy on changed sources
if: github.event_name == 'pull_request'
env:
GITHUB_BASE_REF: ${{ github.base_ref || 'main' }}
run: |
nix develop .#cpp -c .github/scripts/clang-tidy-changed.sh
- name: Build with clang-tidy enabled
if: github.event_name == 'workflow_dispatch'
run: |
nix develop .#cpp -c cmake --build $BUILD_DIR --target scylla
- run: |
echo "::remove-matcher owner=clang::"
if: always()
- name: Show ccache stats
if: ${{ always() }}
run: |
nix develop .#cpp -c ccache --show-stats