Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 5 additions & 0 deletions .github/scripts/build_agent_setup_bicep.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import sys
from pathlib import Path
from azure.cli.core import get_default_cli
Expand Down Expand Up @@ -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))
Expand Down
7 changes: 3 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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", "--"]
8 changes: 8 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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}