diff --git a/.github/scripts/build_agent_setup_bicep.py b/.github/scripts/build_agent_setup_bicep.py index edb285b2..720c1a15 100755 --- a/.github/scripts/build_agent_setup_bicep.py +++ b/.github/scripts/build_agent_setup_bicep.py @@ -1,3 +1,4 @@ +import os import sys from pathlib import Path from azure.cli.core import get_default_cli @@ -26,6 +27,10 @@ def build_bicep_file(bicep_file: Path) -> None: output_file = bicep_file.with_name("azuredeploy.json") print(f"🔹 Building Bicep: {bicep_file} -> {output_file}") + os.environ.update({"AZURE_BICEP_USE_BINARY_FROM_PATH": "false", "AZURE_BICEP_CHECK_VERSION": "false"}) + + # Pin the bicep CLI to minimize pre-commit failures due to modified metadata in files. + run_az_command("bicep", "install", "--version", "v0.33.93") # Run az bicep build using Azure CLI SDK run_az_command("bicep", "build", "--file", str(bicep_file), "--outfile", str(output_file)) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fa4ddd8e..75349b7e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -43,11 +43,10 @@ repos: - id: bicep-build name: Regenerate azuredeploy.json for Agent samples description: "Automatically build Bicep files into azuredeploy.json before commit" - entry: python .github/scripts/build_agent_setup_bicep.py types: [text] files: ^scenarios/Agents/setup/.*\.bicep$ - language: python require_serial: true pass_filenames: true - additional_dependencies: - - azure-cli + entry: python + language: system + args: ["-m", "tox", "-qqq", "run", "-e", "build-agent-bicep", "--"] diff --git a/tox.ini b/tox.ini index 0f434784..6287793d 100644 --- a/tox.ini +++ b/tox.ini @@ -28,3 +28,11 @@ commands = typos {posargs} deps = -r dev-requirements.txt commands = pytest {posargs} + + +[testenv:build-agent-bicep] +deps = + azure-cli +set_env = + AZURE_CONFIG_DIR={env_tmp_dir}/azure +commands = python .github/scripts/build_agent_setup_bicep.py {posargs}