|
| 1 | +# Contributing |
| 2 | + |
| 3 | +Thanks for contributing! This document covers the local lint setup so your changes match what CI enforces. |
| 4 | + |
| 5 | +## Lint matrix |
| 6 | + |
| 7 | +CI runs the `bvt-lint` job on every PR. The workflow installs `pre-commit`, runs `pre-commit run --all-files`, and then builds the docs with `mkdocs build --strict`. The full check set, file scopes, and pinned tool versions all live in [`.pre-commit-config.yaml`](.pre-commit-config.yaml). That file is the single source of truth. |
| 8 | + |
| 9 | +| Hook | What it checks | |
| 10 | +|-----------------------|----------------| |
| 11 | +| `pre-commit-hooks` | Basic hygiene. Line endings, trailing whitespace, final newline, merge-conflict markers, case-conflicting paths, Windows-illegal names, files over 1024 KB. | |
| 12 | +| `ruff-format` | Python scripts (`*.py`). | |
| 13 | +| `clang-format` | Every tracked C++ source file (`*.h`, `*.cpp`, `*.ixx`) and the `## Example` cpp blocks inside any Markdown file. | |
| 14 | +| `gersemi` | CMake build files (`CMakeLists.txt` and `*.cmake`) outside `subprojects/`. | |
| 15 | +| `meson-format` | Meson build files (`meson.build`, `meson.options`, `meson_options.txt`). | |
| 16 | +| `buildifier` | Bazel build files (`BUILD.bazel`, `MODULE.bazel`, `WORKSPACE.bazel`, `*.bzl`). | |
| 17 | +| `actionlint` | GitHub Actions workflows (`.github/workflows/*.yml`). | |
| 18 | + |
| 19 | +These hooks run both locally and in CI. On top of them, CI also builds the docs with `mkdocs build --strict` to confirm `docs/` builds cleanly. |
| 20 | + |
| 21 | +The `clang-format` hook is backed by [`tools/format_cpp.py`](tools/format_cpp.py), which you can also run directly. |
| 22 | + |
| 23 | +```sh |
| 24 | +python3 tools/format_cpp.py # apply fixes in place |
| 25 | +python3 tools/format_cpp.py --check # exits non-zero if any file would change |
| 26 | +``` |
| 27 | + |
| 28 | +## Running lint locally |
| 29 | + |
| 30 | +Install [`pre-commit`](https://pre-commit.com/), then run `pre-commit install` so the hooks run on every `git commit`. The framework manages each formatter at its pinned version for you. See the [pre-commit docs](https://pre-commit.com/) for everyday usage such as running a single hook or all files. |
| 31 | + |
| 32 | +## Upgrading a formatter |
| 33 | + |
| 34 | +All versions are pinned in [`.pre-commit-config.yaml`](.pre-commit-config.yaml), which is the only file you change to upgrade a formatter: |
| 35 | + |
| 36 | +- For most hooks, bump the `rev:` field. |
| 37 | +- For local hooks, bump the version pin in `additional_dependencies:` (for example `meson==X.Y.Z` or `clang-format==X.Y.Z`). |
| 38 | + |
| 39 | +CI reinstalls from the new pin on the next run. |
0 commit comments