-
-
Notifications
You must be signed in to change notification settings - Fork 238
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
Conversation
1139ddf
to
bbe1f4d
Compare
bbe1f4d
to
bb6a0bc
Compare
@omusavi i think you also need to put a level lower the [Filters] {'name': 'ARM_BICEP_LINTER', 'filter_regex_include': None, 'filter_regex_exclude': None, 'files_sub_directory': None, 'lint_all_files': False, 'lint_all_other_linters_files': False, 'file_extensions': ['.bicep'], 'file_names_regex': [], 'file_names_not_ends_with': [], 'file_contains_regex': ['schema\.management\.azure\.com']} |
@omusavi you're really close, your "bad" example only triggers a warning, so the linter returns 0 as exit code |
@nvuillam thanks for helping out with the debugging! Taking a look now... |
@nvuillam actually have a question about how other linters have gotten around this... Turns out that the CLI does not put out a non-zero exit code (nor does it have a flag for it). I will be submitting feedback to hopefully update that in the future, but for now this is what we have. There is a way for people to specifically add a config file to the folder and the linter should pick that up, however since by default everything is a warning, people would need to know to set everything to errors in that config file. Do you recommend doing something like using If we go with the latter option, is it ok to check in a Thanks! |
@omusavi is it possible to use an argument explaining where to find this bicepconfig file ? In lots of cases, MegaLinter provides a default configuration file (all files in this folder are just here for that -> https://github.com/oxsecurity/megalinter/tree/main/TEMPLATES ) The behaviour is the following:
|
@nvuillam There is no flag to point to the bicepconfig file (more feedback for the bicep linter team....), it will pick up whatever file is "closest" to the bicep files. In my testing just now, that seems to mean either co-located with the files, or any folder in the tree above the bicep files under test. In this case, if there is a default one provided in the TEMPLATES folder, I am assuming that will not be present in a root directory of the workspace? edit: Found this issue in the bicep github page: Azure/bicep#5013 |
In that case I think you can create the following structure (test classes will detect good and bad folders )
the _2 files are in case bicep can handle multiple files in one call ( else just put the _1 files ) You also need to define |
Sounds good, will update with those changes |
@nvuillam looks like our change to move I guess at this point might make sense to create a new descriptor file for Bicep - even though its very closely related to ARM, they have different file formats so a lot of the shared things dont really match up. Will update that in addition to the test fixes... |
I probably forgot to take in account file_contains_regex at lower level ^^ |
Codecov Report
@@ Coverage Diff @@
## main #1898 +/- ##
==========================================
+ Coverage 82.00% 82.71% +0.71%
==========================================
Files 156 157 +1
Lines 3378 3384 +6
==========================================
+ Hits 2770 2799 +29
+ Misses 608 585 -23
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
@omusavi it seems that you finally did it ,congrats 😄 Last updates you (optionally) may perform before removing the "draft" statut of the PR:
|
|
@nvuillam unfortunately no SARIF output, I think this is something we can create an issue about in the bicep repo. Other settings added! Thanks for all your help, this was quite a journey :D |
@@ -5,18 +5,23 @@ descriptor_flavors: | |||
linters: | |||
- cli_help_arg_name: --help | |||
cli_executable: bicep | |||
cli_lint_mode: file | |||
cli_lint_errors_count: "\\.bicep\\(\\d+,\\d+\\) : Error " |
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 :)
cli_lint_errors_count: regex_sum |
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
- regex_sum ( sum all the numbers found by regex in logs)
- regex_number (find a single number with regex in logs)
- regex_count (count the number of times the regex is matched in the log)
When there are error count regex, the test classes passes after >= 2 errors, just to make sure it can count 😁 I really think this is the last update I'll ask ^^ |
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.
Once CI it's ok it's all good, thanks a lot for your contribution :)
( @omusavi i allowed myself to add a last commit so bicep linter can be in today's planned released :) )
Thanks @nvuillam! Glad we got this in! |
Bicep is a domain-specific language similar to HCL that allows for deploying Azure resources. The Bicep Linter validates Bicep files prior to them being transpiled to JSON.
This change aims to add the Bicep Linter to MegaLinter.
Fixes #1017
Proposed Changes
Readiness Checklist
Author/Contributor
Reviewing Maintainer
breaking
if this is a large fundamental changeautomation
,bug
,documentation
,enhancement
,infrastructure
, orperformance