Skip to content

Commit 4498058

Browse files
authored
[Helix] Shared framework support + Templates tests (#19177)
1 parent 4e07efe commit 4498058

28 files changed

+248
-63
lines changed

.azure/pipelines/ci.yml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@ stages:
154154
displayName: Build x64
155155

156156
# Build the x86 shared framework
157-
# TODO: make it possible to build for one Windows architecture at a time
158-
# This is going to actually build x86 native assets. See https://github.com/dotnet/aspnetcore/issues/7196
157+
# This is going to actually build x86 native assets.
159158
- script: ./build.cmd
160159
-ci
161160
-arch x86
@@ -631,7 +630,7 @@ stages:
631630
publishOnError: true
632631
includeForks: true
633632

634-
# Helix x64
633+
# Helix x64
635634
- template: jobs/default-build.yml
636635
parameters:
637636
condition: eq(variables['Build.Reason'], 'PullRequest')
@@ -640,9 +639,12 @@ stages:
640639
agentOs: Windows
641640
timeoutInMinutes: 180
642641
steps:
642+
# Build the shared framework
643+
- script: ./build.cmd -ci -all -pack -arch x64 -buildNative /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log /bl:artifacts/log/helix.build.x64.binlog
644+
displayName: Build shared fx
643645
- script: .\restore.cmd -ci
644646
displayName: Restore
645-
- script: .\build.cmd -ci -NoRestore -test -projects eng\helix\helix.proj /p:IsRequiredCheck=true /p:IsHelixJob=true /p:BuildAllProjects=true /p:BuildNative=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl
647+
- script: .\build.cmd -ci -NoRestore -test -projects eng\helix\helix.proj /p:IsRequiredCheck=true /p:IsHelixJob=true /p:BuildAllProjects=true /p:BuildNative=true /p:RunTemplateTests=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl
646648
displayName: Run build.cmd helix target
647649
env:
648650
HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues
@@ -661,9 +663,13 @@ stages:
661663
agentOs: Windows
662664
timeoutInMinutes: 180
663665
steps:
666+
# Build the shared framework
667+
- script: ./build.cmd -ci -all -pack -arch x64 -buildNative /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log /bl:artifacts/log/helix.daily.build.x64.binlog
668+
displayName: Build shared fx
669+
# Build the x86 shared framework
664670
- script: .\restore.cmd -ci
665671
displayName: Restore
666-
- script: .\build.cmd -ci -NoRestore -test -projects eng\helix\helix.proj /p:IsHelixJob=true /p:IsHelixDaily=true /p:BuildAllProjects=true /p:BuildNative=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl
672+
- script: .\build.cmd -ci -NoRestore -test -projects eng\helix\helix.proj /p:IsHelixJob=true /p:IsHelixDaily=true /p:BuildAllProjects=true /p:BuildNative=true /p:RunTemplateTests=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl
667673
displayName: Run build.cmd helix target
668674
env:
669675
HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues
@@ -683,6 +689,7 @@ stages:
683689
agentOs: Linux
684690
timeoutInMinutes: 180
685691
steps:
692+
# Build the shared framework
686693
- script: ./restore.sh -ci
687694
displayName: Restore
688695
- script: ./build.sh -ci --arch arm64 -test --no-build-nodejs -projects $(Build.SourcesDirectory)/eng/helix/helix.proj /p:IsHelixJob=true /p:IsHelixDaily=true /p:BuildAllProjects=true /p:BuildNative=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl

.azure/pipelines/quarantined-tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ jobs:
3030
agentOs: Windows
3131
timeoutInMinutes: 240
3232
steps:
33+
# Build the shared framework
34+
- script: ./build.cmd -ci -all -pack -arch x64 -buildNative /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log /bl:artifacts/log/helix.build.x64.binlog
35+
displayName: Build shared fx
3336
- script: .\restore.cmd -ci
3437
displayName: Restore
35-
- script: .\build.cmd -ci -NoRestore -test -projects eng\helix\helix.proj /p:RunQuarantinedTests=true /p:IsRequiredCheck=true /p:IsHelixJob=true /p:BuildAllProjects=true /p:BuildNative=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl
38+
- script: .\build.cmd -ci -NoRestore -test -projects eng\helix\helix.proj /p:RunQuarantinedTests=true /p:IsRequiredCheck=true /p:IsHelixJob=true /p:BuildAllProjects=true /p:BuildNative=true /p:RunTemplateTests=true /p:ASPNETCORE_TEST_LOG_DIR=artifacts/log -bl
3639
displayName: Run build.cmd helix target
3740
env:
3841
HelixApiAccessToken: $(HelixApiAccessToken) # Needed for internal queues
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<#
2+
.SYNOPSIS
3+
Installs an AspNetCore shared framework on a machine
4+
.DESCRIPTION
5+
This script installs an AspNetCore shared framework on a machine
6+
.PARAMETER AppRuntimePath
7+
The path to the app runtime package to install.
8+
.PARAMETER InstallDir
9+
The directory to install the shared framework to.
10+
.PARAMETER Framework
11+
The framework directory to copy the shared framework from.
12+
.PARAMETER RuntimeIdentifier
13+
The runtime identifier for the shared framework.
14+
#>
15+
param(
16+
[Parameter(Mandatory = $true)]
17+
$AppRuntimePath,
18+
19+
[Parameter(Mandatory = $true)]
20+
$InstallDir,
21+
22+
[Parameter(Mandatory = $true)]
23+
$Framework,
24+
25+
[Parameter(Mandatory = $true)]
26+
$RuntimeIdentifier)
27+
28+
$ErrorActionPreference = 'Stop'
29+
$ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
30+
31+
Set-StrictMode -Version 1
32+
33+
Write-Host "Extracting to $InstallDir"
34+
35+
$zipPackage = [io.path]::ChangeExtension($AppRuntimePath, ".zip")
36+
Write-Host "Renaming to $zipPackage"
37+
Rename-Item -Path $AppRuntimePath -NewName $zipPackage
38+
if (Get-Command -Name 'Microsoft.PowerShell.Archive\Expand-Archive' -ErrorAction Ignore) {
39+
# Use built-in commands where possible as they are cross-plat compatible
40+
Microsoft.PowerShell.Archive\Expand-Archive -Path $zipPackage -DestinationPath ".\tmpRuntime" -Force
41+
}
42+
else {
43+
Remove-Item ".\tmpRuntime" -Recurse -ErrorAction Ignore
44+
# Fallback to old approach for old installations of PowerShell
45+
Add-Type -AssemblyName System.IO.Compression.FileSystem
46+
[System.IO.Compression.ZipFile]::ExtractToDirectory($zipPackage, ".\tmpRuntime")
47+
}
48+
49+
Get-ChildItem -Path ".\tmpRuntime" -Recurse
50+
51+
Write-Host "Copying managed files to $InstallDir"
52+
Copy-Item -Path ".\tmpRuntime\runtimes\$RuntimeIdentifier\lib\$Framework\*" $InstallDir
53+
Write-Host "Copying native files to $InstallDir"
54+
Copy-Item -Path ".\tmpRuntime\runtimes\$RuntimeIdentifier\native\*" $InstallDir

eng/helix/content/InstallNode.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ if (Get-Command "node.exe" -ErrorAction SilentlyContinue)
2929
exit
3030
}
3131

