Skip to content

Commit 0217de1

Browse files
committed
revamp test CI
reuse a local composite action to install clang tools clear added PPA for reuse of llvm install script
1 parent 6cd64c7 commit 0217de1

File tree

3 files changed

+176
-53
lines changed

3 files changed

+176
-53
lines changed

.github/workflows/run-dev-tests.yml

+132-52
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,11 @@ env:
2222
RUST_BACKTRACE: 1
2323

2424
jobs:
25-
cache-deps:
26-
runs-on: ${{ matrix.os }}
27-
strategy:
28-
fail-fast: false
29-
matrix:
30-
os: [windows-latest, ubuntu-latest]
31-
steps:
32-
- run: rustup update --no-self-update
33-
- uses: actions/checkout@v4
34-
- name: Cache .cargo locked resources
35-
uses: actions/cache@v4
36-
with:
37-
path: ~/.cargo
38-
key: ${{ runner.os }}-test-cargo-${{ hashFiles('Cargo.lock') }}
39-
- run: cargo fetch
40-
4125
test:
42-
needs: [cache-deps]
43-
name: test ${{ matrix.os }} w/ clang v${{ matrix.version }}
4426
strategy:
4527
fail-fast: false
4628
matrix:
4729
os: ['windows-latest', ubuntu-latest]
48-
version: ['17', '16', '15', '14', '13', '12', '11', '10', '9', '8', '7']
4930

5031
runs-on: ${{ matrix.os }}
5132
steps:
@@ -87,59 +68,158 @@ jobs:
8768
if: runner.os == 'Windows'
8869
run: choco install ninja
8970

90-
- name: Install Linux clang dependencies
91-
if: runner.os == 'Linux'
92-
shell: bash
93-
run: |
94-
sudo apt-get update
95-
# First try installing from default Ubuntu repositories before trying LLVM script
96-
if ! sudo apt-get install -y clang-format-${{ matrix.version }} clang-tidy-${{ matrix.version }}; then
97-
# This LLVM script will add the relevant LLVM PPA: https://apt.llvm.org/
98-
wget https://apt.llvm.org/llvm.sh -O ${{ runner.temp }}/llvm_install.sh
99-
chmod +x ${{ runner.temp }}/llvm_install.sh
100-
if sudo ${{ runner.temp }}/llvm_install.sh ${{ matrix.version }}; then
101-
sudo apt-get install -y clang-format-${{ matrix.version }} clang-tidy-${{ matrix.version }}
102-
fi
103-
fi
104-
105-
- name: Install clang-tools
106-
run: |
107-
python -m pip install clang-tools
108-
clang-tools --install ${{ matrix.version }}
109-
110-
- name: Cache .cargo locked resources
111-
uses: actions/cache/restore@v4
112-
with:
113-
path: ~/.cargo
114-
key: ${{ runner.os }}-test-cargo-${{ hashFiles('Cargo.lock') }}
71+
- name: Fetch .cargo locked resources
72+
run: cargo fetch
73+
74+
- name: Install clang v7
75+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
76+
with:
77+
version: '7'
11578

11679
- name: Collect Coverage
11780
working-directory: cpp-linter-lib
11881
env:
119-
CLANG_VERSION: ${{ matrix.version }}
82+
CLANG_VERSION: '7'
12083
run: just test
12184

122-
- name: Generate Coverage HTML report
85+
- name: Install clang v8
86+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
87+
with:
88+
version: '8'
89+
90+
- name: Collect Coverage
91+
working-directory: cpp-linter-lib
92+
env:
93+
CLANG_VERSION: '8'
94+
run: just test
95+
96+
- name: Install clang v9
97+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
98+
with:
99+
version: '9'
100+
101+
- name: Collect Coverage
102+
working-directory: cpp-linter-lib
103+
env:
104+
CLANG_VERSION: '9'
105+
run: just test
106+
107+
- name: Install clang v10
108+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
109+
with:
110+
version: '10'
111+
112+
- name: Collect Coverage
113+
working-directory: cpp-linter-lib
114+
env:
115+
CLANG_VERSION: '10'
116+
run: just test
117+
118+
- name: Install clang 11
119+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
120+
with:
121+
version: '11'
122+
123+
- name: Collect Coverage
124+
working-directory: cpp-linter-lib
125+
env:
126+
CLANG_VERSION: '11'
127+
run: just test
128+
129+
- name: Install clang 12
130+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
131+
with:
132+
version: '12'
133+
134+
- name: Collect Coverage
135+
working-directory: cpp-linter-lib
136+
env:
137+
CLANG_VERSION: '12'
138+
run: just test
139+
140+
- name: Install clang 13
141+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
142+
with:
143+
version: '13'
144+
145+
- name: Collect Coverage
146+
working-directory: cpp-linter-lib
147+
env:
148+
CLANG_VERSION: '13'
149+
run: just test
150+
151+
- name: Install clang 14
152+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
153+
with:
154+
version: '14'
155+
156+
- name: Collect Coverage
157+
working-directory: cpp-linter-lib
158+
env:
159+
CLANG_VERSION: '14'
160+
run: just test
161+
162+
- name: Install clang 15
163+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
164+
with:
165+
version: '15'
166+
167+
- name: Collect Coverage
168+
working-directory: cpp-linter-lib
169+
env:
170+
CLANG_VERSION: '15'
171+
run: just test
172+
173+
- name: Install clang 16
174+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
175+
with:
176+
version: '16'
177+
178+
- name: Collect Coverage
179+
working-directory: cpp-linter-lib
180+
env:
181+
CLANG_VERSION: '16'
182+
run: just test
183+
184+
- name: Install clang 17
185+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
186+
with:
187+
version: '17'
188+
189+
- name: Collect Coverage
123190
working-directory: cpp-linter-lib
124191
env:
125-
CLANG_VERSION: ${{ matrix.version }}
192+
CLANG_VERSION: '17'
193+
run: just test
194+
195+
- name: Install clang 18
196+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
197+
with:
198+
version: '18'
199+
200+
- name: Collect Coverage
201+
working-directory: cpp-linter-lib
202+
env:
203+
CLANG_VERSION: '18'
204+
run: just test
205+
206+
- name: Generate Coverage HTML report
207+
working-directory: cpp-linter-lib
126208
run: just pretty-cov
127209

