Skip to content

Add check-pipeline-name-only-steps hook - #20

Open
AmberArcadia wants to merge 2 commits into
mainfrom
check-pipeline-name-only-steps
Open

AmberArcadia wants to merge 2 commits into
mainfrom
check-pipeline-name-only-steps

Conversation

@AmberArcadia

@AmberArcadia AmberArcadia commented Aug 13, 2025 •

Copy link
Copy Markdown
Member

What

Adds check-pipeline-name-only-steps, which fails when a pipeline step consists of nothing but a name:. melange runs such a step as a no-op, so it is either a typo for uses: (- 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

  • A pipeline: key with no value (YAML null) crashed the hook with TypeError; five files on stereo main have one. Guarded.
  • The four copies of the same loop are now one iter_pipelines() plus iter_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.
  • The message says what to do: use uses:, or fold the name into the next step.
  • Listed in example.pre-commit-config.yaml; test-data/README.md no 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 to cuda-stub-12.4.yaml (stereo b7e108846e7, 2026-08-05) and its placeholder pipeline had already been removed (stereo 6e8d75f76ab, 2026-05-26). Today the cuda-stub-*.yaml files have no pipeline: key at all and build, and validatePipelines in melange's pkg/config/config.go enforces 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-check typo. 3 are the placeholders above; 27 are headings written as their own list item, for example enterprise-packages/qdrant.yaml:

  - name: static-file

  - runs: |
      mkdir -p static

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.yaml reports five findings (main, main test, subpackage, nested, subpackage test); the good fixture, which includes a null pipeline:, passes. pre-commit run --all-files is clean.

yaml = ruamel.yaml.YAML(typ="safe")


def check_pipeline_steps(melange_cfg: dict[str, Any]) -> tuple[bool, list[str]]:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

AmberArcadia and others added 2 commits October 2, 2026 13:38
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.
@AmberArcadia

Copy link
Copy Markdown
Member Author

Rebased onto main and pushed ef90f3b: the hook no longer crashes on a null pipeline:, the four loops are one iterator, nested pipeline: lists are checked, and the test-data README loses my home path. On the placeholder-pipeline concern: cuda-stub-meta.yaml has since lost its placeholder and been renamed, the cuda-stub-*.yaml files have no pipeline: key today, and melange's validatePipelines enforces no requirement. The 25 stereo files the hook does flag are fixed in chainguard-dev/stereo#362436. Details in the updated description. @dannf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants