Add check-pipeline-name-only-steps hook - #20
AmberArcadia wants to merge 2 commits into
Conversation
| yaml = ruamel.yaml.YAML(typ="safe") | ||
|
|
||
|
|
||
| def check_pipeline_steps(melange_cfg: dict[str, Any]) -> tuple[bool, list[str]]: |
There was a problem hiding this comment.
melange requires that the main package has a pipeline, so I have created packages with name-only steps. See cuda-stub-meta.yaml in extra-packages as an example. That's likely a melange bug of course, but it's reality today.
This hook validates that pipeline steps in melange YAML files don't have only a 'name' field without 'uses' or other details. This catches a common mistake where 'name' is used instead of 'uses' for pipeline steps. The check covers: - Main pipeline steps - Test pipeline steps - Subpackage pipeline steps - Subpackage test pipeline steps Includes test data files demonstrating both valid and invalid configurations. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- A `pipeline:` key with no value (YAML null) crashed the hook with TypeError; five files on stereo main have one. Every pipeline and test lookup now falls back to an empty list. - The four copies of the same loop collapse into iter_pipelines(), which yields (label, steps) for the main and subpackage build and test pipelines, and iter_steps(), which also descends into nested `pipeline:` lists so a name-only step inside a grouped step is caught. - The message says what to do: use `uses:`, or fold the name into the next step. - test-data/README.md loses the hard-coded home directory path; the bad fixture gains a nested case and the good fixture a null pipeline. - The hook is listed in example.pre-commit-config.yaml. On stereo main today the hook reports 30 steps in 25 files, none of them the `- name: test/go-fips-check` typo it was written for: 3 are placeholder pipelines in meta packages and 27 are `- name:` headings written as their own list item ahead of an anonymous `- runs:` or `- uses:`. melange runs both as no-ops. Those files are fixed in stereo alongside this change.
4037b89 to
ef90f3b
Compare
|
Rebased onto main and pushed ef90f3b: the hook no longer crashes on a null |
What
Adds
check-pipeline-name-only-steps, which fails when a pipeline step consists of nothing but aname:. melange runs such a step as a no-op, so it is either a typo foruses:(- name: test/go-fips-check, the case that prompted this; thanks @OddBloke) or a heading that was meant to sit on the following step.Checked: the main pipeline, the main test pipeline, every subpackage pipeline and test pipeline, and nested
pipeline:lists inside steps.Changes since the first review
pipeline:key with no value (YAML null) crashed the hook withTypeError; five files on stereo main have one. Guarded.iter_pipelines()plusiter_steps(), the shape dannf asked for on Add check-for-go-fips-test pre-commit hook #18. Once both hooks are in I will move the helpers into a shared module; keeping them local for now avoids a cross-PR conflict.uses:, or fold the name into the next step.example.pre-commit-config.yaml;test-data/README.mdno longer carries my home directory path.On "melange requires a main pipeline"
dannf pointed at
cuda-stub-meta.yaml, whose whole pipeline was- name: Without this, subpackages don't build.. That file was renamed tocuda-stub-12.4.yaml(stereo b7e108846e7, 2026-08-05) and its placeholder pipeline had already been removed (stereo 6e8d75f76ab, 2026-05-26). Today thecuda-stub-*.yamlfiles have nopipeline:key at all and build, andvalidatePipelinesin melange'spkg/config/config.goenforces no such requirement. Three placeholders remain on stereo main (eco-python-meta,torchaudio-ffmpeg-tarballs,cuda-toolkit-13.0); the stereo PR below drops them.What the hook finds on stereo main
30 steps in 25 files, none of them the
test/go-fips-checktypo. 3 are the placeholders above; 27 are headings written as their own list item, for exampleenterprise-packages/qdrant.yaml:All 25 files are fixed in chainguard-dev/stereo#362436, so enabling the hook there starts clean.
Test
pre-commit try-repo . check-pipeline-name-only-steps --files test-data/pipeline-name-only-bad.yamlreports five findings (main, main test, subpackage, nested, subpackage test); the good fixture, which includes a nullpipeline:, passes.pre-commit run --all-filesis clean.