Skip to content

Commit

Permalink
feat: add bicep file linting
Browse files Browse the repository at this point in the history
  • Loading branch information
redhatrises committed Feb 6, 2025
1 parent 4bc8f37 commit 0667b8c
Show file tree
Hide file tree
Showing 2 changed files with 123 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/linting.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Bicep

on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:

jobs:
lint:
name: Linting
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Lint Bicep
run: |
az config unset core.no_color
success="true"
FILES=$(find `pwd` \( -name "*.bicep" -o -name "*.bicepparam" \))
echo -e "🔍 \033[0;36mFiles to lint:"
echo $FILES
for file in $FILES; do
{
echo -e "🎗️ \033[0;36mLinting $file" && az bicep lint --file $file
} || {
success="false"
}
done
if [ "$success" = "false" ]; then
echo "::error::❌ Linting of the Bicep files failed."
exit 1;
fi;
88 changes: 87 additions & 1 deletion bicepconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,94 @@
{
"experimentalFeaturesEnabled": {
"extensibility": true
"extensibility": true
},
"extensions": {
"microsoftGraphV1": "br:mcr.microsoft.com/bicep/extensions/microsoftgraph/v1.0:0.1.8-preview"
},
"analyzers": {
"core": {
"enabled": true,
"verbose": false,
"rules": {
"adminusername-should-not-be-literal": {
"level": "error"
},
"artifacts-parameters": {
"level": "error"
},
"explicit-values-for-loc-params": {
"level": "error"
},
"no-hardcoded-env-urls": {
"level": "error"
},
"no-hardcoded-location": {
"level": "error"
},
"no-unnecessary-dependson": {
"level": "error"
},
"no-loc-expr-outside-params": {
"level": "error"
},
"no-unused-existing-resources": {
"level": "error"
},
"no-unused-params": {
"level": "error"
},
"no-unused-vars": {
"level": "error"
},
"max-outputs": {
"level": "error"
},
"max-params": {
"level": "error"
},
"max-resources": {
"level": "error"
},
"max-variables": {
"level": "error"
},
"outputs-should-not-contain-secrets": {
"level": "error"
},
"prefer-interpolation": {
"level": "error"
},
"protect-commandtoexecute-secrets": {
"level": "error"
},
"prefer-unquoted-property-names": {
"level": "error"
},
"use-stable-vm-image": {
"level": "error"
},
"use-recent-api-versions": {
"level": "warn"
},
"use-resource-id-functions": {
"level": "error"
},
"use-stable-resource-identifiers": {
"level": "error"
},
"secure-parameter-default": {
"level": "error"
},
"secure-params-in-nested-deploy": {
"level": "error"
},
"secure-secrets-in-params": {
"level": "error"
},
"simplify-interpolation": {
"level": "error"
}
}
}
}
}

0 comments on commit 0667b8c

Please sign in to comment.