Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add alpine source build CI leg #15765

Merged
merged 6 commits into from
Jun 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions eng/pipelines/templates/stages/vmr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -84,6 +88,27 @@ stages:
withPreviousSDK: false # 🚫

- ${{ if ne(variables['Build.Reason'], 'PullRequest') }}:

# CI - Stage 1 x64 legs ------------------------------------
Copy link
Member Author

@MichaelSimons MichaelSimons Jun 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking for feedback on these header style comments. I am attempting to improve the readability by making it easier to quickly differentiate the various types of 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
Expand Down Expand Up @@ -192,6 +217,8 @@ stages:
useMonoRuntime: false # 🚫
withPreviousSDK: false # 🚫

# CI - Stage 1 arm64 Legs ------------------------------------

- template: ../jobs/vmr-build.yml
parameters:
buildName: Debian11_Offline_MsftSdk
Expand All @@ -208,6 +235,8 @@ stages:
useMonoRuntime: false # 🚫
withPreviousSDK: false # 🚫

# CI - Stage 2 x64 Legs ------------------------------------

- template: ../jobs/vmr-build.yml
parameters:
buildName: CentOSStream8_Online_CurrentSourceBuiltSdk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public DotNetHelper(ITestOutputHelper outputHelper)
}

Directory.CreateDirectory(Config.DotNetDirectory);
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"xzf {Config.SdkTarballPath} -C {Config.DotNetDirectory}", outputHelper);
Utilities.ExtractTarball(Config.SdkTarballPath, Config.DotNetDirectory);
}
IsMonoRuntime = DetermineIsMonoRuntime(Config.DotNetDirectory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ private async Task InitializeOmniSharp()
await client.DownloadFileAsync(omniSharpTarballUrl, omniSharpTarballFile, OutputHelper);

Directory.CreateDirectory(OmniSharpDirectory);
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"xzf {omniSharpTarballFile} -C {OmniSharpDirectory}", OutputHelper);
Utilities.ExtractTarball(omniSharpTarballFile, OmniSharpDirectory);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private void WriteTarballFileList(string? tarballPath, string outputFileName, bo
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -22,7 +26,7 @@ public void VerifyVersionFile()
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);
Expand All @@ -48,7 +52,7 @@ public void VerifyVersionFile()
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));
Expand All @@ -61,9 +65,4 @@ public void VerifyVersionFile()
Directory.Delete(outputDir, recursive: true);
}
}

private void ExtractFileFromTarball(string tarballPath, string filePath, string outputDir)
{
ExecuteHelper.ExecuteProcessValidateExitCode("tar", $"--wildcards -xzf {tarballPath} -C {outputDir} {filePath}", OutputHelper);
MichaelSimons marked this conversation as resolved.
Show resolved Hide resolved
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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(
Expand Down