Skip to content

Commit c106cfe

Browse files
[NativeAOT-LLVM] Add live package testing (#3114)
* Add live package testing * CI
1 parent 889ad13 commit c106cfe

File tree

9 files changed

+166
-9
lines changed

9 files changed

+166
-9
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# When publishing packages in CI, the full closure has duplicates. For example,
2+
# both win-x64/wasi and win-x64/browser produce the "runtime.win-x64.*" package,
3+
# Similarly with win-x64/wasi and linux-x64/wasi producing "runtime.wasi-wasm.*".
4+
# The publishing system does not tolerate duplicates, so we remove them before
5+
# the upload step. This allows us to still have all the packages available for
6+
# testing on all CI platforms.
7+
[CmdletBinding(PositionalBinding=$false)]
8+
param(
9+
[string]$Config,
10+
[string]$TargetOS,
11+
[string]$TargetArch
12+
)
13+
$ErrorActionPreference="Stop"
14+
15+
$RepoRoot = [IO.Path]::GetFullPath("../../..", $PSScriptRoot)
16+
if (!(Test-Path $RepoRoot/LICENSE.TXT))
17+
{
18+
Write-Error "Unexpected repository root: '$RepoRoot'"
19+
}
20+
21+
# Must be kept in sync with "upload-intermediate-artifacts-step.yml".
22+
$PackagesPath = Join-Path $RepoRoot "artifacts" "packages" $Config "Shipping"
23+
24+
if (!(Test-Path $PackagesPath))
25+
{
26+
Write-Host "'$PackagesPath' does not exist, exiting"
27+
exit
28+
}
29+
30+
$HostRid = [Runtime.InteropServices.RuntimeInformation]::RuntimeIdentifier
31+
$PublishTargetPackages = $HostRid -eq "win-x64"
32+
if (!$PublishTargetPackages)
33+
{
34+
$TargetRid = "$TargetOS-$TargetArch"
35+
$TargetPackagePattern = "runtime.$TargetRid.Microsoft.DotNet.ILCompiler.LLVM.*.nupkg"
36+
Write-Host "Removing ${TargetPackagePattern}:"
37+
Get-ChildItem $PackagesPath/$TargetPackagePattern | Write-Host
38+
Remove-Item -Force $PackagesPath/$TargetPackagePattern
39+
}
40+
41+
$PublishHostPackages = $TargetOS -eq "browser"
42+
if (!$PublishHostPackages)
43+
{
44+
$HostPackagePattern = "runtime.$HostRid.Microsoft.DotNet.ILCompiler.LLVM.*.nupkg"
45+
Write-Host "Removing ${HostPackagePattern}:"
46+
Get-ChildItem $PackagesPath/$HostPackagePattern | Write-Host
47+
Remove-Item -Force $PackagesPath/$HostPackagePattern
48+
}
49+
50+
Write-Host "Final package set:"
51+
Get-ChildItem $PackagesPath/* | Write-Host
52+

eng/pipelines/runtimelab/runtimelab-post-build-steps.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ steps:
1616
- script: $(Build.SourcesDirectory)/build$(scriptExt) clr.wasmjit+clr.aot -c $(buildConfigUpper) $(_officialBuildParameter) -ci -cross
1717
displayName: Build the ILC and RyuJit cross-compilers
1818

19-
# Build target packages when the host OS is Windows (note: target libs already built).
20-
- ${{ if contains(parameters.platform, 'win') }}:
21-
- script: $(Build.SourcesDirectory)/build$(scriptExt) nativeaot.packages -a wasm -os ${{ parameters.osGroup }} -c $(buildConfigUpper) $(_officialBuildParameter) -ci
22-
displayName: Build target packages
19+
# Build target packages (note: target libs already built).
20+
- script: $(Build.SourcesDirectory)/build$(scriptExt) nativeaot.packages -a wasm -os ${{ parameters.osGroup }} -c $(buildConfigUpper) $(_officialBuildParameter) -ci
21+
displayName: Build target packages
2322

24-
# Build host packages when the target OS is Browser.
25-
- ${{ if eq(parameters.osGroup, 'browser') }}:
26-
- script: $(Build.SourcesDirectory)/build$(scriptExt) libs+nativeaot.packages -c $(buildConfigUpper) $(_officialBuildParameter) -ci -cross
27-
displayName: Build host packages
23+
# Build host packages.
24+
- script: $(Build.SourcesDirectory)/build$(scriptExt) libs+nativeaot.packages -c $(buildConfigUpper) $(_officialBuildParameter) -ci -cross
25+
displayName: Build host packages
2826

2927
# Build coreclr native test output outside of official build
3028
- ${{ if ne(parameters.isOfficialBuild, true) }}:
@@ -71,6 +69,9 @@ steps:
7169
$(Build.SourcesDirectory)/build$(scriptExt) libs.tests -test -a ${{ parameters.archType }} -os ${{ parameters.osGroup }} -lc ${{ parameters.librariesConfiguration }} -rc $(buildConfigUpper) /p:TestNativeAot=true /p:RunSmokeTestsOnly=true
7270
displayName: Build and run WebAssembly libraries tests
7371
72+
- script: pwsh $(Build.SourcesDirectory)/eng/pipelines/runtimelab/remove-duplicate-packages.ps1 -Config $(_BuildConfig) -TargetOS ${{ parameters.osGroup }} -TargetArch ${{ parameters.archType }}
73+
displayName: Remove duplicate packages before publishing
74+
7475
# Upload unsigned artifacts
7576
- ${{ if eq(parameters.uploadIntermediateArtifacts, true) }}:
7677
- template: /eng/pipelines/common/upload-intermediate-artifacts-step.yml

src/tests/Common/dirs.proj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@
3131
<DisabledProjects Include="$(TestRoot)readytorun\**\*.csproj" Condition="'$(TestBuildMode)' == 'nativeaot'" />
3232
</ItemGroup>
3333

34+
<ItemGroup>
35+
<!-- These projects are built separately in an isolated way. -->
36+
<DisabledProjects Include="$(TestRoot)nativeaot\SmokeTests\HelloWasm\PackagingTests\*.csproj" />
37+
</ItemGroup>
38+
3439
<ItemGroup>
3540
<BuildTestProjects Include="$(__BuildTestProject.Split(';'))" />
3641
<BuildTestDirs Include="$(__BuildTestDir.Split(';'))" />
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<Project Sdk="Microsoft.Build.NoTargets">
2+
<PropertyGroup>
3+
<!-- This is the part of the package testing exposed to the runtime test infrastructure.
4+
The projects themselves are intentionally isolated from the rest of the tree. -->
5+
<CLRTestKind>BuildOnly</CLRTestKind>
6+
<CLRTestTargetUnsupported Condition="'$(TargetsWasm)' != 'true'">true</CLRTestTargetUnsupported>
7+
</PropertyGroup>
8+
9+
<Target Name="PublishPackagingTestProject" BeforeTargets="BeforeBuild">
10+
<ItemGroup>
11+
<PackagingTestProject Include="PackagingTests/PackagingTestProject.csproj" />
12+
13+
<PackagingTestProject>
14+
<TestOutputPath>$(OutputPath)%(FileName)</TestOutputPath>
15+
</PackagingTestProject>
16+
</ItemGroup>
17+
18+
<PropertyGroup>
19+
<Test_Configuration>$(Configuration)</Test_Configuration>
20+
<Test_TargetFramework>$(NetCoreAppCurrent)</Test_TargetFramework>
21+
<Test_RuntimeIdentifier>$(TargetOS)-$(TargetArchitecture)</Test_RuntimeIdentifier>
22+
<Test_RestoreSource>$(ArtifactsShippingPackagesDir)</Test_RestoreSource>
23+
<Test_RestorePackagesPath>$([MSBuild]::NormalizeDirectory('$(PackageOutputPath)', 'packages', '$(Configuration)'))</Test_RestorePackagesPath>
24+
</PropertyGroup>
25+
26+
<Error Condition="!Exists($(Test_RestoreSource))"
27+
Text="The 'nativeaot.packages' subset must be built before building this project" />
28+
29+
<Message Text="Packed packages: '$(Test_RestoreSource)'" Importance="High" />
30+
<Message Text="Unpacked packages: '$(Test_RestorePackagesPath)'" Importance="High" />
31+
32+
<!-- Always start with a clean unpacked state so that there is no need to
33+
manually delete the old packages for the new ones to be picked up.
34+
WARNING: one still needs to manually delete the **source** packages
35+
before "./build nativeaot.packages" because the pkgproj targets do
36+
not declare their inputs properly. -->
37+
<RemoveDir Directories="$(Test_RestorePackagesPath)" />
38+
<RemoveDir Directories="@(PackagingTestProject->'%(TestOutputPath)')" />
39+
40+
<PropertyGroup>
41+
<PackagingTestProjectProperties>
42+
Test_Configuration=$(Test_Configuration);
43+
Test_TargetFramework=$(Test_TargetFramework);
44+
Test_RuntimeIdentifier=$(Test_RuntimeIdentifier);
45+
Test_PackageVersion=$(NetCoreAppCurrentVersion).0-*;
46+
Test_RestoreSource=$(Test_RestoreSource);
47+
Test_RestorePackagesPath=$(Test_RestorePackagesPath);
48+
</PackagingTestProjectProperties>
49+
</PropertyGroup>
50+
51+
<MSBuild Projects="@(PackagingTestProject)"
52+
Targets="Restore"
53+
Properties="$(PackagingTestProjectProperties);
54+
Test_TestOutputPath=%(TestOutputPath);
55+
MSBuildRestoreSessionId=$([System.Guid]::NewGuid())" />
56+
57+
<MSBuild Projects="@(PackagingTestProject)"
58+
Targets="Publish"
59+
Properties="$(PackagingTestProjectProperties);
60+
Test_TestOutputPath=%(TestOutputPath)" />
61+
62+
<Error Condition="!Exists('%(TestOutputPath)/bin/$(Test_Configuration)/$(Test_TargetFramework)/$(Test_RuntimeIdentifier)/publish/%(FileName).wasm')"
63+
Text="%(PackagingTestProject.FullPath) did not produce the expected native artifacts" />
64+
</Target>
65+
</Project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Project>
2+
<!-- Ignore repo build setting; use properties passed by the parent project to reroute the output. -->
3+
<PropertyGroup>
4+
<BaseIntermediateOutputPath>$([MSBuild]::NormalizeDirectory('$(Test_TestOutputPath)', 'obj'))</BaseIntermediateOutputPath>
5+
<BaseOutputPath>$([MSBuild]::NormalizeDirectory('$(Test_TestOutputPath)', 'bin'))</BaseOutputPath>
6+
</PropertyGroup>
7+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<Project>
2+
<!-- Ignore repo build setting. -->
3+
</Project>
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<Configuration>$(Test_Config)</Configuration>
6+
<TargetFramework>$(Test_TargetFramework)</TargetFramework>
7+
<RuntimeIdentifier>$(Test_RuntimeIdentifier)</RuntimeIdentifier>
8+
9+
<PublishTrimmed>true</PublishTrimmed>
10+
<SelfContained>true</SelfContained>
11+
<MSBuildEnableWorkloadResolver>false</MSBuildEnableWorkloadResolver>
12+
<UseAppHost>false</UseAppHost>
13+
14+
<RestorePackagesPath>$(Test_RestorePackagesPath)</RestorePackagesPath>
15+
<RestoreAdditionalProjectSources>$(Test_RestoreSource)</RestoreAdditionalProjectSources>
16+
</PropertyGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Microsoft.DotNet.ILCompiler.LLVM" Version="$(Test_PackageVersion)" />
20+
<PackageReference Include="runtime.$(NETCoreSdkPortableRuntimeIdentifier).Microsoft.DotNet.ILCompiler.LLVM" Version="$(Test_PackageVersion)" />
21+
</ItemGroup>
22+
23+
</Project>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
System.Console.WriteLine("Hello World!");

src/tests/nativeaot/nativeaot.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<ItemGroup Condition="'$(TargetsWasm)' != 'true'">
44
<DisabledProjects Include="*/**/Library.csproj" />
5-
<DisabledProjects Include="*/**/HelloWasm/*.??proj" />
5+
<DisabledProjects Include="*/**/HelloWasm/**/*.??proj" />
66
</ItemGroup>
77

88
<!-- Wasm disabled projects are still in dirs.proj because Wasm is not using this merged test wrapper -->

0 commit comments

Comments
 (0)