Skip to content

Commit 60c0044

Browse files
Run installer tests in pipeline (#47313)
1 parent 3f5719f commit 60c0044

File tree

7 files changed

+179
-15
lines changed

7 files changed

+179
-15
lines changed

eng/pipelines/templates/stages/vmr-build.yml

+20
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,26 @@ stages:
123123
- template: ../steps/vmr-validate-asset-baseline.yml
124124
parameters:
125125
continueOnError: true
126+
- job: ValidateInstallers_Linux_x64
127+
displayName: Validate Installers - Linux x64
128+
pool: ${{ parameters.pool_Linux }}
129+
timeoutInMinutes: 30
130+
steps:
131+
- template: ../steps/vmr-validate-installers.yml
132+
parameters:
133+
targetArchitecture: x64
134+
continueOnError: true
135+
OS: Linux
136+
- job: ValidateInstallers_Linux_arm64
137+
displayName: Validate Installers - Linux arm64
138+
pool: ${{ parameters.pool_LinuxArm64 }}
139+
timeoutInMinutes: 30
140+
steps:
141+
- template: ../steps/vmr-validate-installers.yml
142+
parameters:
143+
targetArchitecture: arm64
144+
continueOnError: true
145+
OS: Linux
126146
- ${{ if eq(variables.signEnabled, 'true') }}:
127147
- job: ValidateSigning_Windows
128148
displayName: Validate Signing - Windows
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
parameters:
2+
- name: continueOnError
3+
type: boolean
4+
default: false
5+
6+
- name: targetArchitecture
7+
type: string
8+
default: ''
9+
10+
- name: OS
11+
type: string
12+
values:
13+
- Windows_NT
14+
- Linux
15+
- Darwin
16+
17+
steps:
18+
- task: DownloadBuildArtifacts@1
19+
inputs:
20+
artifactName: BlobArtifacts
21+
downloadPath: $(Build.ArtifactStagingDirectory)
22+
checkDownloadedFiles: true
23+
displayName: Download Blob Artifacts
24+
25+
- task: DownloadBuildArtifacts@1
26+
inputs:
27+
artifactName: PackageArtifacts
28+
downloadPath: $(Build.ArtifactStagingDirectory)
29+
checkDownloadedFiles: true
30+
displayName: Download Package Artifacts
31+
32+
# This is necessary whenever we want to publish/restore to an AzDO private feed
33+
# Since sdk-task.ps1 tries to restore packages we need to do this authentication here
34+
# otherwise it'll complain about accessing a private feed.
35+
- task: NuGetAuthenticate@1
36+
displayName: 'Authenticate to AzDO Feeds'
37+
38+
- ${{ if eq(parameters.OS, 'Linux') }}:
39+
- script: |
40+
extraBuildProperties="/p:TestRpmPackages=true"
41+
if [[ '${{ parameters.targetArchitecture }}' == 'x64' ]]; then
42+
# At the moment Deb packages are only available for x64
43+
extraBuildProperties="$extraBuildProperties /p:TestDebPackages=true"
44+
fi
45+
46+
./build.sh \
47+
--ci \
48+
-t \
49+
--projects test/Microsoft.DotNet.Installer.Tests/Microsoft.DotNet.Installer.Tests.csproj \
50+
/p:BlobArtifactsDir=$(Build.ArtifactStagingDirectory)/BlobArtifacts \
51+
/p:PackageArtifactsDir=$(Build.ArtifactStagingDirectory)/PackageArtifacts \
52+
$extraBuildProperties
53+
displayName: Validate installer packages
54+
workingDirectory: $(Build.SourcesDirectory)
55+
continueOnError: ${{ parameters.continueOnError }}
56+
57+
- task: PublishTestResults@2
58+
displayName: Publish Test Results
59+
condition: succeededOrFailed()
60+
continueOnError: true
61+
inputs:
62+
testRunner: VSTest
63+
testResultsFiles: 'artifacts/TestResults/Release/*.trx'
64+
searchFolder: $(Build.SourcesDirectory)
65+
mergeTestResults: true
66+
publishRunAttachments: true
67+
testRunTitle: Tests_$(Agent.JobName)

src/SourceBuild/content/build.sh

+11
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ usage()
3939
echo " --build-repo-tests Build repository tests"
4040

4141
echo "Advanced settings:"
42+
echo " --projects <value> Project or solution file to build"
4243
echo " --ci Set when running on CI server"
4344
echo " --clean-while-building Cleans each repo after building (reduces disk space usage, short: -cwb)"
4445
echo " --excludeCIBinarylog Don't output binary log (short: -nobl)"
@@ -82,6 +83,7 @@ packagesArchiveDir="${packagesDir}archive/"
8283
packagesPreviouslySourceBuiltDir="${packagesDir}previously-source-built/"
8384

8485
# Advanced settings
86+
projects=''
8587
ci=false
8688
exclude_ci_binary_log=false
8789
prepare_machine=false
@@ -176,6 +178,10 @@ while [[ $# > 0 ]]; do
176178
-build-repo-tests)
177179
properties+=( "/p:DotNetBuildTests=true" )
178180
;;
181+
-projects)
182+
projects=$2
183+
shift
184+
;;
179185
-ci)
180186
ci=true
181187
;;
@@ -222,6 +228,11 @@ if [[ "$test" == true ]]; then
222228
export MSBUILDDISABLENODEREUSE=1
223229
fi
224230

