Skip to content

Commit

Permalink
[AOT] Added AotCompatibility testApp and added CI to test AOT compati…
Browse files Browse the repository at this point in the history
…bility. (#1296)
  • Loading branch information
Yun-Ting authored Aug 10, 2023
1 parent 888fa69 commit c49d0e8
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/ci-aot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Publish AOTCompatibility testApp

on:
push:
branches: [ 'main*' ]
paths:
- 'src/OpenTelemetry.Instrumentation.Runtime/**'
- '!src/OpenTelemetry.Instrumentation.Runtime/README.md'
pull_request:
branches: [ 'main*' ]
paths:
- 'src/OpenTelemetry.Instrumentation.Runtime/**'
- '!src/OpenTelemetry.Instrumentation.Runtime/README.md'

jobs:
aot-test:
strategy:
fail-fast: false # ensures the entire test matrix is run, even if one permutation fails
matrix:
os: [ ubuntu-latest ]
version: [ net7.0 ]

runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3

- name: publish AOT testApp, assert static analysis warning count, and run the app
shell: pwsh
run: .\build\test-aot-compatibility.ps1 ${{ matrix.version }}

40 changes: 40 additions & 0 deletions build/test-aot-compatibility.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
param([string]$targetNetFramework)

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

$actualWarningCount = 0

foreach ($line in $($publishOutput -split "`r`n"))
{
if ($line -like "*analysis warning IL*")
{
Write-Host $line
$actualWarningCount += 1
}
}

Write-Host "Actual warning count is:", $actualWarningCount
$expectedWarningCount = 0

pushd $rootDirectory/test/OpenTelemetry.AotCompatibility.TestApp/bin/Debug/$targetNetFramework/linux-x64

Write-Host "Executing test App..."
./OpenTelemetry.AotCompatibility.TestApp
Write-Host "Finished executing test App"

if ($LastExitCode -ne 0)
{
Write-Host "There was an error while executing AotCompatibility Test App. LastExitCode is:", $LastExitCode
}

popd

$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
9 changes: 9 additions & 0 deletions opentelemetry-dotnet-contrib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{
.github\workflows\assign-reviewers.yml = .github\workflows\assign-reviewers.yml
.github\workflows\ci-md.yml = .github\workflows\ci-md.yml
.github\workflows\ci.yml = .github\workflows\ci.yml
.github\workflows\ci-aot.yml = .github\workflows\ci-aot.yml
.github\workflows\codeql-analysis.yml = .github\workflows\codeql-analysis.yml
.github\workflows\dotnet-core-cov.yml = .github\workflows\dotnet-core-cov.yml
.github\workflows\dotnet-format-md.yml = .github\workflows\dotnet-format-md.yml
Expand Down Expand Up @@ -79,6 +80,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{824BD1DE
build\OpenTelemetryContrib.test.ruleset = build\OpenTelemetryContrib.test.ruleset
build\sanitycheck.py = build\sanitycheck.py
build\stylecop.json = build\stylecop.json
build\test-aot-compatibility = build\test-aot-compatibility.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{0112BD4F-B7A6-4E43-AB23-B6E961E27A49}"
Expand Down Expand Up @@ -291,6 +293,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "InfluxDB", "InfluxDB", "{2D
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Examples.InfluxDB", "examples\InfluxDB\Examples.InfluxDB\Examples.InfluxDB.csproj", "{B4951583-D432-4E87-85CF-498FDD6A35E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.AotCompatibility.TestApp", "test\OpenTelemetry.AotCompatibility.TestApp\OpenTelemetry.AotCompatibility.TestApp.csproj", "{31937862-0C88-41C0-AFD6-F97A7BF803A9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -609,6 +613,10 @@ Global
{B4951583-D432-4E87-85CF-498FDD6A35E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B4951583-D432-4E87-85CF-498FDD6A35E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B4951583-D432-4E87-85CF-498FDD6A35E6}.Release|Any CPU.Build.0 = Release|Any CPU
{31937862-0C88-41C0-AFD6-F97A7BF803A9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{31937862-0C88-41C0-AFD6-F97A7BF803A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{31937862-0C88-41C0-AFD6-F97A7BF803A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{31937862-0C88-41C0-AFD6-F97A7BF803A9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -703,6 +711,7 @@ Global
{4847A991-D0C3-4421-B0D3-EA189959E639} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
{2D354354-BAFB-490B-A26F-6A16A52A1A45} = {B75EE478-97F7-4E9F-9A5A-DB3D0988EDEA}
{B4951583-D432-4E87-85CF-498FDD6A35E6} = {2D354354-BAFB-490B-A26F-6A16A52A1A45}
{31937862-0C88-41C0-AFD6-F97A7BF803A9} = {2097345F-4DD3-477D-BC54-A922F9B2B402}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {B0816796-CDB3-47D7-8C3C-946434DE3B66}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<PublishAot Condition="!$([MSBuild]::IsOSPlatform('OSX'))">true</PublishAot>
<TrimmerSingleWarn>false</TrimmerSingleWarn>
<SelfContained>true</SelfContained>
</PropertyGroup>

<ItemGroup>
<TrimmerRootAssembly Include="OpenTelemetry.Instrumentation.Runtime" />

<TrimmerRootAssembly Update="@(TrimmerRootAssembly)" Path="$(RepoRoot)\src\%(Identity)\%(Identity).csproj" />
<ProjectReference Include="@(TrimmerRootAssembly->'%(Path)')" />
</ItemGroup>

</Project>
19 changes: 19 additions & 0 deletions test/OpenTelemetry.AotCompatibility.TestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// <copyright file="Program.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;

Console.WriteLine("Hello, World!");

0 comments on commit c49d0e8

Please sign in to comment.