MicrosoftPremier / VstsExtensions

Documentation and issue tracking for Microsoft Premier Services Visual Studio Team Services Extensions
MIT License
56 stars 14 forks source link

Warning Filters do not seem to screen out specified build warnings #185

Closed ajurry closed 1 year ago

ajurry commented 2 years ago

Describe the context

Describe the problem and expected behavior I'm currently trying to setup the BuildQualityChecks on my current build pipeline, to ignore two specific warnings, but it doesn't seem to work.

My current task is setup like the following, with the bonus entries for debugging issues.

      - task: BuildQualityChecks@8
        displayName: 'Task: Check no build warnings introduced'
        inputs:
          checkWarnings: true
          warningFailOption: 'fixed'
          warningThreshold: 0
          showStatistics: true
          warningFilters: |
            /^.+\[warning\].+(MSB3277).+/i
            /^.+\[warning\].+(MSB3247).+/i
          fallbackOnPRTargetBranch: true

The build job has the following warnings present

2022-06-12T22:03:54.3486440Z ##[warning]e_config Tests\config_json_test.cpp(23,0): Warning XUNIT1: config_json_test::test_reads - 1 == 0
##[warning]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2203,5): Warning MSB3277: ...
##[warning]C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2203,5): Warning MSB3247: ...

The basic output for BuildQualityChecks

Overall total warnings: 3
Overall filtered warnings: 0
[SUCCESS] Warnings policy passed with 0 filtered warning(s) out of 3 total warning(s).
No baseline build for current branch found. Looking for builds on pull request target branch.

In which it has found the three warnings, but seems to say that it succeeded, even though one of the warnings should cause this task to fail. Note, I have added a dummy warning by creating a test that should fail.

Other notes

As a work around, I am planning to just set the warning limit to a specific number of warnings for the time being, which should cause the above task to fail.

If the above is just a small issue on my part, feel free to reply with a possible resolution and I give it a go!

ReneSchumacher commented 2 years ago

Hi @ajurry,

as described here, warning filters are not meant to ignore warnings (maybe we should rename the parameter to warningSelectors). When you add warning filters, you tell the task to only look for warnings matching your filters.

Ignoring warnings is best done with the MSBuild or compiler flags (see here for more information). If you need to suppress your two MSBuild warnings, you can add the parameter /p:NoWarn=MSB3277,MSB3247 to your MSBuild/VSBuild step.

ajurry commented 2 years ago

Ohhh... Thanks for this! I think renaming the parameter sounds like a good idea to me! I clearly just misread the documentation.

You're right that it's best to ignore the warnings at a build level, so I will update that build step. Feel free to close this issue, I am leaving it open incase you want to turn it into a ticket for updating the parameter.

ReneSchumacher commented 1 year ago

Hi @ajurry,

I'm closing this issue now as I have (finally) renamed the parameters in the next version. I'll hopefully be able to release the new version by the end of this week.

Thanks for your feedback!