Skip to content

Commit

Permalink
add try catch
Browse files Browse the repository at this point in the history
Signed-off-by: sk593 <[email protected]>
  • Loading branch information
sk593 committed Aug 12, 2024
1 parent 53adddc commit 561d0ef
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions .github/scripts/validate_bicep.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,31 @@
def validate_file(f):
print(f"Validating {f}...", flush=True)

result = subprocess.run(
[bicep_executable, "build", f, "--stdout"],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
stderr = result.stderr.decode("utf-8")
stdout = result.stdout.decode("utf-8")
print("stdout", flush=True)
print(stdout, flush=True)
print("stderr", flush=True)
print(stderr, flush=True)
exitcode = result.returncode

warning_prefix = "WARNING: The following experimental Bicep features"
if stderr.startswith(warning_prefix) and "Error" not in stderr:
stderr = ""
exitcode = 0
try:
result = subprocess.run(
[bicep_executable, "build", f, "--stdout"],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
)
stderr = result.stderr.decode("utf-8")
stdout = result.stdout.decode("utf-8")
print("Stdout", flush=True)
print(stdout, flush=True)
print("Stderr", flush=True)
print(stderr, flush=True)
exitcode = result.returncode

warning_prefix = "WARNING: The following experimental Bicep features"
if stderr.startswith(warning_prefix) and "Error" not in stderr:
stderr = ""
exitcode = 0

if exitcode != 0:
if exitcode != 0:
failures.append(f)
print(stderr, flush=True)
except subprocess.CalledProcessError as e:
print(f"Subprocess error: {e}", flush=True)
failures.append(f)
print(stderr, flush=True)

with concurrent.futures.ThreadPoolExecutor(max_workers=num_workers) as executor:
futures = [executor.submit(validate_file, f) for f in files]
Expand Down

0 comments on commit 561d0ef

Please sign in to comment.