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

Fix native AoT test scripts #1540

Merged
merged 7 commits into from
Feb 5, 2024

Conversation

martincostello
Copy link
Contributor

Changes

  • Support the AoT compatibility script being run locally on Windows.
  • Fix AoT test script not failing for IL compiler errors, only warnings.
  • Fix AoT test script not failing if dotnet publish fails.
  • .NET 8 supports native AoT publishing on macOS, so remove condition.

Found while looking into an app of mine is getting trim warnings from OpenTelemetry.Instrumentation.AWS to see if they were easy to fix.

Copy link

codecov bot commented Jan 20, 2024

Codecov Report

Attention: 51 lines in your changes are missing coverage. Please review.

Comparison is base (71655ce) 73.91% compared to head (b95b8da) 73.37%.
Report is 136 commits behind head on main.

❗ Current head b95b8da differs from pull request most recent head acc16e4. Consider uploading reports for the commit acc16e4 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1540      +/-   ##
==========================================
- Coverage   73.91%   73.37%   -0.55%     
==========================================
  Files         267      256      -11     
  Lines        9615     9457     -158     
==========================================
- Hits         7107     6939     -168     
- Misses       2508     2518      +10     
Flag Coverage Δ
unittests-Exporter.Geneva 58.03% <49.46%> (?)
unittests-Exporter.OneCollector 89.72% <100.00%> (?)
unittests-Extensions 82.75% <100.00%> (?)
unittests-Instrumentation.AspNet 75.66% <ø> (?)
unittests-Instrumentation.EventCounters 75.92% <ø> (?)
unittests-Instrumentation.Owin 85.71% <ø> (?)
unittests-Instrumentation.Process 100.00% <ø> (?)
unittests-Instrumentation.Runtime 100.00% <ø> (?)
unittests-Instrumentation.StackExchangeRedis 71.00% <ø> (?)
unittests-Instrumentation.Wcf 78.47% <ø> (?)
unittests-PersistentStorage 58.80% <ø> (?)
unittests-ResourceDetectors.Azure 80.90% <ø> (?)
unittests-ResourceDetectors.Host 40.00% <ø> (?)
unittests-ResourceDetectors.Process 100.00% <ø> (?)
unittests-ResourceDetectors.ProcessRuntime 76.08% <ø> (?)
unittests-Solution 80.66% <88.57%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
....Exporter.Geneva/GenevaExporterHelperExtensions.cs 100.00% <ø> (+31.81%) ⬆️
...Telemetry.Exporter.Geneva/GenevaExporterOptions.cs 90.00% <ø> (ø)
...OpenTelemetry.Exporter.Geneva/GenevaLogExporter.cs 85.00% <ø> (+7.50%) ⬆️
...lemetry.Exporter.Geneva/GenevaLoggingExtensions.cs 100.00% <ø> (+14.28%) ⬆️
...enTelemetry.Exporter.Geneva/GenevaTraceExporter.cs 82.50% <ø> (+7.50%) ⬆️
...xporter.Geneva/Internal/ConnectionStringBuilder.cs 92.94% <100.00%> (ø)
...ry.Exporter.Geneva/Internal/ExporterEventSource.cs 14.28% <ø> (+9.52%) ⬆️
...eneva/Internal/ReentrantActivityExportProcessor.cs 100.00% <ø> (ø)
...porter.Geneva/Internal/ReentrantExportProcessor.cs 100.00% <ø> (ø)
...ry.Exporter.Geneva/Internal/TableNameSerializer.cs 98.93% <ø> (ø)
... and 91 more

... and 181 files with indirect coverage changes

@Kielek Kielek added the infra Infra work - CI/CD, code coverage, linters label Jan 22, 2024
@martincostello martincostello mentioned this pull request Jan 22, 2024
1 task
@cijothomas
Copy link
Member

@Yun-Ting Could you also review?

$rootDirectory = Split-Path $PSScriptRoot -Parent
$publishOutput = dotnet publish $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj -nodeReuse:false /p:UseSharedCompilation=false
$publishOutput = dotnet publish $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj --runtime $runtime -nodeReuse:false /p:UseSharedCompilation=false
Copy link
Contributor

Choose a reason for hiding this comment

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

You shouldn't need to pass --runtime in. It will be inferred on the platform this code is executing on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was passing it explicitly so it married-up obviously with the output path, as the binary is found later down to run what was compiled, and I thought that made it easier to follow for the casual observer.

Copy link
Contributor

Choose a reason for hiding this comment

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

it married-up obviously with the output path

Following that same logic you would be passing -f $targetNetFramework to publish, because we are using it in the output path. (not that I'm suggesting we actually do that as well).

I'm just of the opinion to not clutter up the command if it doesn't add value. It just adds more things for people to try to understand what this line is doing.


$actualWarningCount = 0

foreach ($line in $($publishOutput -split "`r`n"))
{
if ($line -like "*analysis warning IL*")
if (($line -like "*analysis warning IL*") -or ($line -like "*analysis error IL*"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Under what cases does it emit analysis warning IL vs analysis error IL? Do you need to set "TreatWarningsAsErrors" for this to happen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To be honest, I'm not sure. I was working locally on a project I knew had AoT issues, but the script wasn't flagging any issues. When I manually ran the commands this script was doing, I found the errors.

Copy link
Contributor

Choose a reason for hiding this comment

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

I can get dotnet publish for PublishAot=true to produce "analysis error IL" only on a 9.0 SDK and if TreatWarningsAsErrors=true. So this seems like the a valid change to make (especially if people are using the script as a starting point).

@Yun-Ting
Copy link
Contributor

If the goal of the PR is to support running verifyaotcompat as one of the CI flow on Windows, the below part will need to be updated, too.
https://github.com/open-telemetry/opentelemetry-dotnet/blob/8ca81d4ce29b3550195f55547870c2e5165fcd92/.github/workflows/verifyaotcompat.yml#L14C1-L15C1

That being said, I don't think we'll need to commit the change to the shell file if we are just trying to run the script locally : ).

@martincostello
Copy link
Contributor Author

martincostello commented Jan 31, 2024

No, the goal was just to make the script re-usable locally on a Windows computer.

I found that I couldn't use it while working on several PRs recently to add AoT support for some of the AWS libraries.

People should be able to easily use it to lower the barrier to contribution.

I can also update the test matrix to validate it on Windows as well if that's desired.

@Yun-Ting
Copy link
Contributor

"I can also update the test matrix to validate it on Windows as well if that's desired." -> yes, please.
LGTM once the test matrix got updated. Thanks!

Copy link
Contributor

@eerhardt eerhardt left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

Support the AoT compatibility script being run locally on Windows.
.NET 8 supports native AoT publishing on macOS.
- Script did not fail for errors, only warnings.
- Script did not fail if publishing failed.
If publish fails, show why.
Use `Push-Location` and `Pop-Location` to resolve PowerShell lint warnings in Visual Studio Code.
- Remove explicit `--runtime` flag.
- Cater for macOS explicitly.
Add Windows to the matrix for verifying AoT support.
@Kielek Kielek merged commit 410ddc6 into open-telemetry:main Feb 5, 2024
112 of 113 checks passed
@martincostello martincostello deleted the fix-aot-scripts branch February 5, 2024 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
infra Infra work - CI/CD, code coverage, linters
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants