forked from cataclysmbnteam/Cataclysm-BN
-
Notifications
You must be signed in to change notification settings - Fork 0
112 lines (95 loc) · 4.18 KB
/
clang-tidy.yml
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
name: Clang-tidy (tiles)
on:
# push:
# branches: [main]
# paths: [ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", "build-scripts/**","tools/clang-tidy-plugin/**", ".github/workflows/clang-tidy.yml", "**/.clang-tidy" ]
pull_request:
branches: [main]
paths: [ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", "build-scripts/**", "tools/clang-tidy-plugin/**", ".github/workflows/clang-tidy.yml", "**/.clang-tidy" ]
# We only care about the latest revision of a PR, so cancel all previous instances.
concurrency:
group: clang-tidy-build-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true
jobs:
skip-duplicates:
continue-on-error: true
runs-on: ubuntu-24.04
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
with:
cancel_others: "true"
paths: '[ "**.cpp", "**.h", "**.c", "**/CMakeLists.txt", "**/Makefile", "**.hpp", "**.cmake", "build-scripts/**", "tools/clang-tidy-plugin/**", ".github/workflows/clang-tidy.yml", "**/.clang-tidy" ]'
build:
needs: skip-duplicates
if: ${{ needs.skip-duplicates.outputs.should_skip != 'true' }}
runs-on: ubuntu-24.04
env:
CMAKE: 1
CLANG: /usr/bin/clang++-18
COMPILER: /usr/bin/clang++-18
TILES: 1
SOUND: 1
BUILD_PATH: "build"
AFFECTED_FILES: "affected_files.txt"
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install \
cmake gettext ninja-build mold ccache jq \
clang-18 libclang-18-dev llvm-18 llvm-18-dev clang-tidy-18 \
libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev libpulse-dev libflac-dev
- name: ensure clang 18 is installed
run: |
if [ -z "$(command -v clang++-18)" ]; then
echo "clang 18 not found"
exit 1
fi
ls -al /usr/lib/llvm-18/lib
if [ ! -d /usr/lib/llvm-18/lib ]; then
echo "llvm-18 not found"
exit 1
fi
sudo update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-18 100
sudo update-alternatives --install /usr/bin/FileCheck FileCheck /usr/bin/FileCheck-18 100
sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-18 100
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
install_ccache: false
update_packager_index: false
- name: add problem matcher
run: |
# Enable GitHub actions problem matchers
# (See https://github.com/actions/toolkit/blob/master/docs/problem-matchers.md)
echo "::add-matcher::build-scripts/problem-matchers/catch2.json"
echo "::add-matcher::build-scripts/problem-matchers/debugmsg.json"
- uses: ammaraskar/gcc-problem-matcher@master
- uses: denoland/setup-deno@v2
- name: build clang-tidy plugin
run: |
pip install --break-system-packages lit
bash ./build-scripts/build-clang-tidy-plugin.sh
# - name: test clang-tidy plugin
# run: |
# lit -v $BUILD_PATH/tools/clang-tidy-plugin/test
# clang-tidy --version
- name: gather affected files
run: deno task affected-files ${{ github.event.pull_request.number }} --output "$AFFECTED_FILES"
- name: run clang-tidy
run: bash ./build-scripts/run-clang-tidy-plugin.sh
- name: show most time consuming checks
if: always()
run: | # the folder may not exist if there is no file to analyze
if [ -d clang-tidy-trace ]
then
jq -n 'reduce(inputs.profile | to_entries[]) as {$key,$value} ({}; .[$key] += $value) | with_entries(select(.key|contains(".wall"))) | to_entries | sort_by(.value) | reverse | .[0:10] | from_entries' clang-tidy-trace/*.json
else
echo "clang-tidy-trace folder not found."
fi