Skip to content

Commit

Permalink
Perform AOT check on repository (#2598)
Browse files Browse the repository at this point in the history
* Perform AOT check on repository

* Use param

* Use correct path

* Use parameter

* Update yml and ps file
  • Loading branch information
SaurabhMSFT authored May 17, 2024
1 parent 909669f commit ad64ace
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/aot-check.yml
Original file line number Diff line number Diff line change
@@ -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'

50 changes: 50 additions & 0 deletions build/test-aot.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit ad64ace

Please sign in to comment.