Skip to content

Commit 634d80d

Browse files
authored
mock REST API calls in tests (#21)
* fix parsing of compilation database; add rate limit tests * measure coverage from integration tests * fix CI conflicting cache keys * fix title in permissions.md doc
1 parent 8934b8d commit 634d80d

30 files changed

+2973
-335
lines changed

.github/workflows/binary-builds.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
env:
152152
GH_TOKEN: ${{ github.token }}
153153
run: |
154-
files=$(ls dist/cpp-linter*
154+
files=$(ls dist/cpp-linter*)
155155
gh release create ${{ github.ref_name }} --generate-notes $files
156156
- run: cargo publish
157157
working-directory: cpp-linter-lib

.github/workflows/build-docs.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
uses: actions/cache@v4
1717
with:
1818
path: ~/.cargo
19-
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
19+
key: ${{ runner.os }}-docs-cargo-${{ hashFiles('Cargo.lock') }}
2020
- run: cargo fetch
2121

2222
build-mdbook:
@@ -30,7 +30,7 @@ jobs:
3030
uses: actions/cache/restore@v4
3131
with:
3232
path: ~/.cargo
33-
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
33+
key: ${{ runner.os }}-docs-cargo-${{ hashFiles('Cargo.lock') }}
3434
- name: Install mdbook
3535
uses: taiki-e/install-action@v2
3636
with:
@@ -62,7 +62,7 @@ jobs:
6262
uses: actions/cache/restore@v4
6363
with:
6464
path: ~/.cargo
65-
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
65+
key: ${{ runner.os }}-docs-cargo-${{ hashFiles('Cargo.lock') }}
6666
- run: cargo doc --no-deps --manifest-path cpp-linter-lib/Cargo.toml
6767
- name: upload rustdoc build as artifact
6868
uses: actions/upload-artifact@v4

.github/workflows/python-packaging.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,6 @@ jobs:
111111
- uses: actions/setup-python@v5
112112
with:
113113
python-version: '3.x'
114-
- name: Increment version
115-
if: startsWith(github.ref, 'refs/tags/')
116-
run: python .github/workflows/replace_version_spec.py --new-version=${{ github.ref_name }}
117114
- name: Build wheels
118115
uses: PyO3/maturin-action@v1
119116
with:
@@ -153,7 +150,8 @@ jobs:
153150
- name: Publish to PyPI
154151
uses: PyO3/maturin-action@v1
155152
env:
156-
MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
153+
MATURIN_PYPI_TOKEN: ${{ contains(github.ref_name, 'rc') && secrets.TEST_PYPI_API_TOKEN || secrets.PYPI_API_TOKEN }}
154+
MATURIN_REPOSITORY: ${{ contains(github.ref_name, 'rc') && 'test-pypi' || 'pypi' }}
157155
with:
158156
command: upload
159157
args: --non-interactive --skip-existing dist/*

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

+12-12
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ env:
2323

2424
jobs:
2525
cache-deps:
26-
runs-on: ubuntu-latest
26+
runs-on: ${{ matrix.os }}
2727
strategy:
2828
fail-fast: false
2929
matrix:
30-
os: ['windows-latest', ubuntu-latest]
30+
os: [windows-latest, ubuntu-latest]
3131
steps:
3232
- run: rustup update --no-self-update
3333
- uses: actions/checkout@v4
3434
- name: Cache .cargo locked resources
3535
uses: actions/cache@v4
3636
with:
3737
path: ~/.cargo
38-
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
38+
key: ${{ runner.os }}-test-cargo-${{ hashFiles('Cargo.lock') }}
3939
- run: cargo fetch
4040

4141
test:
@@ -76,16 +76,16 @@ jobs:
7676
with:
7777
python-version: 3.x
7878

79-
# - name: Install workflow deps
80-
# run: python3 -m pip install meson
79+
- name: Install workflow deps
80+
run: python3 -m pip install meson
8181

8282
# # https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages
83-
# - name: Install ninja (Linux)
84-
# if: runner.os == 'Linux'
85-
# run: sudo apt-get install ninja-build
86-
# - name: Install ninja (Windows)
87-
# if: runner.os == 'Windows'
88-
# run: choco install ninja
83+
- name: Install ninja (Linux)
84+
if: runner.os == 'Linux'
85+
run: sudo apt-get install ninja-build
86+
- name: Install ninja (Windows)
87+
if: runner.os == 'Windows'
88+
run: choco install ninja
8989

9090
- name: Install Linux clang dependencies
9191
if: runner.os == 'Linux'
@@ -111,7 +111,7 @@ jobs:
111111
uses: actions/cache/restore@v4
112112
with:
113113
path: ~/.cargo
114-
key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }}
114+
key: ${{ runner.os }}-test-cargo-${{ hashFiles('Cargo.lock') }}
115115

116116
- name: Collect Coverage
117117
working-directory: cpp-linter-lib

.pre-commit-config.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ repos:
33
rev: v4.6.0
44
hooks:
55
- id: trailing-whitespace
6-
exclude: cpp-linter-lib/tests/capture_tools_output/cpp-linter/cpp-linter/test_git_lib.patch
6+
exclude: cpp-linter-lib/tests/.*\.(?:patch|diff)
77
- id: end-of-file-fixer
88
- id: check-docstring-first
99
- id: check-added-large-files

Cargo.lock

+92
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cpp-linter-lib/Cargo.toml

+5
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ documentation.workspace = true
88
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
99

1010
[dependencies]
11+
chrono = "0.4.38"
1112
clap = "4.5.16"
13+
futures = "0.3.30"
1214
git2 = "0.19.0"
1315
lenient_semver = "0.4.2"
1416
log = "0.4.22"
@@ -26,6 +28,7 @@ tokio-stream = "0.1.15"
2628
which = "6.0.3"
2729

2830
[dev-dependencies]
31+
mockito = "1.5.0"
2932
tempfile = "3.9.0"
3033

3134
[features]
@@ -34,3 +37,5 @@ openssl-vendored = ["dep:openssl", "dep:openssl-probe"]
3437
[[bin]]
3538
name = "cpp-linter"
3639
path = "src/main.rs"
40+
test = false
41+
bench = false

cpp-linter-lib/examples/gh_rest_api.rs

-34
This file was deleted.

0 commit comments

Comments
 (0)