Skip to content

Commit

Permalink
update validate workflow (#1200)
Browse files Browse the repository at this point in the history
Signed-off-by: sk593 <[email protected]>
  • Loading branch information
sk593 authored Aug 23, 2024
1 parent fad7c64 commit e63efe0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 8 additions & 5 deletions .github/scripts/validate_bicep.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

files = []
failures = []
warnings = []

# Walk the directory tree and find all .bicep files
for root, _, filenames in os.walk("."):
Expand All @@ -46,12 +47,11 @@ def validate_file(f):
stderr = result.stderr.decode("utf-8")
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 "Warning" in stderr:
warnings.append(f)
print(stderr, flush=True)

if exitcode != 0:
if exitcode != 0 or "Error" in stderr:
failures.append(f)
print(stderr, flush=True)

Expand All @@ -62,4 +62,7 @@ def validate_file(f):
for f in failures:
print(f"Failed: {f}", flush=True)

for f in warnings:
print(f"Warning: {f}", flush=True)

exit(len(failures))
4 changes: 2 additions & 2 deletions .github/workflows/validate-bicep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ jobs:
name: Validate Bicep Code
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Setup and verify bicep CLI
run: |
curl -Lo rad-bicep https://github.com/Azure/bicep/releases/latest/download/bicep-linux-x64
chmod +x ./rad-bicep
./rad-bicep --version
- name: Check out repo
uses: actions/checkout@v4
- name: Verify Bicep files
run: python ./.github/scripts/validate_bicep.py
3 changes: 3 additions & 0 deletions bicepconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@
"extensions": {
"radius": "br:biceptypes.azurecr.io/radius:latest",
"aws": "br:biceptypes.azurecr.io/aws:latest"
},
"cloud": {
"credentialPrecedence": [ "Environment" ]
}
}

0 comments on commit e63efe0

Please sign in to comment.