forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (108 loc) · 4.02 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
113
114
name: Clang-tidy 16
on:
push:
branches:
- master
pull_request:
branches:
- master
paths:
- '**.c'
- '**.cpp'
- '**.h'
- '**.hpp'
- '**/CMakeLists.txt'
- '**/Makefile'
- 'build-scripts/clang-tidy.sh'
- 'build-scripts/clang-tidy-wrapper.sh'
- 'build-scripts/get_affected_files.py'
- '.github/workflows/clang-tidy.yml'
# 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-latest
# 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/clang-tidy.sh", "build-scripts/clang-tidy-wrapper.sh", "build-scripts/get_affected_files.py", ".github/workflows/clang-tidy.yml" ]'
build:
needs: skip-duplicates
if: ${{ needs.skip-duplicates.outputs.should_skip != 'true' }}
strategy:
fail-fast: false
matrix:
# To make the run finish in the run time limit, we split it up into two
# parts: the src directory and everything else
subset: [ 'src', 'other' ]
runs-on: ubuntu-22.04
env:
CMAKE: 1
CLANG: clang++-16
COMPILER: clang++-16
CATA_CLANG_TIDY: plugin
CATA_CLANG_TIDY_SUBSET: ${{ matrix.subset }}
TILES: 1
SOUND: 1
RELEASE: 1
steps:
- name: install LLVM 16
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main"
sudo apt update
sudo apt install llvm-16 llvm-16-dev llvm-16-tools clang-16 clang-tidy-16 clang-tools-16 \
libclang-16-dev libsdl2-dev libsdl2-ttf-dev libsdl2-image-dev libsdl2-mixer-dev \
libpulse-dev ccache gettext jq
- name: install dependencies
run: |
sudo apt install python3-pip libncursesw5-dev ninja-build cmake gettext
pip3 install --user lit
- name: ensure clang-tidy and FileCheck commands point to LLVM 16
run: |
mkdir ~/llvm-command-override
ln -s /usr/bin/clang-tidy-16 ~/llvm-command-override/clang-tidy
ln -s /usr/bin/FileCheck-16 ~/llvm-command-override/FileCheck
echo "$HOME/llvm-command-override" >> $GITHUB_PATH
- name: checkout repository
uses: actions/checkout@v3
- name: prepare
run: bash ./build-scripts/requirements.sh
- name: determine changed files
if: ${{ github.event_name == 'pull_request' }}
uses: actions/[email protected]
with:
script: |
var fs = require('fs');
const response = await github.paginate(github.rest.pulls.listFiles,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
}
);
const files = response.map(x => x.filename);
for (const path of files) {
console.log(path);
}
fs.writeFileSync("files_changed", files.join('\n'));
- uses: ammaraskar/gcc-problem-matcher@master
- name: run clang-tidy
run: bash ./build-scripts/clang-tidy.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