From ace5667a2934e4b2ab646c549aabb2799abf9e23 Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 20 Jan 2024 12:35:45 +0000 Subject: [PATCH 1/7] Support script on Windows Support the AoT compatibility script being run locally on Windows. --- build/test-aot-compatibility.ps1 | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/build/test-aot-compatibility.ps1 b/build/test-aot-compatibility.ps1 index ff400b667b..09cf3c5ad4 100644 --- a/build/test-aot-compatibility.ps1 +++ b/build/test-aot-compatibility.ps1 @@ -1,7 +1,10 @@ param([string]$targetNetFramework) +$runtime = $IsWindows ? "win-x64" : "linux-x64" +$app = $IsWindows ? "./OpenTelemetry.AotCompatibility.TestApp.exe" : "./OpenTelemetry.AotCompatibility.TestApp" + $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 $actualWarningCount = 0 @@ -17,10 +20,10 @@ foreach ($line in $($publishOutput -split "`r`n")) Write-Host "Actual warning count is:", $actualWarningCount $expectedWarningCount = 0 -pushd $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/linux-x64 +pushd $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/$runtime Write-Host "Executing test App..." -./OpenTelemetry.AotCompatibility.TestApp +$app Write-Host "Finished executing test App" if ($LastExitCode -ne 0) From 34926f4326a3359351ac23b86e34bfcbb73112ce Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 20 Jan 2024 12:41:16 +0000 Subject: [PATCH 2/7] Validate AoT on macOS .NET 8 supports native AoT publishing on macOS. --- .../OpenTelemetry.AotCompatibility.TestApp.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj b/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj index 7c7ca3a5dc..f982a95588 100644 --- a/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj +++ b/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj @@ -3,7 +3,7 @@ Exe net8.0 - true + true false true @@ -11,7 +11,7 @@ From a411d77891d7d3bbe5ef1556cc53af1da3e0c6a0 Mon Sep 17 00:00:00 2001 From: martincostello Date: Sat, 20 Jan 2024 12:43:29 +0000 Subject: [PATCH 3/7] Fix AoT test script false negatives - Script did not fail for errors, only warnings. - Script did not fail if publishing failed. --- build/test-aot-compatibility.ps1 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/build/test-aot-compatibility.ps1 b/build/test-aot-compatibility.ps1 index 09cf3c5ad4..821f4dc314 100644 --- a/build/test-aot-compatibility.ps1 +++ b/build/test-aot-compatibility.ps1 @@ -10,7 +10,7 @@ $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*")) { Write-Host $line $actualWarningCount += 1 @@ -20,6 +20,11 @@ foreach ($line in $($publishOutput -split "`r`n")) Write-Host "Actual warning count is:", $actualWarningCount $expectedWarningCount = 0 +if ($LastExitCode -ne 0) +{ + Write-Host "There was an error while publishing AotCompatibility Test App. LastExitCode is:", $LastExitCode +} + pushd $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/$runtime Write-Host "Executing test App..." From e6e5bd97c41acdad44eaa33e343bb8b5d152a624 Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 23 Jan 2024 10:03:14 +0000 Subject: [PATCH 4/7] Show publish output If publish fails, show why. --- build/test-aot-compatibility.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/build/test-aot-compatibility.ps1 b/build/test-aot-compatibility.ps1 index 821f4dc314..4a5d6cb941 100644 --- a/build/test-aot-compatibility.ps1 +++ b/build/test-aot-compatibility.ps1 @@ -23,6 +23,7 @@ $expectedWarningCount = 0 if ($LastExitCode -ne 0) { Write-Host "There was an error while publishing AotCompatibility Test App. LastExitCode is:", $LastExitCode + Write-Host $publishOutput } pushd $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/$runtime From 853516bd5f452d628253a649d0bb882fe431eaa2 Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 23 Jan 2024 10:03:39 +0000 Subject: [PATCH 5/7] Fix lint warnings Use `Push-Location` and `Pop-Location` to resolve PowerShell lint warnings in Visual Studio Code. --- build/test-aot-compatibility.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build/test-aot-compatibility.ps1 b/build/test-aot-compatibility.ps1 index 4a5d6cb941..1f9db2c27a 100644 --- a/build/test-aot-compatibility.ps1 +++ b/build/test-aot-compatibility.ps1 @@ -26,7 +26,7 @@ if ($LastExitCode -ne 0) Write-Host $publishOutput } -pushd $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/$runtime +Push-Location $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/$runtime Write-Host "Executing test App..." $app @@ -37,7 +37,7 @@ if ($LastExitCode -ne 0) Write-Host "There was an error while executing AotCompatibility Test App. LastExitCode is:", $LastExitCode } -popd +Pop-Location $testPassed = 0 if ($actualWarningCount -ne $expectedWarningCount) From 05eb22b2242622625ea131636c696d8f19c7e90f Mon Sep 17 00:00:00 2001 From: martincostello Date: Wed, 31 Jan 2024 17:35:29 +0000 Subject: [PATCH 6/7] Address feedback - Remove explicit `--runtime` flag. - Cater for macOS explicitly. --- build/test-aot-compatibility.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build/test-aot-compatibility.ps1 b/build/test-aot-compatibility.ps1 index 1f9db2c27a..5abe054bec 100644 --- a/build/test-aot-compatibility.ps1 +++ b/build/test-aot-compatibility.ps1 @@ -1,10 +1,7 @@ param([string]$targetNetFramework) -$runtime = $IsWindows ? "win-x64" : "linux-x64" -$app = $IsWindows ? "./OpenTelemetry.AotCompatibility.TestApp.exe" : "./OpenTelemetry.AotCompatibility.TestApp" - $rootDirectory = Split-Path $PSScriptRoot -Parent -$publishOutput = dotnet publish $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj --runtime $runtime -nodeReuse:false /p:UseSharedCompilation=false +$publishOutput = dotnet publish $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/OpenTelemetry.AotCompatibility.TestApp.csproj -nodeReuse:false /p:UseSharedCompilation=false $actualWarningCount = 0 @@ -26,6 +23,9 @@ if ($LastExitCode -ne 0) Write-Host $publishOutput } +$runtime = $IsWindows ? "win-x64" : ($IsMacOS ? "macos-x64" : "linux-x64") +$app = $IsWindows ? "./OpenTelemetry.AotCompatibility.TestApp.exe" : "./OpenTelemetry.AotCompatibility.TestApp" + Push-Location $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Release/$targetNetFramework/$runtime Write-Host "Executing test App..." From acc16e467818d7864d6ed7f7ee0775c796ab05a9 Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 1 Feb 2024 10:11:31 +0000 Subject: [PATCH 7/7] Verify native AoT on Windows Add Windows to the matrix for verifying AoT support. --- .github/workflows/verifyaotcompat.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/verifyaotcompat.yml b/.github/workflows/verifyaotcompat.yml index c437c70c9c..1a6cc014c7 100644 --- a/.github/workflows/verifyaotcompat.yml +++ b/.github/workflows/verifyaotcompat.yml @@ -9,7 +9,7 @@ jobs: strategy: fail-fast: false # ensures the entire test matrix is run, even if one permutation fails matrix: - os: [ ubuntu-latest ] + os: [ ubuntu-latest, windows-latest ] version: [ net8.0 ] runs-on: ${{ matrix.os }} @@ -19,4 +19,3 @@ jobs: - name: publish AOT testApp, assert static analysis warning count, and run the app shell: pwsh run: .\build\test-aot-compatibility.ps1 ${{ matrix.version }} -