Skip to content

feat: support testing on diff python versions #56

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,18 @@ on:
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.14.0-alpha.2", "3.13", "3.12", "3.11", "3.10", "3.9", "3.8"]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python 3.12

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: "3.12"
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -29,6 +34,7 @@ jobs:
coverage report
coverage xml
- uses: codecov/codecov-action@v5
if: matrix.python-version == '3.13'
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ tests/__pycache__
coverage.xml
__pycache__
venv
.venv
result.txt
testing/main.c
*/*compile_commands.json
23 changes: 14 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
# cpp-linter-hooks

[![PyPI](https://img.shields.io/pypi/v/cpp-linter-hooks)](https://pypi.org/project/cpp-linter-hooks/)
[![PyPI](https://img.shields.io/pypi/v/cpp-linter-hooks?color=blue)](https://pypi.org/project/cpp-linter-hooks/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/cpp-linter-hooks)](https://pypi.org/project/cpp-linter-hooks/)
[![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)
[![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)
[![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)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
<!-- [![PyPI - Downloads](https://img.shields.io/pypi/dw/cpp-linter-hooks)](https://pypi.org/project/cpp-linter-hooks/) -->

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.
cpp-linter-hooks is a [pre-commit](https://pre-commit.com/) hook that uses `clang-format` and `clang-tidy` to format C/C++ code.

> [!NOTE]
> 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.
> 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.

## Usage

Add the following configuration to your `.pre-commit-config.yaml`:
To use cpp-linter-hooks, add the following configuration to your `.pre-commit-config.yaml`:

### Basic Configuration

```yaml
repos:
Expand All @@ -27,6 +30,8 @@ repos:
args: [--checks='boost-*,bugprone-*,performance-*,readability-*,portability-*,modernize-*,clang-analyzer-*,cppcoreguidelines-*']
```

### Custom Configuration

To use custom configurations like `.clang-format` and `.clang-tidy`:

```yaml
Expand Down Expand Up @@ -55,15 +60,15 @@ repos:

## Output

### clang-format output
### clang-format Example

```bash
clang-format.............................................................Failed
- hook id: clang-format
- files were modified by this hook
```

The diff between the modified file is as follows:
Here’s a sample diff showing the formatting applied:

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

### clang-tidy output
### clang-tidy Example

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

## Contributing

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

## License

[MIT](LICENSE)
cpp-linter-hooks is licensed under the [MIT License](LICENSE)
10 changes: 9 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
requires = ["setuptools>=45", "setuptools-scm"]
build-backend = "setuptools.build_meta"

requires-python = ">=3.8"

[project]
name = "cpp_linter_hooks"
description = "Automatically check c/c++ code with clang-format and clang-tidy"
Expand All @@ -21,7 +23,13 @@ classifiers = [
"Operating System :: Microsoft :: Windows",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Topic :: Software Development :: Build Tools",
]
dependencies = [
Expand Down
Loading