Macros
Overview
The cikit.macros package provides reusable building blocks for project-specific
CI commands. Macros cover common tasks such as linting, testing, coverage generation,
build execution, Python package distribution, repository packing, report generation,
packaging, and documentation builds.
Run-bound macros operate on a CiRunEnvironment so generated metrics and artifacts
belong to an explicit logical run. Project-specific command modules should primarily
handle command-line arguments and orchestration while reusable tool integration remains
inside the macros.
This guide describes the Python macro API. For command-line usage, see Built-in CI Commands. For developing and registering custom CI commands, see CI Commands.
Dependency Model
cikit intentionally keeps its own runtime dependency set small. Tool-specific dependencies are not installed automatically just because a corresponding macro exists.
Projects must provide the tools required by the macros they use. Depending on the tool, this may mean adding a Python package to the project environment, installing a system executable, or providing a project-specific toolchain.
Macro |
Purpose |
Dependencies |
|---|---|---|
Archive creation |
None |
|
C/C++ static analysis |
clang-tidy, cloc, PyYAML |
|
CMake builds and CTest execution |
CMake >= 3.20, generator, toolchain |
|
Shared CI helpers |
rsync (for directory comparison) |
|
Python and C/C++ coverage reports |
coverage or gcovr with compatible gcov |
|
API documentation generation |
Doxygen |
|
PlatformIO builds |
PlatformIO Core |
|
Python package build and publishing |
build, twine |
|
Python static analysis |
pylint, pylint-gitlab (optional) |
|
Python test execution |
pytest, coverage (optional) |
|
Repository packing and statistics |
Node.js, Repomix |
|
Shared build and test reports |
None |
|
Python linting |
Ruff |
|
Documentation builds |
Sphinx |
Python-based tools can normally be kept in a project dependency group, for example:
[dependency-groups]
dev = [
"ruff>=0.15",
"...",
]
System tools such as CMake, Ninja, Doxygen, clang-tidy, cloc, or rsync should be installed by the development environment or CI image when needed. The Repomix macro also needs Node.js and Repomix; they are not installed by cikit.
Artifacts and cikit Data
Most run-bound macros update the current run data and register generated artifacts. This allows independent pipeline steps to exchange reports and generated outputs without depending on fixed filesystem paths.
Typical artifact types produced by macros include:
badges
timeline charts
JUnit and Cobertura XML reports
lint reports
generated RST pages
HTML report folders
command logs
direct build outputs
distribution and documentation outputs
metadata files such as Repomix statistics
bundles
Artifacts can later be consumed by reporting and Sphinx macros. Run-specific report
helpers only include artifacts associated with the current logical run.
Metrics should be persisted with env.data_set() or env.data_update();
env.data returns a snapshot; modifying it does not persist changes.
For the complete artifact model, see Artifacts. For persistent run data and timeline history, see Cikit Data.
Using Macros from Project Commands
Macros can be used by built-in, installed, or project-local CI commands as well as by other Python scripts. Commands handle argument parsing and orchestration; macros provide reusable implementation. Initialize the appropriate environment with Common Helpers before invoking run-bound macros. For command structure and error handling, see CI Commands.