forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (75 loc) · 2.72 KB
/
Copy pathcode-tidy.yml
File metadata and controls
87 lines (75 loc) · 2.72 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
name: Tidy Checks
on:
push:
branches:
- master
pull_request:
branches:
- master
jobs:
RunClangTidy:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: 'recursive'
- name: Install dependencies
run: |
sudo ./scripts/uni-get-dependencies.sh
sudo apt -qq -y install clang-tidy
- name: Run CMake
run: cmake -S . -B build -GNinja
- name: Build autogenerated files
run: ninja -C build CMakeFiles/OpenSCAD_autogen
- name: Create Cache Timestamp
id: cache_timestamp
uses: nanzm/get-time-action@v2.0
with:
format: 'YYYY-MM-DD-HH-mm-ss'
- name: Retrieve cached results
uses: actions/cache@v4
with:
# TODO: maybe cache based on time in push but based on some PR
# identifier in pull requests ?
path: /home/runner/.cache/clang-tidy
key: clang-tidy-${{ steps.cache_timestamp.outputs.time }}
restore-keys: clang-tidy-
# TODO: each distinct file will store a new file (output of clang-tidy)
# in this directory; also clang-tidy version and content of its config
# While small, this will accumulate, so cleaning every now and then might
# be good.
- name: Run ClangTidy
run: |
ln -s build/compile_commands.json .
# Since we're not 'clean' yet, or with 'true' to not fail CI, but
# at least the output will provide a report
scripts/run-clang-tidy-cached.cc || true
- name: Show difference to base
run: |
BASE_DIR=/home/runner/.cache/clang-tidy/for-hash
PR_BASE_SHA=$BASE_DIR/${{ github.event.pull_request.base.sha }}
if [ -r ${PR_BASE_SHA}.summary ]; then
# TODO: this might still need refinement once submitted
join -j2 -a1 \
<(sort -k2 OpenSCAD_clang-tidy.summary) \
<(sort -k2 ${PR_BASE_SHA}.summary) \
| awk '{ delta=($2 - $3); \
if (delta != 0) printf("%30s %+5d\n", $1, delta); }'
fi
- name: Remember for git sha
# Only remember when we're pushing
if: ${{github.event_name == 'push' && (github.ref == 'refs/heads/master')}}
run: |
# TODO: that accumulates, maybe clean old ones every now and then.
BASE_DIR=/home/runner/.cache/clang-tidy/for-hash
mkdir -p ${BASE_DIR}
cp OpenSCAD_clang-tidy.out ${BASE_DIR}/${{ github.sha }}.out
cp OpenSCAD_clang-tidy.summary ${BASE_DIR}/${{ github.sha }}.summary
- name: Upload clang-tidy Results
uses: actions/upload-artifact@v4
with:
name: clang-tidy Results
path: |
OpenSCAD_clang-tidy.out
OpenSCAD_clang-tidy.summary