check_makefile_targets¶
rhiza_hooks.check_makefile_targets
¶
Check that Makefile contains expected targets for rhiza projects.
A catch-all rule satisfies every recommended target at once. Since rhiza v1.4.0 the
root Makefile is a rhiza-task shim that defines only help and forwards every
other goal through %:, so make test works with no test: rule in sight;
reporting fmt, install and test missing there is a false report on a
Makefile that is correct, and under --strict it blocks the commit. The rule is
applied by :meth:rhiza_hooks._makefile.MakefileTargets.defines, shared with
check-workflow-make-targets so the two agree on what "defined" means.
check_makefile(filepath, recommended=RECOMMENDED_TARGETS)
¶
Check a Makefile for recommended targets.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filepath
|
Path
|
Path to the Makefile |
required |
recommended
|
set[str]
|
Target names that must be present (defaults to RECOMMENDED_TARGETS) |
RECOMMENDED_TARGETS
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of warning messages (empty if all recommended targets exist) |
Source code in rhiza_hooks/check_makefile_targets.py
main(argv=None)
¶
Main entry point for the hook.
Source code in rhiza_hooks/check_makefile_targets.py
resolve_recommended_targets(targets, extra_targets)
¶
Build the effective set of required targets from the CLI options.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
targets
|
list[str] | None
|
Values of |
required |
extra_targets
|
list[str] | None
|
Values of |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
The set of target names a Makefile is expected to define. |
With neither option, the built-in defaults apply:
sorted(resolve_recommended_targets(None, None)) ['fmt', 'help', 'install', 'test']
--target replaces them, so a project with its own vocabulary is not
also held to the defaults:
sorted(resolve_recommended_targets(["build"], None)) ['build']
--extend-target adds to whichever set is active:
sorted(resolve_recommended_targets(None, ["deploy"])) ['deploy', 'fmt', 'help', 'install', 'test'] sorted(resolve_recommended_targets(["build"], ["deploy"])) ['build', 'deploy']