Skip to content

Commit 96fbc91

Browse files
authored
chore(dev): add uv support (#143)
* adjust metadata for uv support fix project's minimum supported python version and check-in uv.lock * set dev dependencies as a proper group dev dependencies are no use to users as extra/optional dependencies * update test/benchmark CI and use uv to run pre-commit in testing/run.sh
1 parent 069417d commit 96fbc91

File tree

5 files changed

+885
-17
lines changed

5 files changed

+885
-17
lines changed

.github/workflows/codspeed.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,15 @@ jobs:
3131
with:
3232
python-version: "3.13"
3333

34+
- name: Setup uv
35+
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
36+
3437
- name: Install dependencies
35-
run: pip install -e .[dev]
38+
run: uv sync --dev
3639

3740
- name: Run benchmarks
3841
uses: CodSpeedHQ/action@4348f634fa7309fe23aac9502e88b999ec90a164 #v3
3942
with:
4043
token: ${{ secrets.CODSPEED_TOKEN }}
41-
run: pytest tests/ --codspeed
44+
run: uv run pytest tests/ --codspeed
4245
mode: instrumentation

.github/workflows/test.yml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ name: Test
22

33
on:
44
push:
5-
branches: main
5+
branches: [main]
66
pull_request:
7-
branches: main
7+
branches: [main]
88
workflow_dispatch:
99

1010
jobs:
@@ -22,16 +22,17 @@ jobs:
2222
with:
2323
python-version: ${{ matrix.python-version }}
2424

25+
- name: Setup uv
26+
uses: astral-sh/setup-uv@85856786d1ce8acfbcc2f13a5f3fbd6b938f9f41 # v7.1.2
27+
2528
- name: Install dependencies
26-
run: |
27-
python -m pip install --upgrade pip
28-
pip install .[dev]
29+
run: uv sync --dev
2930

3031
- name: Run tests and collect coverage
31-
run: |
32-
coverage run --source=tests,cpp_linter_hooks -m pytest -vv
33-
coverage report
34-
coverage xml
32+
run: |-
33+
uv run coverage run --source=tests,cpp_linter_hooks -m pytest -vv
34+
uv run coverage report
35+
uv run coverage xml
3536
- uses: codecov/codecov-action@5a1091511ad55cbe89839c7260b706298ca349f7 #v5
3637
if: matrix.python-version == '3.13'
3738
with:

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
requires = ["setuptools>=45", "setuptools-scm"]
33
build-backend = "setuptools.build_meta"
44

5-
requires-python = ">=3.9"
6-
75
[project]
6+
requires-python = ">=3.9"
87
name = "cpp_linter_hooks"
98
description = "Automatically formats and lints C/C++ code using clang-format and clang-tidy"
109
readme = "README.md"
@@ -48,7 +47,7 @@ clang-tidy-hook = "cpp_linter_hooks.clang_tidy:main"
4847
source = "https://github.com/cpp-linter/cpp-linter-hooks"
4948
tracker = "https://github.com/cpp-linter/cpp-linter-hooks/issues"
5049

51-
[project.optional-dependencies]
50+
[dependency-groups]
5251
dev = [
5352
"coverage",
5453
"pre-commit",
@@ -83,4 +82,4 @@ omit = ["tests/*"]
8382
exclude_also = [
8483
"__name__",
8584
"FileNotFoundError"
86-
]
85+
]

testing/run.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ for config in "${configs[@]}"; do
1111
echo "===================================="
1212
echo "Test $config"
1313
echo "===================================="
14-
pre-commit clean
15-
pre-commit run -c testing/$config --files testing/main.c | tee -a result.txt || true
14+
uvx pre-commit clean
15+
uvx pre-commit run -c testing/$config --files testing/main.c | tee -a result.txt || true
1616
git restore testing/main.c
1717
done
1818

0 commit comments

Comments
 (0)