Skip to content

Commit 638ceed

Browse files
committed
revamp test CI
reuse a local composite action to install clang tools clear added PPA for reuse of LLVM install script only run long-running unit tests on latest supported clang version
1 parent 6cd64c7 commit 638ceed

File tree

6 files changed

+188
-57
lines changed

6 files changed

+188
-57
lines changed

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

Lines changed: 137 additions & 54 deletions
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,161 @@ 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') }}
115-
116-
- name: Collect Coverage
71+
- name: Fetch .cargo locked resources
72+
run: cargo fetch
73+
74+
- if: runner.os == 'Linux'
75+
run: sudo apt-get update
76+
77+
- name: Install clang v7
78+
uses: cpp-linter/cpp_linter_rs/install-clang-action@pr-reviews
79+
with:
80+
version: '7'
81+
82+
- name: Collect Coverage for clang v7
11783
working-directory: cpp-linter-lib
11884
env:
119-
CLANG_VERSION: ${{ matrix.version }}
85+
CLANG_VERSION: '7'
12086
run: just test
12187

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

128213
- name: Upload coverage data
129214
uses: actions/upload-artifact@v4
130215
with:
131-
name: HTML_report-${{ runner.os }}-clang_v${{ matrix.version }}
216+
name: HTML_report-${{ runner.os }}
132217
path: target/llvm-cov-pretty
133218

134219
- name: Generate Coverage lcov report
135-
if: matrix.version == '16' && runner.os == 'Linux'
220+
if: runner.os == 'Linux'
136221
working-directory: cpp-linter-lib
137-
env:
138-
CLANG_VERSION: ${{ matrix.version }}
139222
run: just lcov
140223

141224
- uses: codecov/codecov-action@v4
142-
if: matrix.version == '16' && runner.os == 'Linux'
225+
if: runner.os == 'Linux'
143226
with:
144227
token: ${{secrets.CODECOV_TOKEN}}
145228
files: cpp-linter-lib/lcov.info

cpp-linter-lib/src/git.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ mod test {
412412
}
413413

414414
#[tokio::test]
415+
#[ignore]
415416
async fn with_no_changed_sources() {
416417
// commit with no modified C/C++ sources
417418
let sha = "0c236809891000b16952576dc34de082d7a40bf3";
@@ -426,6 +427,7 @@ mod test {
426427
}
427428

428429
#[tokio::test]
430+
#[ignore]
429431
async fn with_changed_sources() {
430432
// commit with modified C/C++ sources
431433
let sha = "950ff0b690e1903797c303c5fc8d9f3b52f1d3c5";
@@ -445,6 +447,7 @@ mod test {
445447
}
446448

447449
#[tokio::test]
450+
#[ignore]
448451
async fn with_staged_changed_sources() {
449452
// commit with no modified C/C++ sources
450453
let sha = "0c236809891000b16952576dc34de082d7a40bf3";

cpp-linter-lib/src/rest_api/github_api.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -899,12 +899,14 @@ mod test {
899899
}
900900

901901
#[tokio::test]
902+
#[ignore]
902903
#[should_panic(expected = "REST API secondary rate limit exceeded")]
903904
async fn secondary_rate_limit() {
904905
simulate_rate_limit(true).await;
905906
}
906907

907908
#[tokio::test]
909+
#[ignore]
908910
#[should_panic(expected = "REST API rate limit exceeded!")]
909911
async fn primary_rate_limit() {
910912
simulate_rate_limit(false).await;

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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 44 additions & 0 deletions
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+
# NOTE: sudo apt-get update should be executed at least once before running this action
16+
run: |
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

justfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ py-dev:
1919

2020
# run the test suite
2121
[group("code coverage")]
22-
test:
22+
test *args='':
2323
cargo llvm-cov --no-report \
2424
nextest --manifest-path cpp-linter-lib/Cargo.toml \
25-
--lib --tests --color always
25+
--lib --tests --color always {{ args }}
2626

2727
# Clear previous test build artifacts
2828
[group("code coverage")]

0 commit comments

Comments
 (0)