Skip to content

Commit 41e7389

Browse files
authored
feat: support testing on diff python versions (#56)
* feat: test.yml to support test on diff python versions * feat: update python versions * feat: update python versions * feat: update README.md and add requires-python
1 parent 434ac11 commit 41e7389

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

Diff for: .github/workflows/test.yml

+8-2
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,18 @@ on:
1010
jobs:
1111
test:
1212
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: ["3.14.0-alpha.2", "3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]
1316
steps:
1417
- name: Checkout
1518
uses: actions/checkout@v4
16-
- name: Set up Python 3.12
19+
20+
- name: Set up Python ${{ matrix.python-version }}
1721
uses: actions/setup-python@v5
1822
with:
19-
python-version: "3.12"
23+
python-version: ${{ matrix.python-version }}
24+
2025
- name: Install dependencies
2126
run: |
2227
python -m pip install --upgrade pip
@@ -29,6 +34,7 @@ jobs:
2934
coverage report
3035
coverage xml
3136
- uses: codecov/codecov-action@v5
37+
if: matrix.python-version == '3.13'
3238
with:
3339
token: ${{ secrets.CODECOV_TOKEN }}
3440
files: ./coverage.xml

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ tests/__pycache__
88
coverage.xml
99
__pycache__
1010
venv
11+
.venv
1112
result.txt
1213
testing/main.c
1314
*/*compile_commands.json

Diff for: README.md

+14-9
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
# cpp-linter-hooks
22

3-
[![PyPI](https://img.shields.io/pypi/v/cpp-linter-hooks)](https://pypi.org/project/cpp-linter-hooks/)
3+
[![PyPI](https://img.shields.io/pypi/v/cpp-linter-hooks?color=blue)](https://pypi.org/project/cpp-linter-hooks/)
4+
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cpp-linter-hooks)](https://pypi.org/project/cpp-linter-hooks/)
45
[![codecov](https://codecov.io/gh/cpp-linter/cpp-linter-hooks/branch/main/graph/badge.svg?token=L74Z3HZ4Y5)](https://codecov.io/gh/cpp-linter/cpp-linter-hooks)
56
[![Test](https://github.com/cpp-linter/cpp-linter-hooks/actions/workflows/test.yml/badge.svg)](https://github.com/cpp-linter/cpp-linter-hooks/actions/workflows/test.yml)
67
[![CodeQL](https://github.com/cpp-linter/cpp-linter-hooks/actions/workflows/codeql.yml/badge.svg)](https://github.com/cpp-linter/cpp-linter-hooks/actions/workflows/codeql.yml)
78
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
89
<!-- [![PyPI - Downloads](https://img.shields.io/pypi/dw/cpp-linter-hooks)](https://pypi.org/project/cpp-linter-hooks/) -->
910

10-
cpp-linter-hooks is a [pre-commit](https://pre-commit.com/) hook that uses clang-format and clang-tidy to check your C/C++ code.
11+
cpp-linter-hooks is a [pre-commit](https://pre-commit.com/) hook that uses `clang-format` and `clang-tidy` to format C/C++ code.
1112

1213
> [!NOTE]
13-
> This hook automatically downloads a specific version of `clang-format` or `clang-tidy` [binaries](https://github.com/cpp-linter/clang-tools-static-binaries) and installs it on the system.
14+
> This hook automatically downloads specific versions of `clang-format` or `clang-tidy` [binaries](https://github.com/cpp-linter/clang-tools-static-binaries) and installs them on your system.
1415
1516
## Usage
1617

17-
Add the following configuration to your `.pre-commit-config.yaml`:
18+
To use cpp-linter-hooks, add the following configuration to your `.pre-commit-config.yaml`:
19+
20+
### Basic Configuration
1821

1922
```yaml
2023
repos:
@@ -27,6 +30,8 @@ repos:
2730
args: [--checks='boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*']
2831
```
2932
33+
### Custom Configuration
34+
3035
To use custom configurations like `.clang-format` and `.clang-tidy`:
3136

3237
```yaml
@@ -55,15 +60,15 @@ repos:
5560

5661
## Output
5762

58-
### clang-format output
63+
### clang-format Example
5964

6065
```bash
6166
clang-format.............................................................Failed
6267
- hook id: clang-format
6368
- files were modified by this hook
6469
```
6570

66-
The diff between the modified file is as follows:
71+
Here’s a sample diff showing the formatting applied:
6772

6873
```diff
6974
--- a/testing/main.c
@@ -106,7 +111,7 @@ int main() {for (;;) break; printf("Hello world!\n");return 0;}
106111
^
107112
```
108113

109-
### clang-tidy output
114+
### clang-tidy Example
110115

111116
```bash
112117
clang-tidy...............................................................Failed
@@ -125,8 +130,8 @@ Use -header-filter=.* to display errors from all non-system headers. Use -system
125130

126131
## Contributing
127132

128-
Contributions are very welcome, including submitting issues, PRs, etc.
133+
We welcome contributions! Whether it's fixing issues, suggesting improvements, or submitting pull requests, your support is greatly appreciated.
129134

130135
## License
131136

132-
[MIT](LICENSE)
137+
cpp-linter-hooks is licensed under the [MIT License](LICENSE)

Diff for: pyproject.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
requires = ["setuptools>=45", "setuptools-scm"]
33
build-backend = "setuptools.build_meta"
44

5+
requires-python = ">=3.8"
6+
57
[project]
68
name = "cpp_linter_hooks"
79
description = "Automatically check c/c++ code with clang-format and clang-tidy"
@@ -21,7 +23,13 @@ classifiers = [
2123
"Operating System :: Microsoft :: Windows",
2224
"Operating System :: POSIX :: Linux",
2325
"Operating System :: MacOS",
24-
"Programming Language :: Python :: 3",
26+
"Programming Language :: Python :: 3.8",
27+
"Programming Language :: Python :: 3.9",
28+
"Programming Language :: Python :: 3.10",
29+
"Programming Language :: Python :: 3.11",
30+
"Programming Language :: Python :: 3.12",
31+
"Programming Language :: Python :: 3.13",
32+
"Programming Language :: Python :: 3.14",
2533
"Topic :: Software Development :: Build Tools",
2634
]
2735
dependencies = [

0 commit comments

Comments
 (0)