Skip to content
Merged
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
13 changes: 7 additions & 6 deletions pre_commit_hooks/shellcheck_run_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ def do_shellcheck(
test_pipeline = pkg["test"].get("pipeline", [])
pipelines.extend(test_pipeline)
name = melange_cfg["package"]["name"]
all_run_files = []
all_steps = []
with contextlib.ExitStack() as stack:
for step in pipelines:
if "runs" not in step.keys():
continue
all_run_files.extend(
[
all_steps.append(
(
step,
stack.enter_context(
tempfile.NamedTemporaryFile(
mode="w",
Expand All @@ -65,15 +66,15 @@ def do_shellcheck(
delete_on_close=False,
),
),
],
),
)
for shfile in all_run_files:
for step, shfile in all_steps:
shfile.write(step["runs"])
shfile.close()
subprocess.check_call(
["/usr/bin/shellcheck"]
+ ["--shell=busybox", "--"]
+ [os.path.basename(f.name) for f in all_run_files],
+ [os.path.basename(f.name) for _, f in all_steps],
cwd=os.getcwd(),
)

Expand Down
Loading