32-
if (Test-Path "$output_dir\node.exe")
32+
if (Test-Path "$InstallDir\node.exe")
3333
{
34-
Write-Host "Node.exe found at $output_dir"
34+
Write-Host "Node.exe found at $InstallDir"
3535
exit
3636
}
3737

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
3+
# Cause the script to fail if any subcommand fails
4+
set -e
5+
6+
appRuntimePath=$1
7+
output_dir=$2
8+
framework=$3
9+
rid=$4
10+
tmpDir=./tmpRuntime
11+
12+
echo "Installing shared framework from $appRuntimePath"
13+
cp $appRuntimePath sharedFx.zip
14+
15+
mkdir -p $tmpDir
16+
unzip sharedFx.zip -d $tmpDir
17+
mkdir -p $output_dir
18+
echo "Copying to $output_dir"
19+
cp $tmpDir/runtimes/$rid/lib/$framework/* $output_dir
20+
cp $tmpDir/runtimes/$rid/native/* $output_dir

eng/helix/content/runtests.cmd

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,22 @@ set PATH=%DOTNET_ROOT%;%PATH%;%HELIX_CORRELATION_PAYLOAD%\node\bin
2121
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture %$arch% -Version %$sdkVersion% -InstallDir %DOTNET_ROOT%"
2222
powershell.exe -NoProfile -ExecutionPolicy unrestricted -Command "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; &([scriptblock]::Create((Invoke-WebRequest -useb 'https://dot.net/v1/dotnet-install.ps1'))) -Architecture %$arch% -Runtime dotnet -Version %$runtimeVersion% -InstallDir %DOTNET_ROOT%"
2323

24+
if EXIST ".\Microsoft.AspNetCore.App" (
25+
echo "Found Microsoft.AspNetCore.App, copying to %DOTNET_ROOT%\shared\Microsoft.AspNetCore.App\%runtimeVersion%"
26+
xcopy /i /y ".\Microsoft.AspNetCore.App" %DOTNET_ROOT%\shared\Microsoft.AspNetCore.App\%runtimeVersion%\
27+
)
28+
29+
echo "Current Directory: %HELIX_WORKITEM_ROOT%"
2430
set HELIX=%$helixQueue%
31+
set HELIX_DIR=%HELIX_WORKITEM_ROOT%
32+
set NUGET_FALLBACK_PACKAGES=%HELIX_DIR%
33+
set NUGET_RESTORE=%HELIX_DIR%\nugetRestore
34+
echo "Setting HELIX_DIR: %HELIX_DIR%"
35+
echo Creating nuget restore directory: %NUGET_RESTORE%
36+
mkdir %NUGET_RESTORE%
37+
mkdir logs
38+
39+
dir
2540

2641
%DOTNET_ROOT%\dotnet vstest %$target% -lt >discovered.txt
2742
find /c "Exception thrown" discovered.txt

eng/helix/content/runtests.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1
3131

3232
# Used by SkipOnHelix attribute
3333
export helix="$helix_queue_name"
34+
export HELIX_DIR="$DIR"
35+
export NUGET_FALLBACK_PACKAGES="$DIR"
36+
export NUGET_RESTORE="$DIR/nugetRestore"
37+
echo "Creating nugetRestore directory: $NUGET_RESTORE"
38+
mkdir $NUGET_RESTORE
39+
mkdir logs
40+
41+
ls -la
3442

3543
RESET="\033[0m"
3644
RED="\033[0;31m"
@@ -82,6 +90,13 @@ if [ $? -ne 0 ]; then
8290
done
8391
fi
8492

93+
# Copy over any local shared fx if found
94+
if [ -d "Microsoft.AspNetCore.App" ]
95+
then
96+
echo "Found Microsoft.AspNetCore.App directory, copying to $DOTNET_ROOT/shared/Microsoft.AspNetCore.App/$dotnet_runtime_version."
97+
cp -r Microsoft.AspNetCore.App $DOTNET_ROOT/shared/Microsoft.AspNetCore.App/$dotnet_runtime_version
98+
fi
99+
85100
if [ -e /proc/self/coredump_filter ]; then
86101
# Include memory in private and shared file-backed mappings in the dump.
87102
# This ensures that we can see disassembly from our shared libraries when

eng/targets/Helix.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
<HelixUseArchive>false</HelixUseArchive>
2222
<LoggingTestingDisableFileLogging Condition="'$(IsHelixJob)' == 'true'">false</LoggingTestingDisableFileLogging>
2323
<NodeVersion>10.15.3</NodeVersion>
24+
<AppRuntimeVersion>5.0.0-ci</AppRuntimeVersion>
25+
<TestDependsOnAspNetRuntime>false</TestDependsOnAspNetRuntime>
2426
</PropertyGroup>
2527

2628
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">

eng/targets/Helix.targets

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,20 @@
1616
<HelixPreCommand Include="call RunPowershell.cmd InstallNode.ps1 $(NodeVersion) %25HELIX_CORRELATION_PAYLOAD%25\node\bin || exit /b 1" />
1717
</ItemGroup>
1818

19+
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'true' AND '$(TestDependsOnAspNetRuntime)' == 'true'">
20+
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg" />
21+
<HelixPreCommand Include="call RunPowershell.cmd InstallAppRuntime.ps1 Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App netcoreapp5.0 win-x64 || exit /b 1" />
22+
</ItemGroup>
23+
24+
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(IsWindowsHelixQueue)' == 'false' AND '$(TestDependsOnAspNetRuntime)' == 'true'">
25+
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg" />
26+
<HelixPreCommand Include="./installappruntime.sh Microsoft.AspNetCore.App.Runtime.win-x64.$(AppRuntimeVersion).nupkg Microsoft.AspNetCore.App netcoreapp5.0 win-x64" />
27+
</ItemGroup>
28+
29+
<ItemGroup Condition="'$(IsHelixJob)' == 'true' AND '$(TestDependsOnAspNetRuntime)' == 'true'">
30+
<HelixContent Include="$(RepoRoot)artifacts\packages\Release\Shipping\*-ci.nupkg" />
31+
</ItemGroup>
32+
1933
<!-- Item group has to be defined here becasue Helix.props is evaluated before xunit.runner.console.props -->
2034
<ItemGroup Condition="$(BuildHelixPayload)">
2135
<Content Include="@(HelixContent)" />

src/ProjectTemplates/test/BlazorServerTemplateTest.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ public BlazorServerTemplateTest(ProjectFactoryFixture projectFactory, BrowserFix
2424

2525
public Project Project { get; private set; }
2626

27-
[Fact]
27+
[ConditionalFact]
28+
[SkipOnHelix("selenium")]
2829
public async Task BlazorServerTemplateWorks_NoAuth()
2930
{
3031
Project = await ProjectFactory.GetOrCreateProject("blazorservernoauth", Output);
@@ -79,9 +80,10 @@ public async Task BlazorServerTemplateWorks_NoAuth()
7980
}
8081
}
8182

82-
[Theory]
83+
[ConditionalTheory]
8384
[InlineData(true)]
8485
[InlineData(false)]
86+
[SkipOnHelix("ef restore no worky")]
8587
public async Task BlazorServerTemplateWorks_IndividualAuth(bool useLocalDB)
8688
{
8789
Project = await ProjectFactory.GetOrCreateProject("blazorserverindividual" + (useLocalDB ? "uld" : ""), Output);

src/ProjectTemplates/test/ByteOrderMarkTest.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.IO;
66
using System.Linq;
77
using System.Text;
8+
using Microsoft.AspNetCore.Testing;
89
using Xunit;
910
using Xunit.Abstractions;
1011

@@ -19,7 +20,8 @@ public ByteOrderMarkTest(ITestOutputHelper output)
1920
_output = output;
2021
}
2122

22-
[Theory]
23+
[ConditionalTheory]
24+
[SkipOnHelix("missing files")]
2325
[InlineData("Web.ProjectTemplates")]
2426
[InlineData("Web.Spa.ProjectTemplates")]
2527
public void JSAndJSONInAllTemplates_ShouldNotContainBOM(string projectName)
@@ -60,7 +62,8 @@ public void JSAndJSONInAllTemplates_ShouldNotContainBOM(string projectName)
6062
Assert.False(filesWithBOMCharactersPresent);
6163
}
6264

63-
[Fact]
65+
[ConditionalFact]
66+
[SkipOnHelix("missing files")]
6467
public void RazorFilesInWebProjects_ShouldContainBOM()
6568
{
6669
var projectName = "Web.ProjectTemplates";

src/ProjectTemplates/test/EmptyWebTemplateTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Threading.Tasks;
55
using Templates.Test.Helpers;
6+
using Microsoft.AspNetCore.Testing;
67
using Xunit;
78
using Xunit.Abstractions;
89

@@ -22,7 +23,8 @@ public EmptyWebTemplateTest(ProjectFactoryFixture projectFactory, ITestOutputHel
2223

2324
public ITestOutputHelper Output { get; }
2425

25-
[Fact]
26+
[ConditionalFact]
27+
[SkipOnHelix("Cert failures", Queues = "OSX.1014.Amd64;OSX.1014.Amd64.Open")]
2628
public async Task EmptyWebTemplateCSharp()
2729
{
2830
await EmtpyTemplateCore(languageOverride: null);

src/ProjectTemplates/test/GrpcTemplateTest.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System;
55
using System.Runtime.InteropServices;
66
using System.Threading.Tasks;
7+
using Microsoft.AspNetCore.Testing;
78
using Templates.Test.Helpers;
89
using Xunit;
910
using Xunit.Abstractions;
@@ -23,7 +24,8 @@ public GrpcTemplateTest(ProjectFactoryFixture projectFactory, ITestOutputHelper
2324
public ProjectFactoryFixture ProjectFactory { get; }
2425
public ITestOutputHelper Output { get; }
2526

26-
[Fact]
27+
[ConditionalFact]
28+
[SkipOnHelix("Not supported queues", Queues = "Windows.7.Amd64;Windows.7.Amd64.Open;OSX.1014.Amd64;OSX.1014.Amd64.Open")]
2729
public async Task GrpcTemplate()
2830
{
2931
Project = await ProjectFactory.GetOrCreateProject("grpc", Output);

src/ProjectTemplates/test/Helpers/ProcessEx.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Concurrent;
66
using System.Collections.Generic;
77
using System.Diagnostics;
8+
using System.IO;
89
using System.Linq;
910
using System.Reflection;
1011
using System.Runtime.InteropServices;
@@ -99,6 +100,11 @@ public static ProcessEx Run(ITestOutputHelper output, string workingDirectory, s
99100
}
100101

101102
startInfo.EnvironmentVariables["NUGET_PACKAGES"] = NUGET_PACKAGES;
103+
104+
if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("helix")))
105+
{
106+
startInfo.EnvironmentVariables["NUGET_FALLBACK_PACKAGES"] = Environment.GetEnvironmentVariable("NUGET_FALLBACK_PACKAGES");
107+
}
102108

103109
output.WriteLine($"==> {startInfo.FileName} {startInfo.Arguments} [{startInfo.WorkingDirectory}]");
104110
var proc = Process.Start(startInfo);
@@ -189,11 +195,12 @@ public void WaitForExit(bool assertSuccess, TimeSpan? timeSpan = null)
189195
}
190196
}
191197

192-
private static string GetNugetPackagesRestorePath() =>
193-
typeof(ProcessEx).Assembly
198+
private static string GetNugetPackagesRestorePath() => (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("NUGET_RESTORE")))
199+
? typeof(ProcessEx).Assembly
194200
.GetCustomAttributes<AssemblyMetadataAttribute>()
195201
.First(attribute => attribute.Key == "TestPackageRestorePath")
196-
.Value;
202+
.Value
203+
: Environment.GetEnvironmentVariable("NUGET_RESTORE");
197204

198205
public void Dispose()
199206
{

0 commit comments

Comments
 (0)