Overview

devops is a collection of small, focused command line tools used to keep C++ projects consistent: style and license checks on C++ sources, changelog maintenance, and Git tag/version helpers. All tools read shared settings from a single configuration file (devops.toml or .devops.toml), so behavior can be tuned once and reused across every command and CI job.

Feature areas

C++ code quality checks

The cpp subsystem builds a set of rules from the [cpp] configuration and runs them against a project’s C++ sources:

  • Header guards — every .h, .hpp, .tpp and .impl.hpp file must contain a proper #ifndef / #define / #endif guard, with the #define immediately following the #ifndef line (no blank line or comment in between). If header_guards_according_to_filepath is enabled, the guard macro name is also checked against a name derived from the file’s path — each directory and the file stem is converted from camelCase/PascalCase to SNAKE_CASE (e.g. velocityVerlet.hpp expects VELOCITY_VERLET, not VELOCITYVERLET) — using the default __{path}_{ext}__ pattern or a custom one set via header_guard_pattern. Every problem found with a file’s header guard (structural issues and a path-derived name mismatch) is reported together in a single error instead of one at a time across repeated runs.

  • Key sequence order — flags keyword sequences such as static inline constexpr that are written out of the expected order.

  • License headers — verifies that source and header files start with the contents of a configured license header file (see below).

  • AST-based checks (optional, requires pip install devops[ast]) — uses libclang to parse each file and run semantic checks that text-based rules cannot express, such as enforcing canonical parameter names for specific types or banning particular macros. See AST-based C++ checks for the full list and how each one is configured.

Run it with cpp_checks.

Incremental checks

For large codebases, running every check on every file on every commit can be slow. Incremental mode skips files that have not changed since they last passed:

  • After each run, per-file results (pass/fail) and file modification times are persisted to a JSON state file.

  • On the next run, files that passed and whose mtime is unchanged are skipped entirely.

  • Files that failed, were modified, or are new are always re-checked.

  • By default cpp_checks still stops at the first failure (fail-fast), even in incremental mode. Set fail_fast = false in [cpp] (or pass --no-fail-fast) to check every file in one pass and record all results.

Enable via TOML (recommended for CI / permanent projects):

[cpp]
incremental_state_file = "build/.cpp_check_state.json"
# Optional: disable fail-fast to record results for all files in one pass
# fail_fast = false

Add the state file to .gitignore — it is machine-local and should not be committed.

Enable via CLI (one-off or scripting):

cpp_checks --incremental
cpp_checks --incremental --state-file build/.cpp_check_state.json
cpp_checks --incremental --no-fail-fast   # check all files, save full state

--state-file implies --incremental and takes precedence over the TOML setting. When --incremental is used without --state-file, the TOML path is used if configured; otherwise the default path (.devops_cpp_state.json in the current directory) is used.

Checking only changed files

To check just the files a branch or commit range touched (typically in a pull request pipeline), pass a git commit hash or branch name with --base-ref:

cpp_checks --base-ref origin/dev      # files changed on this branch vs dev
cpp_checks --base-ref 8412f24         # files changed since a commit

The comparison is made against the merge-base of the given reference and HEAD, so commits that landed on the base branch after you branched off are not reported. Tracked files with uncommitted (staged or unstaged) changes are included; deleted files and untracked files are not.

--base-ref overrides check_only_staged_files and check_dirs from the [cpp] TOML section. exclude_dirs is still honored, and directories passed explicitly on the command line further restrict the changed files. It can be combined with --incremental and --no-fail-fast. An unknown reference makes cpp_checks exit with an error. In CI, make sure the base reference is available locally (e.g. fetch-depth: 0 for actions/checkout).

License header management

Beyond just checking for a license header, devops can insert one into files that are missing it, one file at a time or recursively across directories. See add_license_header and add_license_headers.

Buggy file filtering

Some C++ codebases need to work around known compiler bugs tied to specific macros. filter_buggy_cpp_files scans a directory tree and prints only the files that do not use any macro listed under exclude.buggy_cpp_macros — useful for scoping a workaround or a build flag to the files that actually need it.

Changelog management

devops maintains CHANGELOG.md files with a simple insertion-marker convention: a ## Next Release heading followed by an <!-- insertion marker --> comment. Running update_changelog inserts a new ## [VERSION](.../releases/tag/VERSION) - YYYY-MM-DD entry right above the marker and moves the marker down, ready for the next release. update_changelogs applies the same update to every path configured under file.changelog_paths at once, which is how this project keeps multiple changelogs (if any) in sync from a single CI step.

Git tag utilities

get_latest_tag and increase_latest_tag parse Git tags as <prefix><major>.<minor>.<patch> and let CI compute the next release version without hand-maintaining it — this is what this project’s own release workflow uses to bump versions on hotfix/* branches.

Release commands

devops_release holds the steps of a release workflow: resolve the version from a release/<tag> or hotfix/<name> branch, check that the tag is still free, wait for green CI on the release commit, then tag it and publish the GitHub release. Every step is safe to re-run, and Git or GitHub errors always stop the release. The CI workflows and the release branch are set in [release].

CLI command reference

All commands are installed as console scripts and read defaults from the configuration file unless overridden on the command line.

cpp_checks

Run the configured C++ style, header guard, and license header checks. Exits with status 1 if any check fails.

cpp_checks --dirs src include
cpp_checks --license-header LICENSE_HEADER.txt

add_license_header

Prepend a license header to a single file if it doesn’t already have one.

add_license_header src/main.cpp LICENSE_HEADER.txt
add_license_header src/main.cpp LICENSE_HEADER.txt --dry-run

add_license_headers

Prepend a license header to every C++ file found under the given directories (current directory if omitted).

add_license_headers LICENSE_HEADER.txt --dirs src include

filter_buggy_cpp_files

Print the C++ files under the given directories that do not contain any macro listed in exclude.buggy_cpp_macros.

filter_buggy_cpp_files --dirs src include

update_changelog

Insert a new version entry into one changelog file.

update_changelog 1.2.0
update_changelog 1.2.0 --changelog-path docs/CHANGELOG.md

update_changelogs

Insert a new version entry into every changelog configured under file.changelog_paths (or a custom set passed explicitly).

update_changelogs 1.2.0
update_changelogs 1.2.0 --changelog-paths CHANGELOG.md docs/CHANGELOG.md

get_latest_tag

Print the latest Git tag, parsed as <prefix><major>.<minor>.<patch>.

get_latest_tag
get_latest_tag --prefix v

increase_latest_tag

Print the next version after bumping the latest Git tag. Exactly one of --major, --minor, or --patch must be given.

increase_latest_tag --patch
increase_latest_tag --major --prefix v

devops_release

Release steps for CI. Errors are printed to stderr and exit with code 1.

devops_release version --head-ref release/v1.2.0 --title Release-1.2.0 --prepare
devops_release version --head-ref hotfix/fix-x --title "Hotfix-1.1.1: fix x" --prepare
devops_release check-refs v1.2.0
devops_release wait-ci MolarVerse/PQ "$GITHUB_SHA"
devops_release publish MolarVerse/PQ v1.2.0
gh api repos/MolarVerse/PQ/releases/generate-notes -f tag_name=v1.2.0 --jq .body \
    | devops_release reviewers MolarVerse/PQ
  • version prints the release tag. A release PR title must be Release-X.Y.Z; a hotfix PR title must start with Hotfix-X.Y.Z. With --prepare it also checks that the tag is new and that a hotfix is the latest tag plus one patch.

  • check-refs fails if the tag or the release/<tag> branch exists.

  • wait-ci waits until the newest push run of every workflow in release.ci_workflows succeeded on that exact commit.

  • publish tags HEAD and creates a stable release with generated notes. A re-run finishes a partial publication; a tag on another commit or a draft release stops it.

  • reviewers prints the human PR authors of release notes read from stdin.

The GitHub token comes from GH_TOKEN or GITHUB_TOKEN, and the API URL from GITHUB_API_URL.

generate_toml_template

Write devops.toml.template to the current directory: every configuration key, commented out, set to its default value. See Configuration File for what each key does.

generate_toml_template