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 build --no-summary option not working #5828

Closed
asears opened this issue Feb 1, 2022 · 2 comments · Fixed by #5980
Closed

Bicep build --no-summary option not working #5828

asears opened this issue Feb 1, 2022 · 2 comments · Fixed by #5980
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@asears
Copy link

asears commented Feb 1, 2022

Bicep version

 bicep --help
Bicep CLI version 0.4.1124 (66c84c8ee5)

Usage:
  bicep build [options] <file>
    Builds a .bicep file.

    Arguments:
      <file>        The input file

    Options:
      --outdir <dir>    Saves the output at the specified directory.
      --outfile <file>  Saves the output as the specified file path.
      --no-summary      Omits the summary at the end of the build.
      --stdout          Prints the output to stdout.
      --no-restore      Builds the bicep file without restoring external modules.

    Examples:
      bicep build file.bicep
      bicep build file.bicep --stdout
      bicep build file.bicep --no-summary
      bicep build file.bicep --outdir dir1
      bicep build file.bicep --outfile file.json
      bicep build file.bicep --no-restore

Describe the bug
no summary parameter unavailable.

On the flipside, is it possible to build the templates and provide just a text summary or Test Results compatible file for a DevOps build?
It would be useful to see a summary (similar to flake8 or pytest) on the console, and publish test results to a build.
No need to see the json detail in the build if performing verifications.

To Reproduce

Get-ChildItem -Path . -Include "*.bicep" -r | foreach { bicep build $_.FullName --no-summary }
Unrecognized parameter "--no-summary"
@ghost ghost added the Needs: Triage 🔍 label Feb 1, 2022
@matsest
Copy link
Contributor

matsest commented Feb 1, 2022

I think that feature was removed in #3686

In the case of no errors it does not print any summary.

It should likely be removed from the help text in https://github.com/Azure/bicep/blob/main/src/Bicep.Cli/Commands/RootCommand.cs.
Not quite sure about if this is intended to be introduced again is kept on purpose?

For the second question:

The way the command is implemented it does throw an error code if the build fails and prints out the errors.

You could do something like:

$biceps = Get-ChildItem -Path . -Include "*.bicep" -r

$errors = 0
$numberOfFiles = $biceps.Length

foreach ($file in $biceps) {
  $fileName = $file.Name
  Write-Host "`n-------- Processing $fileName..."

  bicep build $file.FullName
  if ($LASTEXITCODE -ne 0) {
    Write-Warning "Compiling $fileName failed"
    $errors += 1
  }
}

Write-Host "`n-------- Summary"
Write-Host "Number of files:`t $numberOfFiles"
Write-Host "Successful builds:`t $($numberOfFiles - $errors)"
Write-Host "Failed builds:`t`t $errors"

if ($errors -gt 0){
  exit 1
}

matsest pushed a commit to matsest/bicep that referenced this issue Feb 1, 2022
@alex-frankel alex-frankel added the bug Something isn't working label Feb 2, 2022
@alex-frankel alex-frankel added this to the Committed Backlog milestone Feb 3, 2022
@alex-frankel alex-frankel added good first issue Good for newcomers and removed Needs: Triage 🔍 labels Feb 3, 2022
@asears
Copy link
Author

asears commented Feb 3, 2022

This seems like a great extension possibility for Devops. Thanks for the script!

matsest pushed a commit to matsest/bicep that referenced this issue Feb 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators May 25, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants