diff --git a/.github/workflows/aot-check.yml b/.github/workflows/aot-check.yml new file mode 100644 index 0000000000..b9f684dca1 --- /dev/null +++ b/.github/workflows/aot-check.yml @@ -0,0 +1,28 @@ +name: "AOT Check" + +on: + push: + branches: [ "dev" ] + pull_request: + types: + - opened + - synchronize + - reopened + - ready_for_review + branches: [ "dev" ] + +jobs: + analyze: + runs-on: windows-latest + name: Wilson GitHub AOT check + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + fetch-depth: 1 + + - name: Runs powershell script + id: aot-powershell + run: build\test-aot.ps1 'net8.0' + diff --git a/build/test-aot.ps1 b/build/test-aot.ps1 new file mode 100644 index 0000000000..6bde9fa6ff --- /dev/null +++ b/build/test-aot.ps1 @@ -0,0 +1,50 @@ +param([string]$targetNetFramework) + +$projectName='Microsoft.IdentityModel.AotCompatibility.TestApp' +$rootDirectory = Split-Path $PSScriptRoot -Parent +$publishOutput = dotnet publish $rootDirectory/test/$projectName/$projectName.csproj --self-contained -nodeReuse:false /p:UseSharedCompilation=false + +$actualWarningCount = 0 + +foreach ($line in $($publishOutput -split "`r`n")) +{ + if (($line -like "*analysis warning IL*") -or ($line -like "*analysis error IL*")) + { + Write-Host $line + $actualWarningCount += 1 + } +} + +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 + Write-Host $publishOutput +} + +$runtime = if ($IsWindows) { "win-x64" } elseif ($IsMacOS) { "macos-x64"} else {"linux-x64"} +$app = if ($IsWindows ) {"./$projectName.exe" } else {"./projectName" } + +Push-Location $rootDirectory/test/$projectName/bin/Release/$targetNetFramework/win-x64 + +Write-Host "Executing test App..." +$app +Write-Host "Finished executing test App" + +if ($LastExitCode -ne 0) +{ + Write-Host "There was an error while executing AotCompatibility Test App. LastExitCode is:", $LastExitCode +} + +Pop-Location + +$testPassed = 0 +if ($actualWarningCount -ne $expectedWarningCount) +{ + $testPassed = 1 + Write-Host "Actual warning count:", actualWarningCount, "is not as expected. Expected warning count is:", $expectedWarningCount +} + +Exit $testPassed