Skip to content

Commit 8601139

Browse files
authored
refactor: install clang tools on demand (#279)
In order of precedence, this patch allows installing clang tools from 1. PyPI - Python and `pip` are not required. The executable binary is extracted from the downloaded wheel. - downloaded wheels are verified using SHA256 or Blake2b256 algorithms. 2. system package manager(s) (if any available are supported) - Windows: `chocolatey`, `winget` - MacOS: homebrew - Linux: `apt` (Debian), `dnf` (Fedora), `pacman` (arch linux) - Note: For `apt`, when first attempt fails, the official LLVM install script is (cached and) used as a fallback approach. 3. static binaries - binaries are verified with accompanied SHA512 checksum - min and max supported versions can be controlled via env variables at compile time (not runtime); `MIN_CLANG_TOOLS_VERSION` and `MAX_CLANG_TOOLS_VERSION` respectively. - static binary release tag can be controlled via env variable `CLANG_TOOLS_TAG` at compile time (not runtime). - static binary repo url can be controlled via env variable `CLANG_TOOLS_REPO` at compile time (not runtime). ## Caching Caching is enabled per OS standards and specific to cpp-linter use. Caching does not apply to package managers as they tend to manage caches on their own. Note, the cached official LLVM install script (for the `apt` package manager fallback) becomes invalid 24 hours after download. Cache directory can be overridden using the `CPP_LINTER_CACHE` environment variable.
1 parent c09f124 commit 8601139

49 files changed

Lines changed: 21904 additions & 782 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.config/nextest.toml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,28 +3,37 @@ nextest-version = "0.9.77"
33

44
[profile.default]
55
# A profile to run most tests, except tests that run longer than 10 seconds
6-
default-filter = "not test(#*rate_limit_secondary) - test(#git::test::with_*) - test(#repo_get_sha)"
6+
default-filter = """\
7+
not test(#*rate_limit_secondary) \
8+
- test(#git::test::with_*) \
9+
- test(#git::test::repo_get_sha) \
10+
- test(#*eval_version)
11+
"""
712

813
# This will flag any test that runs longer than 10 seconds. Useful when writing new tests.
914
slow-timeout = "10s"
1015

16+
# show which tests were skipped
17+
status-level = "skip"
18+
19+
[profile.warmup]
20+
# Run this profile before other tests to warmup the cache of clang tools binaries.
21+
default-filter = 'test(#*eval_version)'
22+
1123
[profile.ci]
1224
# A profile to run only tests that use clang-tidy and/or clang-format
1325
# NOTE: This profile is intended to keep CI runtime low. Locally, use default or all profiles
1426

1527
# This is all tests in tests/ folder + unit test for --extra-args.
16-
default-filter = "kind(test) + test(#*use_extra_args)"
17-
18-
# show which tests were skipped
19-
status-level = "skip"
28+
default-filter = "kind(test) + test(#*use_extra_args) + test(#*eval_version)"
2029

2130
# show log output from each test
2231
success-output = "final"
2332
failure-output = "immediate-final"
2433

2534
[profile.all]
2635
# A profile to run all tests (including tests that run longer than 10 seconds)
27-
default-filter = "all()"
36+
default-filter = "all() - test(#*eval_version)"
2837

2938
# Revert slow-timeout to nextest default value.
3039
# Otherwise, default profile value (10s) is inherited.

.github/workflows/benchmark.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
fi
6161
- run: rustup update --no-self-update
6262
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'
63-
- run: cargo build --bin cpp-linter --release
63+
- run: cargo build --bin cpp-linter --features bin --release
6464
if: steps.cache.outputs.cache-hit != 'true' || steps.validate.outputs.cache-valid == 'false'
6565
- name: Upload build artifact
6666
uses: actions/upload-artifact@v7

.github/workflows/binary-builds.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ jobs:
6767
os: ubuntu-latest
6868
vendored: true
6969
cross: true
70-
- target: powerpc64-unknown-linux-gnu
71-
os: ubuntu-latest
72-
vendored: true
73-
cross: true
70+
# - target: powerpc64-unknown-linux-gnu
71+
# os: ubuntu-latest
72+
# vendored: true
73+
# cross: true
7474
- target: powerpc64le-unknown-linux-gnu
7575
os: ubuntu-latest
7676
vendored: true
@@ -131,7 +131,7 @@ jobs:
131131
--bin cpp-linter
132132
--release
133133
--target ${{ matrix.target }}
134-
${{ matrix.vendored && '--features openssl-vendored' || '' }}
134+
--features ${{ matrix.vendored && 'bin,openssl-vendored' || 'bin' }}
135135
136136
- name: Prepare artifacts (unix)
137137
if: runner.os != 'Windows'

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

Lines changed: 21 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
strategy:
3232
fail-fast: false
3333
matrix:
34-
os: ['windows-latest', ubuntu-latest]
34+
os: ["windows-latest", ubuntu-latest]
3535

3636
runs-on: ${{ matrix.os }}
3737
steps:
@@ -93,125 +93,28 @@ jobs:
9393
- if: runner.os == 'Linux'
9494
run: sudo apt-get update
9595

96-
- name: Install clang 11
97-
uses: ./.github/install-clang-action
98-
with:
99-
version: '11'
100-
101-
- name: Collect Coverage for clang v11
102-
env:
103-
CLANG_VERSION: '11'
104-
run: nur test --profile ci
105-
106-
- name: Install clang 12
107-
uses: ./.github/install-clang-action
108-
with:
109-
version: '12'
110-
111-
- name: Collect Coverage for clang v12
112-
env:
113-
CLANG_VERSION: '12'
114-
run: nur test --profile ci
115-
116-
- name: Install clang 13
117-
uses: ./.github/install-clang-action
118-
with:
119-
version: '13'
120-
121-
- name: Collect Coverage for clang v13
122-
env:
123-
CLANG_VERSION: '13'
124-
run: nur test --profile ci
125-
126-
- name: Install clang 14
127-
uses: ./.github/install-clang-action
128-
with:
129-
version: '14'
130-
131-
- name: Collect Coverage for clang v14
132-
env:
133-
CLANG_VERSION: '14'
134-
run: nur test --profile ci
135-
136-
- name: Install clang 15
137-
uses: ./.github/install-clang-action
138-
with:
139-
version: '15'
140-
141-
- name: Collect Coverage for clang v15
142-
env:
143-
CLANG_VERSION: '15'
144-
run: nur test --profile ci
145-
146-
- name: Install clang 16
147-
uses: ./.github/install-clang-action
148-
with:
149-
version: '16'
150-
151-
- name: Collect Coverage for clang v16
152-
env:
153-
CLANG_VERSION: '16'
154-
run: nur test --profile ci
96+
- name: Install nushell
97+
uses: hustcer/setup-nu@920172d92eb04671776f3ba69d605d3b09351c30 # v3.22
15598

156-
- name: Install clang 17
157-
uses: ./.github/install-clang-action
158-
with:
159-
version: '17'
160-
161-
- name: Collect Coverage for clang v17
162-
env:
163-
CLANG_VERSION: '17'
164-
run: nur test --profile ci
165-
166-
- name: Install clang 18
167-
uses: ./.github/install-clang-action
168-
with:
169-
version: '18'
170-
171-
- name: Collect Coverage for clang v18
99+
- name: Run test suite
172100
env:
173-
CLANG_VERSION: '18'
174-
run: nur test --profile ci
175-
176-
- name: Install clang v19
177-
uses: ./.github/install-clang-action
178-
with:
179-
version: '19'
180-
181-
- name: Collect Coverage for clang v19
182-
env:
183-
CLANG_VERSION: '19'
184-
run: nur test --profile ci
185-
186-
- name: Install clang v20
187-
uses: ./.github/install-clang-action
188-
with:
189-
version: '20'
190-
191-
- name: Collect Coverage for clang v20
192-
env:
193-
CLANG_VERSION: '20'
194-
run: nur test --profile ci
195-
196-
- name: Install clang v21
197-
uses: ./.github/install-clang-action
198-
with:
199-
version: '21'
200-
201-
- name: Collect Coverage for clang v21
202-
env:
203-
CLANG_VERSION: '21'
204-
run: nur test --profile ci
205-
206-
- name: Install clang v22
207-
uses: ./.github/install-clang-action
208-
with:
209-
version: '22'
210-
211-
- name: Collect Coverage for clang v22
212-
env:
213-
CLANG_VERSION: '22'
214-
run: nur test --profile all
101+
MIN_CLANG_TOOLS_VERSION: "11"
102+
MAX_CLANG_TOOLS_VERSION: "22"
103+
shell: nu {0}
104+
run: |-
105+
let max_ver = $env.MAX_CLANG_TOOLS_VERSION | into int
106+
let min_ver = $env.MIN_CLANG_TOOLS_VERSION | into int
107+
for $ver in ($min_ver..$max_ver) {
108+
print $"::group::Testing with clang v($ver)"
109+
with-env { CLANG_VERSION: $"($ver)" } {
110+
nur test --profile warmup
111+
let test_profile = (
112+
if ($ver == $max_ver) { "all" } else { "ci" }
113+
)
114+
nur test --profile $test_profile
115+
}
116+
print "::endgroup::"
117+
}
215118
216119
- name: Generate Coverage HTML report
217120
run: nur test llvm-cov

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repos:
88
exclude: bindings/node/.*package\.json
99
- id: check-docstring-first
1010
- id: check-added-large-files
11-
exclude: '^\.yarn/releases/yarn.*js'
11+
exclude: '^\.yarn/releases/yarn.*js|pypi_clang.*\.json$'
1212
- id: check-yaml
1313
exclude: docs/mkdocs.yml
1414
- id: check-toml

0 commit comments

Comments
 (0)