Add alpine source build CI leg (#15765)

This commit is contained in:
Michael Simons 2023-06-02 15:24:47 -05:00 committed by GitHub
parent 32e54381c3
commit e65d04254c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 89 additions and 11 deletions

View file

@ -13,6 +13,7 @@ parameters:
# The following parameters aren't expected to be passed in rather they are used for encapsulation
# -----------------------------------------------------------------------------------------------
alpine317Container: mcr.microsoft.com/dotnet-buildtools/prereqs:alpine-3.17
centOSStream8Container: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream8
centOSStream9Container: mcr.microsoft.com/dotnet-buildtools/prereqs:centos-stream9
debian11Arm64Container: mcr.microsoft.com/dotnet-buildtools/prereqs:debian-11-arm64v8
@ -65,6 +66,9 @@ stages:
value: ${{ replace(replace(variables['Build.SourceBranch'], 'refs/heads/', ''), 'refs/pull/', '') }}
jobs:
# PR and CI legs ------------------------------------
- template: ../jobs/vmr-build.yml
parameters:
buildName: CentOSStream8_Online_MsftSdk
@ -84,6 +88,27 @@ stages:
withPreviousSDK: false # 🚫
- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:
# CI - Stage 1 x64 legs ------------------------------------
- template: ../jobs/vmr-build.yml
parameters:
buildName: Alpine317_Offline_MsftSdk
isBuiltFromVmr: ${{ parameters.isBuiltFromVmr }}
vmrBranch: ${{ variables.VmrBranch }}
architecture: x64
pool:
name: ${{ variables.defaultPoolName }}
demands: ${{ variables.defaultPoolDemands }}
container: ${{ parameters.alpine317Container }}
buildFromArchive: false # ✅
enablePoison: false # 🚫
excludeOmniSharpTests: true # ✅
overrideDistroDisablingSha1: false # 🚫
runOnline: false # 🚫
useMonoRuntime: false # 🚫
withPreviousSDK: false # 🚫
- template: ../jobs/vmr-build.yml
parameters:
buildName: CentOSStream8_Online_PreviousSourceBuiltSdk
@ -192,6 +217,8 @@ stages:
useMonoRuntime: false # 🚫
withPreviousSDK: false # 🚫
# CI - Stage 1 arm64 Legs ------------------------------------
- template: ../jobs/vmr-build.yml
parameters:
buildName: Debian11_Offline_MsftSdk
@ -208,6 +235,8 @@ stages:
useMonoRuntime: false # 🚫
withPreviousSDK: false # 🚫
# CI - Stage 2 x64 Legs ------------------------------------
- template: ../jobs/vmr-build.yml
parameters:
buildName: CentOSStream8_Online_CurrentSourceBuiltSdk

View file

@ -36,7 +36,7 @@ internal class DotNetHelper
}
Directory.CreateDirectory(Config.DotNetDirectory);
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"xzf {Config.SdkTarballPath} -C {Config.DotNetDirectory}", outputHelper);
Utilities.ExtractTarball(Config.SdkTarballPath, Config.DotNetDirectory);
}
IsMonoRuntime = DetermineIsMonoRuntime(Config.DotNetDirectory);

View file

@ -9,6 +9,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">

View file

@ -65,7 +65,7 @@ public class OmniSharpTests : SmokeTests
await client.DownloadFileAsync(omniSharpTarballUrl, omniSharpTarballFile, OutputHelper);
Directory.CreateDirectory(OmniSharpDirectory);
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"xzf {omniSharpTarballFile} -C {OmniSharpDirectory}", OutputHelper);
Utilities.ExtractTarball(omniSharpTarballFile, OmniSharpDirectory);
}
}
}

View file

@ -43,7 +43,7 @@ public class SdkContentTests : SmokeTests
throw new InvalidOperationException($"Tarball path '{tarballPath}' does not exist.");
}
string fileListing = ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"tf {tarballPath}", OutputHelper);
string fileListing = Utilities.GetTarballContentNames(tarballPath).Aggregate((a, b) => $"{a}{Environment.NewLine}{b}");
fileListing = BaselineHelper.RemoveRids(fileListing, isPortable);
fileListing = BaselineHelper.RemoveVersions(fileListing);
IEnumerable<string> files = fileListing.Split(Environment.NewLine).OrderBy(path => path);

