Skip to content
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

Bicep lint command #10819

Merged
merged 5 commits into from Aug 10, 2023
Merged

Bicep lint command #10819

merged 5 commits into from Aug 10, 2023

Conversation

johan-lindqvist
Copy link
Contributor

@johan-lindqvist johan-lindqvist commented May 25, 2023

Contributing a Pull Request

If you haven't already, read the full contribution guide. The guide may have changed since the last time you read it, so please double-check. Once you are done and ready to submit your PR, run through the relevant checklist below.

Contributing a feature

  • I have opened a new issue for the proposal, or commented on an existing one, and ensured that the Bicep maintainers are good with the design of the feature being implemented
  • I have included "Fixes #{issue_number}" in the PR description, so GitHub can link to the issue and close it when the PR is merged
  • I have appropriate test coverage of my new feature

Fixes #2811

Added new command lint that will return an error exit code when there are any warnings or errors when building the bicep files. The command has a flag --ignore-warnings to only react on errors, not sure if this is needed though since you could use the build command instead.

I also added tests, copied and refactored from build command tests, I could use some feedback if the tests cover enough or there are some missing tests that should be added (that's why I didn't check the test checkbox above).

Checklist/discussion points

  • Do we want the --ignore-warnings flag? Does it serve a purpose?
  • Are there any more tests needed?
  • Support running linter from CLI separately to build #2811 describes different exit codes depending on warnings/errors, is this wanted?
  • Are there any additional flags that are needed for the command?
Microsoft Reviewers: Open in CodeFlow

@johan-lindqvist
Copy link
Contributor Author

@microsoft-github-policy-service agree

@jikuja
Copy link

jikuja commented Jun 18, 2023

Are there any additional flags that are needed for the command?

Comment on lines 125 to 126
Options:
--ignore-warnings Exit code will only consider errors. Warnings will be ignored.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We discussed this today - feedback:

  • The behavior for bicep lint should be consistent with bicep build by default - e.g. warnings should not cause a failure. So that would necessitate inverting the flag (e.g. --warn-as-error instead), and also supporting this for the bicep build command.
  • If it simplifies things, we can merge this PR without the implementation of --warn-as-error, and leave that to be implemented later.

@anthony-c-martin
Copy link
Member

@johan-lindqvist sorry for the long delay responding to this PR. This is great functionality to have. I've discussed this with the team and have shared the feedback in a comment.

Since it's been open for such a long time, I'm happy for you to make the suggested changes yourself, but would also be happy to make them on your behalf - let me know which you'd prefer.

@johan-lindqvist
Copy link
Contributor Author

johan-lindqvist commented Aug 10, 2023

@johan-lindqvist sorry for the long delay responding to this PR. This is great functionality to have. I've discussed this with the team and have shared the feedback in a comment.

Since it's been open for such a long time, I'm happy for you to make the suggested changes yourself, but would also be happy to make them on your behalf - let me know which you'd prefer.

No worries 😄, I won't have time to work on this for two weeks or so. I'm fine with either way, if you have time and want to finish it you're more than welcome to! Otherwise I will fix the feedback once I have some free time in a few weeks.

@anthony-c-martin anthony-c-martin changed the title feat: add lint command Bicep lint command Aug 10, 2023
@anthony-c-martin anthony-c-martin enabled auto-merge (squash) August 10, 2023 18:02
Copy link
Member

@anthony-c-martin anthony-c-martin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@anthony-c-martin anthony-c-martin merged commit 6c3a71d into Azure:main Aug 10, 2023
39 checks passed
StephenWeatherford pushed a commit that referenced this pull request Aug 11, 2023
# Contributing a Pull Request

If you haven't already, read the full [contribution
guide](https://github.com/Azure/bicep/blob/main/CONTRIBUTING.md). The
guide may have changed since the last time you read it, so please
double-check. Once you are done and ready to submit your PR, run through
the relevant checklist below.

## Contributing a feature

* [x] I have opened a new issue for the proposal, or commented on an
existing one, and ensured that the Bicep maintainers are good with the
design of the feature being implemented
* [x] I have included "Fixes #{issue_number}" in the PR description, so
GitHub can link to the issue and close it when the PR is merged
* [ ] I have appropriate test coverage of my new feature

Fixes #2811

Added new command `lint` that will return an error exit code when there
are any warnings or errors when building the bicep files. The command
has a flag `--ignore-warnings` to only react on errors, not sure if this
is needed though since you could use the `build` command instead.

I also added tests, copied and refactored from `build` command tests, I
could use some feedback if the tests cover enough or there are some
missing tests that should be added (that's why I didn't check the test
checkbox above).

## Checklist/discussion points
- [ ] Do we want the `--ignore-warnings` flag? Does it serve a purpose?
- [ ] Are there any more tests needed?
- [ ] #2811 describes different exit codes depending on warnings/errors,
is this wanted?
- [ ] Are there any additional flags that are needed for the command?

###### Microsoft Reviewers: [Open in
CodeFlow](https://portal.fabricbot.ms/api/codeflow?pullrequest=https://github.com/Azure/bicep/pull/10819)

---------

Co-authored-by: Anthony Martin <38542602+anthony-c-martin@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support running linter from CLI separately to build
3 participants