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

[tests] Enable TreatWarningsAsErrors=true #16766

Merged
merged 3 commits into from Aug 15, 2023

Conversation

pjcollins
Copy link
Member

@pjcollins pjcollins commented Aug 15, 2023

Fixes #16709
Sets TreatWarningsAsErrors to true when building template and sample
projects to ensure that warnings are not missed.

Sets `TreatWarningsAsErrors` to true when building template and sample
projects to ensure that warnings are not missed.
@pjcollins
Copy link
Member Author

/azp run

@Eilon
Copy link
Member

Eilon commented Aug 15, 2023

Yay! ❤️

It would be good to deliberately cause a warning (e.g. change a template/sample to call some obsolete API, or some wacky version) and ensure it causes the type of failure we want to see, and that the failure correctly causes the PR checks to fail. (And then of course revert the warning before merging 😁 )

@pjcollins
Copy link
Member Author

I added a warning case to one of the templates for testing, but am not sure why CI isn't triggering...

@Eilon
Copy link
Member

Eilon commented Aug 15, 2023

I added a warning case to one of the templates for testing, but am not sure why CI isn't triggering...

Maybe CI is just bogged down and needed a minute to recover. Looks like it's woken up now.

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@samhouts samhouts added this to the .NET 8 GA milestone Aug 15, 2023
@pjcollins
Copy link
Member Author

I'll revert the testing changes, looks like this is working as expected:

Screenshot 2023-08-15 at 5 37 12 PM
[ToolRunner] Running: D:\a\_work\1\s\bin\dotnet\dotnet build "D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj" -c Release -t:Pack -p:RestoreNoCache=true -p:RestorePackagesPath=D:\a\_work\_temp\test-intg\packages -p:RestoreConfigFile=D:\a\_work\_temp\test-intg\NuGet.config -p:CustomBeforeMicrosoftCSharpTargets=D:\a\_work\1\s\src\Templates\TemplateTestExtraTargets.targets -p:DisableTransitiveFrameworkReferenceDownloads=true -p:TreatWarningsAsErrors=true -bl:"D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Pack-133366053208885546.binlog"
[ToolRunner] Process 'dotnet' exited with code: 1
MSBuild version 17.5.1+f6fdcf537 for .NET
  Determining projects to restore...
  Restored D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj (in 537 ms).
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-ios]
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-windows10.0.19041.0]
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-maccatalyst]
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-tizen]
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-android]
Build FAILED.
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-ios]
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-windows10.0.19041.0]
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-maccatalyst]
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-tizen]
D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Class1.cs(6,9): error CS0169: The field 'Class1.unused' is never used [D:\a\_work\_temp\test-intg\Buildmauilibnet70ReleaseTrue\Buildmauilibnet70ReleaseTrue.csproj::TargetFramework=net7.0-android]
    0 Warning(s)
    5 Error(s)
Time Elapsed 00:00:07.18


  Failed Build("mauilib","net7.0","Release",True) [7 s]
  Error Message:
     Project Buildmauilibnet70ReleaseTrue.csproj failed to build. Check test output/attachments for errors.
  Expected: True
  But was:  False

  Stack Trace:
     at Microsoft.Maui.IntegrationTests.TemplateTests.Build(String id, String framework, String config, Boolean shouldPack) in D:\a\_work\1\s\src\TestUtils\src\Microsoft.Maui.IntegrationTests\TemplateTests.cs:line 45
   at InvokeStub_TemplateTests.Build(Object, Object, IntPtr*)

1)    at Microsoft.Maui.IntegrationTests.TemplateTests.Build(String id, String framework, String config, Boolean shouldPack) in D:\a\_work\1\s\src\TestUtils\src\Microsoft.Maui.IntegrationTests\TemplateTests.cs:line 45
   at InvokeStub_TemplateTests.Build(Object, Object, IntPtr*)

@pjcollins pjcollins marked this pull request as ready for review August 15, 2023 21:38
@pjcollins pjcollins requested a review from a team as a code owner August 15, 2023 21:38
@Eilon
Copy link
Member

Eilon commented Aug 15, 2023

Do you want to enable auto-merge so this can get merged once it passes CI?

image

@pjcollins pjcollins enabled auto-merge (squash) August 15, 2023 21:54
@Eilon Eilon added the area/infrastructure 🏗️ CI, Maestro / Coherency label Aug 15, 2023
@pjcollins pjcollins merged commit 6fd85a1 into dotnet:main Aug 15, 2023
39 checks passed
@rmarinho
Copy link
Member

Hum... not sure if this will block us of getting stuff merged .. but we will see.

@Eilon
Copy link
Member

Eilon commented Aug 16, 2023

Hum... not sure if this will block us of getting stuff merged .. but we will see.

Yeah I think it's a worthwhile experiment. We'll see if it helps or hinders. But if it hinders a lot, then I think it points to a more serious problem of why we keep getting warnings showing up to begin with.

@pjcollins pjcollins deleted the templates-warn-as-err branch August 16, 2023 18:13
rmarinho pushed a commit that referenced this pull request Aug 19, 2023
Fixes: #16709

Sets `TreatWarningsAsErrors` to true when building template and sample
projects to ensure that warnings are not missed.
@github-actions github-actions bot locked and limited conversation to collaborators Dec 7, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/infrastructure 🏗️ CI, Maestro / Coherency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Testing] Modify our CI Template Tests so that TreatWarningsAsErrors is enabled
5 participants