231+
# Override project if specified on cmd-line
232+
if [[ ! -z "$projects" ]]; then
233+
project="$projects"
234+
fi
235+
225236
function Build {
226237
if [[ "$sourceOnly" != "true" ]]; then
227238

src/SourceBuild/content/eng/build.ps1

+7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Param(
1313

1414
# Advanced settings
1515
[switch]$buildRepoTests,
16+
[string]$projects,
1617
[switch]$ci,
1718
[switch][Alias('cwb')]$cleanWhileBuilding,
1819
[switch][Alias('nobl')]$excludeCIBinarylog,
@@ -36,6 +37,7 @@ function Get-Usage() {
3637

3738
Write-Host "Advanced settings:"
3839
Write-Host " -buildRepoTests Build repository tests"
40+
Write-Host " -projects <value> Project or solution file to build"
3941
Write-Host " -ci Set when running on CI server"
4042
Write-Host " -cleanWhileBuilding Cleans each repo after building (reduces disk space usage, short: -cwb)"
4143
Write-Host " -excludeCIBinarylog Don't output binary log (short: -nobl)"
@@ -64,6 +66,11 @@ if ($test) {
6466
$env:MSBUILDENSURESTDOUTFORTASKPROCESSES="1"
6567
}
6668

69+
# Override project if specified on cmd-line
70+
if ($projects) {
71+
$project = $projects
72+
}
73+
6774
if ($sign) {
6875
$arguments += "/p:Sign=true"
6976
}

src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/Config.cs

+14-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
namespace Microsoft.DotNet.Installer.Tests;
1111

12+
public enum Architecture
13+
{
14+
X64,
15+
Arm64
16+
}
17+
1218
public static class Config
1319
{
1420
public static string AssetsDirectory { get; } = GetRuntimeConfig(AssetsDirectorySwitch);
@@ -20,7 +26,7 @@ public static class Config
2026
public static string ScenarioTestsNuGetConfigPath { get; } = GetRuntimeConfig(ScenarioTestsNuGetConfigSwitch);
2127
const string ScenarioTestsNuGetConfigSwitch = RuntimeConfigSwitchPrefix + nameof(ScenarioTestsNuGetConfigPath);
2228

23-
public static string Architecture { get; } = GetRuntimeConfig(ArchitectureSwitch);
29+
public static Architecture Architecture { get; } = GetArchitecture(GetRuntimeConfig(ArchitectureSwitch));
2430
const string ArchitectureSwitch = RuntimeConfigSwitchPrefix + nameof(Architecture);
2531

2632
public static bool TestRpmPackages { get; } = TryGetRuntimeConfig(TestRpmPackagesSwitch, out bool value) ? value : false;
@@ -34,6 +40,13 @@ public static class Config
3440

3541
public const string RuntimeConfigSwitchPrefix = "Microsoft.DotNet.Installer.Tests.";
3642

43+
public static Architecture GetArchitecture(string architecture) => architecture switch
44+
{
45+
"x64" => Architecture.X64,
46+
"arm64" => Architecture.Arm64,
47+
_ => throw new ArgumentException($"Unknown architecture: {architecture}")
48+
};
49+
3750
public static string GetRuntimeConfig(string key)
3851
{
3952
return TryGetRuntimeConfig(key, out string? value) ? value : throw new InvalidOperationException($"Runtime config setting '{key}' must be specified");

src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/LinuxInstallerTests.cs

+53-12
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ public class LinuxInstallerTests : IDisposable
2525
private readonly string _tmpDir;
2626
private readonly string _contextDir;
2727
private readonly ITestOutputHelper _outputHelper;
28+
private readonly string _excludeLinuxArch;
2829

2930
private bool _rpmContextInitialized = false;
3031
private bool _debContextInitialized = false;
3132
private bool _sharedContextInitialized = false;
3233

3334
private const string NetStandard21RpmPackage = @"https://dotnetcli.blob.core.windows.net/dotnet/Runtime/3.1.0/netstandard-targeting-pack-2.1.0-x64.rpm";
3435
private const string NetStandard21DebPackage = @"https://dotnetcli.blob.core.windows.net/dotnet/Runtime/3.1.0/netstandard-targeting-pack-2.1.0-x64.deb";
35-
private const string RuntimeDepsRepo = "mcr.microsoft.com/dotnet/nightly/runtime-deps";
36+
private const string RuntimeDepsRepo = "mcr.microsoft.com/dotnet/runtime-deps";
3637
private const string RuntimeDepsVersion = "10.0-preview";
3738

3839
public static bool IncludeRpmTests => Config.TestRpmPackages;
@@ -53,13 +54,17 @@ public LinuxInstallerTests(ITestOutputHelper outputHelper)
5354
Directory.CreateDirectory(_tmpDir);
5455
_contextDir = Path.Combine(_tmpDir, Path.GetRandomFileName());
5556
Directory.CreateDirectory(_contextDir);
57+
58+
_excludeLinuxArch = Config.Architecture == Architecture.X64 ?
59+
Architecture.Arm64.ToString().ToLower() :
60+
Architecture.X64.ToString().ToLower();
5661
}
5762

5863
public void Dispose()
5964
{
6065
try
6166
{
62-
//Directory.Delete(_tmpDir, recursive: true);
67+
Directory.Delete(_tmpDir, recursive: true);
6368
}
6469
catch
6570
{
@@ -92,31 +97,46 @@ public void DebTest(string repo, string tag)
9297

9398
private void InitializeContext(PackageType packageType)
9499
{
100+
string packageArchitecture =
101+
Config.Architecture == Architecture.X64 ?
102+
"x64" :
103+
packageType == PackageType.Rpm ?
104+
"aarch64" :
105+
"arm64";
106+
95107
if (packageType == PackageType.Rpm && !_rpmContextInitialized)
96108
{
97-
// For rpm enumerate RPM packages, excluding those that contain ".cm." in the name
98-
List<string> rpmPackages = Directory.GetFiles(Config.AssetsDirectory, "*.rpm", SearchOption.AllDirectories)
99-
.Where(p => !Path.GetFileName(p).Contains("-cm.") && !Path.GetFileName(p).EndsWith("azl.rpm"))
109+
// Copy all applicable RPM packages, excluding Mariner and Azure Linux copies
110+
List<string> rpmPackages =
111+
Directory.GetFiles(Config.AssetsDirectory, $"*-{packageArchitecture}*.rpm", SearchOption.AllDirectories)
112+
.Where(p => !Path.GetFileName(p).Contains("-cm.") &&
113+
!Path.GetFileName(p).Contains("-azl-") &&
114+
!Path.GetFileName(p).EndsWith("azl.rpm"))
100115
.ToList();
101116

102117
foreach (string rpmPackage in rpmPackages)
103118
{
104119
File.Copy(rpmPackage, Path.Combine(_contextDir, Path.GetFileName(rpmPackage)));
105120
}
106121

107-
DownloadFileAsync(NetStandard21RpmPackage, Path.Combine(_contextDir, Path.GetFileName(NetStandard21RpmPackage))).Wait();
122+
if (Config.Architecture == Architecture.X64)
123+
{
124+
DownloadFileAsync(NetStandard21RpmPackage, Path.Combine(_contextDir, Path.GetFileName(NetStandard21RpmPackage))).Wait();
125+
}
108126
_rpmContextInitialized = true;
109127
}
110128
else if (!_debContextInitialized)
111129
{
112-
// Copy all DEB packages as well
113-
foreach (string debPackage in Directory.GetFiles(Config.AssetsDirectory, "*.deb", SearchOption.AllDirectories))
130+
// Copy all applicable DEB packages
131+
foreach (string debPackage in Directory.GetFiles(Config.AssetsDirectory, $"*-{packageArchitecture}*.deb", SearchOption.AllDirectories))
114132
{
115133
File.Copy(debPackage, Path.Combine(_contextDir, Path.GetFileName(debPackage)));
116134
}
117135

118-
// Download NetStandard 2.1 packages
119-
DownloadFileAsync(NetStandard21DebPackage, Path.Combine(_contextDir, Path.GetFileName(NetStandard21DebPackage))).Wait();
136+
if (Config.Architecture == Architecture.X64)
137+
{
138+
DownloadFileAsync(NetStandard21DebPackage, Path.Combine(_contextDir, Path.GetFileName(NetStandard21DebPackage))).Wait();
139+
}
120140
_debContextInitialized = true;
121141
}
122142

@@ -127,7 +147,10 @@ private void InitializeContext(PackageType packageType)
127147
Directory.CreateDirectory(nugetPackagesDir);
128148
foreach (string package in Directory.GetFiles(Config.PackagesDirectory, "*.nupkg", SearchOption.AllDirectories))
129149
{
130-
File.Copy(package, Path.Combine(nugetPackagesDir, Path.GetFileName(package)));
150+
if (ShouldCopyPackage(package.ToLower()))
151+
{
152+
File.Copy(package, Path.Combine(nugetPackagesDir, Path.GetFileName(package)));
153+
}
131154
}
132155

133156
// Copy and update NuGet.config from scenario-tests repo
@@ -147,6 +170,24 @@ private void InitializeContext(PackageType packageType)
147170
}
148171
}
149172

173+
private bool ShouldCopyPackage(string package)
174+
{
175+
if (package.Contains(".osx-") ||
176+
package.Contains(".win-") ||
177+
package.Contains(".linux-musl-") ||
178+
package.Contains(".linux-bionic-") ||
179+
package.Contains(".mono.") ||
180+
package.Contains("symbols") ||
181+
package.Contains("vs.redist") ||
182+
package.Contains(".linux-arm.") ||
183+
package.Contains($".linux-{_excludeLinuxArch}."))
184+
{
185+
return false;
186+
}
187+
188+
return true;
189+
}
190+
150191
private void InsertLocalPackagesPathToNuGetConfig(string nuGetConfig, string localPackagesPath)
151192
{
152193
XDocument doc = XDocument.Load(nuGetConfig);
@@ -247,7 +288,7 @@ private List<string> GetPackageList(string baseImage, PackageType packageType)
247288
AddPackage(packageList, "aspnetcore-runtime-", packageType);
248289
AddPackage(packageList, "aspnetcore-targeting-pack-", packageType);
249290
AddPackage(packageList, "dotnet-apphost-pack-", packageType);
250-
if (Config.Architecture == "x64")
291+
if (Config.Architecture == Architecture.X64)
251292
{
252293
// netstandard package exists for x64 only
253294
AddPackage(packageList, "netstandard-targeting-pack-", packageType);

src/SourceBuild/content/test/Microsoft.DotNet.Installer.Tests/Microsoft.DotNet.Installer.Tests.csproj

+7-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
<VSTestCLIRunSettings>$(VSTestCLIRunSettings);RunConfiguration.DotNetHostPath=$(DotnetTool)</VSTestCLIRunSettings>
77
</PropertyGroup>
88

9+
<PropertyGroup>
10+
<BlobArtifactsDir Condition="'$(BlobArtifactsDir)' == ''">$(ArtifactsAssetsDir)</BlobArtifactsDir>
11+
<PackageArtifactsDir Condition="'$(PackageArtifactsDir)' == ''">$(ArtifactsPackagesDir)</PackageArtifactsDir>
12+
</PropertyGroup>
13+
914
<ItemGroup>
1015
<ProjectReference Include="..\TestUtilities\TestUtilities.csproj" />
1116
</ItemGroup>
@@ -15,10 +20,10 @@
1520
<ItemGroup>
1621
<!-- General configs -->
1722
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).AssetsDirectory">
18-
<Value>$(ArtifactsAssetsDir)</Value>
23+
<Value>$(BlobArtifactsDir)</Value>
1924
</RuntimeHostConfigurationOption>
2025
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).PackagesDirectory">
21-
<Value>$(ArtifactsPackagesDir)</Value>
26+
<Value>$(PackageArtifactsDir)</Value>
2227
</RuntimeHostConfigurationOption>
2328
<RuntimeHostConfigurationOption Include="$(MSBuildProjectName).ScenarioTestsNuGetConfigPath">
2429
<Value>$(RepoRoot)src\scenario-tests\NuGet.config</Value>

0 commit comments

Comments
 (0)