From 399c36351c119bb93537e095c3773edff796c775 Mon Sep 17 00:00:00 2001 From: Justin Vreeland Date: Fri, 17 Jul 2026 13:40:47 -0700 Subject: [PATCH] fix: pass per-repo pipeline dirs to melange compile in shellcheck hook The shellcheck-run-steps hook hardcoded a single --pipeline-dir flag derived from the file's parent directory. This fails for packages in enterprise-packages/ and extra-packages/ that reference pipelines from other tiers (e.g. pipelines/py/pip-vendor-bump.yaml). Add a PIPELINE_DIRS mapping matching stereo's dirToPipelineDirs so each package tier gets the correct set of --pipeline-dir flags passed to melange compile. Fixes OS-2428 --- pre_commit_hooks/shellcheck_run_steps.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/pre_commit_hooks/shellcheck_run_steps.py b/pre_commit_hooks/shellcheck_run_steps.py index 0affc3b..32d4842 100644 --- a/pre_commit_hooks/shellcheck_run_steps.py +++ b/pre_commit_hooks/shellcheck_run_steps.py @@ -19,6 +19,27 @@ # 0.31.6 pinning to resolve var-transforms linting error MelangeImage = "cgr.dev/chainguard/melange:latest" +# Pipeline directories per package tier, matching stereo's dirToPipelineDirs. +# Paths are relative to the repo root (the Docker /work mount). +PIPELINE_DIRS: dict[str, list[str]] = { + "os/": ["./os/pipelines/"], + "extra-packages/": ["./extra-packages/pipelines/", "./pipelines/os"], + "enterprise-packages/": [ + "./enterprise-packages/pipelines/", + "./pipelines/", + "./pipelines/os", + ], +} + + +def _pipeline_dirs_for(filename: str) -> list[str]: + """Return the --pipeline-dir flags appropriate for *filename*.""" + for prefix, dirs in PIPELINE_DIRS.items(): + if filename.startswith(prefix): + return [f"--pipeline-dir={d}" for d in dirs] + # Fallback: derive from the file's own directory (original behaviour). + return [f"--pipeline-dir=./{os.path.dirname(filename)}/pipelines"] + # Returns False if shellcheck reports issues def do_shellcheck( @@ -122,7 +143,7 @@ def main(argv: Sequence[str] | None = None) -> int: MelangeImage, "compile", f"--arch={arch}", - f"--pipeline-dir=./{os.path.dirname(filename)}/pipelines", + *_pipeline_dirs_for(filename), filename, ], stdout=compiled_out,