utils/
utils/ holds contributor and developer tooling: scripts for building, testing, linting, code generation and CI checks.
They are maintenance helpers the project never ships to its users, and user-facing executables live in tools/.
No directory here holds a C project today.
A C tool added here follows the root layout and joins CPP_PROJECTS in utils/lint/check_layout.py.
Content that belongs elsewhere
| Content | Where it goes |
|---|---|
Anything users install or run |
|
The test suites themselves |
|
A script that no contributor, CI job or build step runs |
Nowhere, because it does not belong in the repository. |
The root |
It is an entry point and stays at the root. The tool behind it is |
Contents by subdirectory
| Directory | Purpose |
|---|---|
|
The dependency and build setup tool behind |
|
The build’s CMake helpers:
|
|
Code generators: the version header, the config info and the YAML configuration schema. |
|
The Danger.js checks of pull-request size and hygiene that CI runs. |
|
Documentation tooling: the generator of the bootstrap options page, plus checks of the commands registry and of the getting-started example, with the Python tests of the registry check. |
|
The formatter. |
|
The checks. The layout check enforces the Codebase Layout page.
It fails on an unlisted top-level entry, a missing or extra layout page, a library under The checks write their findings as SARIF with |
|
The test runners: |
Danger.js checks
The repo-checks job of .github/workflows/pr-target-checks.yml runs Danger on every pull request into develop:
npx --prefix utils/danger danger ci --dangerfile utils/danger/dangerfile.ts
It triggers on pull_request_target, so a forked pull request gets comments and statuses through the base-repo token and no forked code runs.
The job holds contents: read, pull-requests: write, issues: write and statuses: write.
The Utility Tests workflow runs the Vitest tests, and .github/workflows/ci-scope-detector.yml reuses the scope classifier of logic.ts to decide which parts of the build matrix run.
The npm commands
Run them from the repository root:
npm --prefix utils/danger ci
npm --prefix utils/danger test
npm --prefix utils/danger run danger:local
npm --prefix utils/danger run danger:scope-map
npm --prefix utils/danger run danger:ci
-
ciinstalls the development dependencies without touching the root. -
testruns the Vitest tests of the rule logic. -
danger:localprints the report forfixtures/sample-pr.json. -
danger:scope-mapprints a JSON map from every tracked file to its scope. -
danger:cineeds a GitHub pull request context, so only the workflow runs it.
The files
The Danger directory holds these files:
| File | Role |
|---|---|
|
The rule logic with no I/O: scope mapping, commit validation, size and hygiene warnings. |
|
Fetches the commits and files and feeds |
|
Renders the report. |
|
The entry point, which stays thin. |
|
Sample pull request payloads for local runs. |
|
The Vitest tests. |
|
A Node setup of their own, so npm never touches the repository root. |
The rules
All the rules live in logic.ts:
| Rule | What it says |
|---|---|
Scopes |
|
Commit types |
|
Commit size |
A commit with more than 2000 lines of source churn gets a note, unless it is a |
Pull request size |
More than 5000 lines of source churn gets a warning. The limit is higher because well-sliced commits can still add up. |
Description length |
The body needs |
Feature pull requests |
One (a |
A rule change edits logic.ts, refreshes fixtures/ when the report changes and passes npm test.
The checks report warnings and notes and never fail the run.
Build integration
The root build adds utils/ first, unconditionally.
utils/CMakeLists.txt adds the subdirectories in this order: codegen, bootstrap, danger, docs, format, lint, testing, cmake.
The first, codegen/, also generates the headers every build needs.
The script directories expose their scripts as custom targets, which anyone can run whether or not tests or docs are on.
Only the CTest tests that these directories register depend on MRDOCS_BUILD_TESTS.
| Directory | Targets and tests |
|---|---|
|
|
|
|
|
The |
|
|
|
|
|
|
|
|
|
No targets. |
check_layout.py and lint.py are not targets either. CI runs lint.py, which runs the layout check, and the lint and check-layout recipes of the generated justfile run them locally.