View file

@ -1,4 +1,8 @@
using System;
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -22,7 +26,7 @@ public class SourceBuiltArtifactsTests : SmokeTests
try
{
// Extract the .version file
ExtractFileFromTarball(Config.SourceBuiltArtifactsPath, ".version", outputDir);
Utilities.ExtractTarball(Config.SourceBuiltArtifactsPath, outputDir, ".version");
string[] versionLines = File.ReadAllLines(Path.Combine(outputDir, ".version"));
Assert.Equal(2, versionLines.Length);
@ -48,7 +52,7 @@ public class SourceBuiltArtifactsTests : SmokeTests
string sdkVersion = versionLines[1];
// Find the expected SDK version by getting it from the SDK tarball
ExtractFileFromTarball(Config.SdkTarballPath ?? string.Empty, "./sdk/*/.version", outputDir);
Utilities.ExtractTarball(Config.SdkTarballPath ?? string.Empty, outputDir, "./sdk/*/.version");
DirectoryInfo sdkDir = new DirectoryInfo(Path.Combine(outputDir, "sdk"));
string sdkVersionPath = sdkDir.GetFiles(".version", SearchOption.AllDirectories).Single().FullName;
string[] sdkVersionLines = File.ReadAllLines(Path.Combine(outputDir, sdkVersionPath));
@ -61,9 +65,4 @@ public class SourceBuiltArtifactsTests : SmokeTests
Directory.Delete(outputDir, recursive: true);
}
}
private void ExtractFileFromTarball(string tarballPath, string filePath, string outputDir)
{
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"--wildcards -xzf {tarballPath} -C {outputDir} {filePath}", OutputHelper);
}
}

View file

@ -2,7 +2,12 @@
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using Microsoft.Extensions.FileSystemGlobbing;
using System;
using System.Collections.Generic;
using System.Formats.Tar;
using System.IO;
using System.IO.Compression;
using System.Threading;
using System.Threading.Tasks;
using Xunit.Abstractions;
@ -11,6 +16,50 @@ namespace Microsoft.DotNet.SourceBuild.SmokeTests;
public static class Utilities
{
public static void ExtractTarball(string tarballPath, string outputDir)
{
using FileStream fileStream = File.OpenRead(tarballPath);
using GZipStream decompressorStream = new(fileStream, CompressionMode.Decompress);
TarFile.ExtractToDirectory(decompressorStream, outputDir, true);
}
public static void ExtractTarball(string tarballPath, string outputDir, string targetFilePath)
{
Matcher matcher = new();
matcher.AddInclude(targetFilePath);
using FileStream fileStream = File.OpenRead(tarballPath);
using GZipStream decompressorStream = new(fileStream, CompressionMode.Decompress);
using TarReader reader = new(decompressorStream);
TarEntry entry;
while ((entry = reader.GetNextEntry()) is not null)
{
if (matcher.Match(entry.Name).HasMatches)
{
string outputPath = Path.Join(outputDir, entry.Name);
Directory.CreateDirectory(Path.GetDirectoryName(outputPath));
using FileStream outputFileStream = File.Create(outputPath);
entry.DataStream.CopyTo(outputFileStream);
break;
}
}
}
public static IEnumerable<string> GetTarballContentNames(string tarballPath)
{
using FileStream fileStream = File.OpenRead(tarballPath);
using GZipStream decompressorStream = new(fileStream, CompressionMode.Decompress);
using TarReader reader = new(decompressorStream);
TarEntry entry;
while ((entry = reader.GetNextEntry()) is not null)
{
yield return entry.Name;
}
}
public static async Task RetryAsync(Func<Task> executor, ITestOutputHelper outputHelper)
{
await Utilities.RetryAsync(