forked from CleverRaven/Cataclysm-DDA
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (138 loc) · 4.87 KB
/
iwyu.yml
File metadata and controls
142 lines (138 loc) · 4.87 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
131
132
133
134
135
136
137
138
139
140
141
142
name: IWYU (include-what-you-use)
on:
push:
branches:
- master
pull_request:
branches:
- master
types: [opened, reopened, synchronize, ready_for_review]
# We only care about the latest revision of a PR, so cancel all previous instances.
concurrency:
group: iwyu-${{ github.event.pull_request.number || github.ref_name }}
cancel-in-progress: true
jobs:
check-changes:
runs-on: ubuntu-latest
outputs:
should_run: ${{ github.event_name == 'push' || steps.changed-files.outputs.result == 'true' }}
steps:
- name: check for relevant file changes
id: changed-files
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
with:
script: |
const response = await github.paginate(github.rest.pulls.listFiles,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
}
);
const dominated_by = [
/^src\//,
/^tests\//,
/^tools\/iwyu\//,
/CMakeLists\.txt$/,
/^\.github\/workflows\/iwyu\.yml$/,
];
const dominated = response.some(f => dominated_by.some(r => r.test(f.filename)));
return dominated;
iwyu:
needs: check-changes
if: ${{ needs.check-changes.outputs.should_run == 'true' }}
runs-on: ubuntu-24.04
env:
COMPILER: clang++-19
steps:
- name: install LLVM 19
run: |
sudo apt install llvm-19-dev clang-19 libclang-19-dev
sudo apt install cmake
- name: checkout IWYU repository
id: iwyu-checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: include-what-you-use/include-what-you-use
path: include-what-you-use-src
ref: clang_19
persist-credentials: false
- name: checkout own repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
path: Cataclysm-DDA
persist-credentials: false
- name: cache IWYU build
id: iwyu-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: iwyu-build
key: iwyu-clang19-ubuntu2404-${{ steps.iwyu-checkout.outputs.commit }}
- name: build IWYU
if: steps.iwyu-cache.outputs.cache-hit != 'true'
run: |
cmake -B iwyu-build -DCMAKE_PREFIX_PATH=/usr/lib/llvm-19 -DCMAKE_BUILD_TYPE=Release include-what-you-use-src
cmake --build iwyu-build --parallel 4
- name: set IWYU paths
id: build-iwyu
run: |
echo "IWYU_SRC_DIR=${PWD}/include-what-you-use-src">> "$GITHUB_OUTPUT"
echo "IWYU_BIN_DIR=${PWD}/iwyu-build/bin">> "$GITHUB_OUTPUT"
- name: determine changed files
if: ${{ github.event_name == 'pull_request' }}
uses: actions/github-script@f28e40c7f34bde8b3046d885e986cb6290c5673b # v7
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("Cataclysm-DDA/files_changed", files.join('\n') + '\n');
- name: create CDDA compilation database
working-directory: Cataclysm-DDA
run: |
set -x
echo ::group::Building compilation database
cmake -B build \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DCMAKE_CXX_COMPILER=$COMPILER \
-DCMAKE_BUILD_TYPE="Release" \
-DTILES=${TILES:-0} \
-DSOUND=${SOUND:-0} \
-DLOCALIZE=${LOCALIZE:-0} \
.
echo ::endgroup::
# and include database too, for get_affected_files.py
make includes -j4 --silent TILES=${TILES:-0} SOUND=${SOUND:-0} LOCALIZE=${LOCALIZE:-0}
- uses: ammaraskar/gcc-problem-matcher@0f9c86f9e693db67dacf53986e1674de5f2e5f28 # master
- name: run IWYU
working-directory: Cataclysm-DDA
env:
IWYU_SRC_DIR: ${{ steps.build-iwyu.outputs.IWYU_SRC_DIR }}
IWYU_BIN_DIR: ${{ steps.build-iwyu.outputs.IWYU_BIN_DIR }}
run: |
PATH="${PATH}:${IWYU_BIN_DIR}:${IWYU_SRC_DIR}"
python build-scripts/ci-iwyu-run.py
iwyu-result:
if: ${{ always() }}
needs: [iwyu]
runs-on: ubuntu-latest
steps:
- name: require successful IWYU
run: |
result="${{ needs.iwyu.result }}"
if [ "$result" = "success" ] || [ "$result" = "skipped" ]; then
echo "IWYU result: $result"
exit 0
fi
echo "IWYU failed with result: $result"
exit 1