Skip to content

Commit

Permalink
Update validate bicep workflow (#1736)
Browse files Browse the repository at this point in the history
* update validate bicep to print warnings

Signed-off-by: sk593 <[email protected]>

* update biceps

Signed-off-by: sk593 <[email protected]>

---------

Signed-off-by: sk593 <[email protected]>
  • Loading branch information
sk593 authored Sep 6, 2024
1 parent 81006a7 commit c3b967b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 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
2 changes: 1 addition & 1 deletion samples/eshop-dapr/infra/dapr-state-store.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ resource daprStateStore 'Applications.Dapr/stateStores@2023-10-01-preview' = {
version: 'v1'
metadata: {
url: cosmosAccount.properties.documentEndpoint
masterKey: listKeys(cosmosAccount.id, cosmosAccount.apiVersion).primaryMasterKey
masterKey: cosmosAccount.listKeys().primaryMasterKey
database: cosmosDbName
collection: cosmosDbCollectionName
actorStateStore: 'true'
Expand Down
1 change: 1 addition & 0 deletions samples/eshop/infra/infra.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -113,4 +113,5 @@ output rabbitmq string = rabbitmq.name
output servicebus string = servicebus.name

@description('Event Bus connection string')
#disable-next-line outputs-should-not-contain-secrets
output eventBusConnectionString string = (AZURESERVICEBUSENABLED == 'True') ? servicebus.listSecrets().connectionString : rabbitmq.properties.host

0 comments on commit c3b967b

Please sign in to comment.