Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion pre_commit_hooks/shellcheck_run_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
Loading