-
-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Bicep Linter #1898
Merged
Merged
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
b527ed5
Add Bicep to ARM descriptor
omusavi 975fb0e
Add test cases
omusavi 827f15d
Update changelog
omusavi 666eb0d
Add version regex
omusavi 44e7a1c
Remove unnecessary class
omusavi b5a7974
Fix test extension
omusavi 91020a8
generated changes
omusavi 75ed178
Fix missing '\' in Dockerfile
omusavi 8959404
Generated fixes
omusavi 6a1cbc5
Merge branch 'main' into bicep-linter
omusavi 9aa6b92
Simplify bicep tests
omusavi c83f946
Remove sudo from Dockerfile
omusavi f93c820
Add bicepconfig file to cspell ignore
omusavi bb6a0bc
Download file to bicep filename
omusavi c7b3aa1
Merge branch 'main' into bicep-linter
omusavi 4d11c00
Update Bicep CLI command
omusavi 3dd61cb
Quote version regex to avoid escapes and set extra args to array
omusavi 76f455d
missing escape
omusavi 0966221
Set file extensions at linter level
omusavi 04470cc
Merge branch 'main' into bicep-linter
omusavi 53f0e44
Move file_container_regex to ArmLinter block
omusavi 2b340f6
Extract bicep linter into its own descriptor
omusavi 63d941f
Generated files
omusavi c191ef2
Move test files and create a bicepconfig file
omusavi 717da99
Merge branch 'main' into bicep-linter
omusavi f158435
Remove old test file and set cli_executable
omusavi 0779704
Remove config_file_name as there is no configurable flag in the bicep…
omusavi d71593c
Add additional metadata
omusavi 718dfdf
Missing regex field
omusavi 45e4799
Simplify regex
omusavi 331c5cd
Merge branch 'main' into bicep-linter
nvuillam 60d3a62
Add more errors to bicep-bad
nvuillam File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
@description('Web app name.') | ||
@minLength(2) | ||
param webAppName string = 'webApp-${uniqueString(resourceGroup().id)}' | ||
|
||
@description('Location for all resources.') | ||
param location string = resourceGroup().location | ||
|
||
@description('Describes plan\'s pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/') | ||
@allowed([ | ||
'F1' | ||
'D1' | ||
'B1' | ||
'B2' | ||
'B3' | ||
'S1' | ||
'S2' | ||
'S3' | ||
'P1' | ||
'P2' | ||
'P3' | ||
'P4' | ||
]) | ||
param sku string = 'F1' | ||
|
||
@description('The language stack of the app.') | ||
@allowed([ | ||
'.net' | ||
'php' | ||
'node' | ||
'html' | ||
]) | ||
param language string = '.net' | ||
|
||
@description('Optional Git Repo URL, if empty a \'hello world\' app will be deploy from the Azure-Samples repo') | ||
param repoUrl string = '' | ||
|
||
var unusedVarThatShouldError = '' | ||
var appServicePlanName = 'AppServicePlan-${webAppName}' | ||
var gitRepoReference = { | ||
'.net': 'https://github.com/Azure-Samples/app-service-web-dotnet-get-started' | ||
node: 'https://github.com/Azure-Samples/nodejs-docs-hello-world' | ||
php: 'https://github.com/Azure-Samples/php-docs-hello-world' | ||
html: 'https://github.com/Azure-Samples/html-docs-hello-world' | ||
} | ||
var gitRepoUrl = (empty(repoUrl) ? gitRepoReference[language] : repoUrl) | ||
var configReference = { | ||
'.net': { | ||
comments: '.Net app. No additional configuration needed.' | ||
} | ||
html: { | ||
comments: 'HTML app. No additional configuration needed.' | ||
} | ||
php: { | ||
phpVersion: '7.4' | ||
} | ||
node: { | ||
appSettings: [ | ||
{ | ||
name: 'WEBSITE_NODE_DEFAULT_VERSION' | ||
value: '12.15.0' | ||
} | ||
] | ||
} | ||
} | ||
|
||
resource asp 'Microsoft.Web/serverfarms@2021-03-01' = { | ||
name: appServicePlanName | ||
location: location | ||
sku: { | ||
name: sku | ||
} | ||
} | ||
|
||
resource webApp 'Microsoft.Web/sites@2021-03-01' = { | ||
name: webAppName | ||
location: location | ||
identity: { | ||
type: 'SystemAssigned' | ||
} | ||
properties: { | ||
siteConfig: union(configReference[language],{ | ||
minTlsVersion: '1.2' | ||
scmMinTlsVersion: '1.2' | ||
ftpsState: 'FtpsOnly' | ||
}) | ||
serverFarmId: asp.id | ||
httpsOnly: true | ||
} | ||
} | ||
|
||
resource gitsource 'Microsoft.Web/sites/sourcecontrols@2021-03-01' = { | ||
parent: webApp | ||
name: 'web' | ||
properties: { | ||
repoUrl: gitRepoUrl | ||
branch: 'master' | ||
isManualIntegration: true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
@description('Web app name.') | ||
@minLength(2) | ||
param webAppName string = 'webApp-${uniqueString(resourceGroup().id)}' | ||
|
||
@description('Location for all resources.') | ||
param location string = resourceGroup().location | ||
|
||
@description('Describes plan\'s pricing tier and instance size. Check details at https://azure.microsoft.com/en-us/pricing/details/app-service/') | ||
@allowed([ | ||
'F1' | ||
'D1' | ||
'B1' | ||
'B2' | ||
'B3' | ||
'S1' | ||
'S2' | ||
'S3' | ||
'P1' | ||
'P2' | ||
'P3' | ||
'P4' | ||
]) | ||
param sku string = 'F1' | ||
|
||
@description('The language stack of the app.') | ||
@allowed([ | ||
'.net' | ||
'php' | ||
'node' | ||
'html' | ||
]) | ||
param language string = '.net' | ||
|
||
@description('Optional Git Repo URL, if empty a \'hello world\' app will be deploy from the Azure-Samples repo') | ||
param repoUrl string = '' | ||
|
||
var appServicePlanName = 'AppServicePlan-${webAppName}' | ||
var gitRepoReference = { | ||
'.net': 'https://github.com/Azure-Samples/app-service-web-dotnet-get-started' | ||
node: 'https://github.com/Azure-Samples/nodejs-docs-hello-world' | ||
php: 'https://github.com/Azure-Samples/php-docs-hello-world' | ||
html: 'https://github.com/Azure-Samples/html-docs-hello-world' | ||
} | ||
var gitRepoUrl = (empty(repoUrl) ? gitRepoReference[language] : repoUrl) | ||
var configReference = { | ||
'.net': { | ||
comments: '.Net app. No additional configuration needed.' | ||
} | ||
html: { | ||
comments: 'HTML app. No additional configuration needed.' | ||
} | ||
php: { | ||
phpVersion: '7.4' | ||
} | ||
node: { | ||
appSettings: [ | ||
{ | ||
name: 'WEBSITE_NODE_DEFAULT_VERSION' | ||
value: '12.15.0' | ||
} | ||
] | ||
} | ||
} | ||
|
||
resource asp 'Microsoft.Web/serverfarms@2021-03-01' = { | ||
name: appServicePlanName | ||
location: location | ||
sku: { | ||
name: sku | ||
} | ||
} | ||
|
||
resource webApp 'Microsoft.Web/sites@2021-03-01' = { | ||
name: webAppName | ||
location: location | ||
identity: { | ||
type: 'SystemAssigned' | ||
} | ||
properties: { | ||
siteConfig: union(configReference[language],{ | ||
minTlsVersion: '1.2' | ||
scmMinTlsVersion: '1.2' | ||
ftpsState: 'FtpsOnly' | ||
}) | ||
serverFarmId: asp.id | ||
httpsOnly: true | ||
} | ||
} | ||
|
||
resource gitsource 'Microsoft.Web/sites/sourcecontrols@2021-03-01' = { | ||
parent: webApp | ||
name: 'web' | ||
properties: { | ||
repoUrl: gitRepoUrl | ||
branch: 'master' | ||
isManualIntegration: true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"analyzers": { | ||
"core": { | ||
"enabled": true, | ||
"verbose": true, | ||
"rules": { | ||
"no-unused-vars": { | ||
"level": "error" | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -411,6 +411,7 @@ | |
"bestpractices", | ||
"bfseries", | ||
"bibitem", | ||
"bicepconfig", | ||
"bigskip", | ||
"bikeshedding", | ||
"bmod", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
descriptor_id: BICEP | ||
descriptor_type: tooling_format | ||
descriptor_flavors: | ||
- dotnet | ||
linters: | ||
- cli_help_arg_name: --help | ||
cli_executable: bicep | ||
cli_lint_errors_count: "\\.bicep\\(\\d+,\\d+\\) : Error " | ||
cli_lint_extra_args: | ||
- "build" | ||
cli_lint_mode: file | ||
cli_version_arg_name: --version | ||
file_extensions: | ||
- ".bicep" | ||
linter_image_url: https://raw.githubusercontent.com/Azure/bicep/main/docs/images/BicepLogoImage.png | ||
linter_name: bicep_linter | ||
linter_text: | | ||
By default, Bicep linter errors are set as warnings. To customize linter settings, | ||
use a `bicepconfig.json` file. For more information, see the [documentation for the Bicep Linter](https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-config-linter#customize-linter) | ||
linter_repo: https://github.com/Azure/bicep | ||
linter_rules_configuration_url: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-config | ||
linter_rules_inline_disable_url: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/linter#silencing-false-positives | ||
linter_rules_url: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/linter#default-rules | ||
linter_url: https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/linter | ||
version_extract_regex: "Bicep CLI version (\\d+)\\.(\\d+)\\.(\\d+)" | ||
examples: | ||
- | | ||
# Bicep CLI | ||
bicep build infra.bicep; | ||
|
||
# Azure CLI | ||
az bicep build -f infra.bicep | ||
install: | ||
dockerfile: | ||
- ARG BICEP_EXE='bicep' | ||
- ARG BICEP_URI='https://github.com/Azure/bicep/releases/latest/download/bicep-linux-musl-x64' | ||
- ARG BICEP_DIR='/usr/local/bin' | ||
- | | ||
RUN curl --retry 5 --retry-delay 5 -sLo ${BICEP_EXE} "${BICEP_URI}" \ | ||
&& chmod +x "${BICEP_EXE}" \ | ||
&& mv "${BICEP_EXE}" "${BICEP_DIR}" | ||
ide: | ||
vscode: | ||
- name: VSCode Bicep | ||
url: https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-bicep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
megalinter/tests/test_megalinter/linters/bicep_bicep_linter_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# !/usr/bin/env python3 | ||
""" | ||
Unit tests for BICEP linter bicep_linter | ||
This class has been automatically @generated by .automation/build.py, please do not update it manually | ||
""" | ||
|
||
from unittest import TestCase | ||
|
||
from megalinter.tests.test_megalinter.LinterTestRoot import LinterTestRoot | ||
|
||
|
||
class bicep_bicep_linter_test(TestCase, LinterTestRoot): | ||
descriptor_id = "BICEP" | ||
linter_name = "bicep_linter" |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the properties are cli_lint_errors_count and cli_lint_errors_regex :)
megalinter/megalinter/descriptors/javascript.megalinter-descriptor.yml
Line 49 in 43e2810
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cli_lint_error_count can be