Skip to content
Merged
Changes from 2 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
53 changes: 40 additions & 13 deletions pre_commit_hooks/shellcheck_run_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,47 @@ def main(argv: Sequence[str] | None = None) -> int:
"w",
delete_on_close=False,
) as compiled_out:
subprocess.check_call(
[
"docker",
"run",
f"--volume={os.getcwd()}:/work",
"--rm",
MelangeImage,
"compile",
f"--arch={os.uname().machine}",
"--pipeline-dir=./pipelines",
filename,
],
stdout=compiled_out,
# Try multiple architectures
architectures = list(
dict.fromkeys([os.uname().machine, "x86_64", "aarch64"]),
)
compilation_succeeded = False

for i, arch in enumerate(architectures):
try:
subprocess.run(
[
"docker",
"run",
f"--volume={os.getcwd()}:/work",
"--rm",
MelangeImage,
"compile",
f"--arch={arch}",
"--pipeline-dir=./pipelines",
filename,
],
stdout=compiled_out,
stderr=subprocess.PIPE,
check=True,
text=True,
)
compilation_succeeded = True
break # Success, exit the architecture loop
except subprocess.CalledProcessError:
if i < len(architectures) - 1:
# Reset the file for the next attempt
compiled_out.seek(0)
compiled_out.truncate()
continue
else:
# Last architecture failed, propagate the error
raise

if not compilation_succeeded:
fail_cnt += 1
continue

compiled_out.close()
try:
with open(compiled_out.name) as compiled_in:
Expand Down
Loading