128210
- name: Upload coverage data
129211
uses: actions/upload-artifact@v4
130212
with:
131-
name: HTML_report-${{ runner.os }}-clang_v${{ matrix.version }}
213+
name: HTML_report-${{ runner.os }}
132214
path: target/llvm-cov-pretty
133215

134216
- name: Generate Coverage lcov report
135-
if: matrix.version == '16' && runner.os == 'Linux'
217+
if: runner.os == 'Linux'
136218
working-directory: cpp-linter-lib
137-
env:
138-
CLANG_VERSION: ${{ matrix.version }}
139219
run: just lcov
140220

141221
- uses: codecov/codecov-action@v4
142-
if: matrix.version == '16' && runner.os == 'Linux'
222+
if: runner.os == 'Linux'
143223
with:
144224
token: ${{secrets.CODECOV_TOKEN}}
145225
files: cpp-linter-lib/lcov.info

cpp-linter-lib/tests/reviews_test_assets/.clang-tidy

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,performance-*,bugprone-*,clang-analyzer-*,mpi-*,misc-*,readability-*'
33
WarningsAsErrors: ''
44
HeaderFilterRegex: ''
5-
AnalyzeTemporaryDtors: false
65
FormatStyle: 'file'
76
CheckOptions:
87
- key: bugprone-argument-comment.CommentBoolLiterals

install-clang-action/action.yml

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Install clang
2+
description: Install clang tidy and clang-format given a specified version
3+
4+
inputs:
5+
version:
6+
description: The version of clang tools to install
7+
required: true
8+
9+
runs:
10+
using: composite
11+
steps:
12+
- name: Install Linux clang dependencies
13+
if: runner.os == 'Linux'
14+
shell: bash
15+
run: |
16+
sudo apt-get update
17+
# First try installing from default Ubuntu repositories before trying LLVM script
18+
if ! sudo apt-get install -y clang-format-${{ inputs.version }} clang-tidy-${{ inputs.version }}; then
19+
if [ ! -f "${{ runner.temp }}/llvm_install.sh" ]; then
20+
# This LLVM script will add the relevant LLVM PPA: https://apt.llvm.org/
21+
wget https://apt.llvm.org/llvm.sh -O ${{ runner.temp }}/llvm_install.sh
22+
chmod +x ${{ runner.temp }}/llvm_install.sh
23+
fi
24+
if sudo "${{ runner.temp }}/llvm_install.sh" "${{ inputs.version }}" ; then
25+
sudo apt-get install -y clang-format-${{ inputs.version }} clang-tidy-${{ inputs.version }}
26+
fi
27+
# remove the PPA for future reuse of install script (regardless of successful install)
28+
sudo rm /etc/apt/sources.list.d/*llvm*.list || true
29+
fi
30+
31+
- name: Install MacOS clang dependencies
32+
if: runner.os == 'macOS'
33+
shell: bash
34+
continue-on-error: true
35+
run: |
36+
brew install llvm@${{ inputs.version }}
37+
ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-format" "/usr/local/bin/clang-format-${{ inputs.version }}"
38+
ln -s "$(brew --prefix llvm@${{ inputs.version }})/bin/clang-tidy" "/usr/local/bin/clang-tidy-${{ inputs.version }}"
39+
40+
- name: Use clang-tools-pip as fallback
41+
shell: bash
42+
run: |
43+
python -m pip install clang-tools
44+
clang-tools -i ${{ inputs.version }} -b -f

0 commit comments

Comments
 (0)