Browse Source

Parameters fixes

pull/12072/head
Max Katz 3 years ago
parent
commit
65e29787dd
  1. 30
      .nuke/build.schema.json
  2. 19
      nukebuild/ApiDiffValidation.cs
  3. 21
      nukebuild/BuildParameters.cs

30
.nuke/build.schema.json

@ -6,21 +6,18 @@
"build": {
"type": "object",
"properties": {
"ApiValidationBaseline": {
"type": "string",
"description": "api-baseline"
"api-baseline": {
"type": "string"
},
"Configuration": {
"type": "string",
"description": "configuration"
"configuration": {
"type": "string"
},
"Continue": {
"type": "boolean",
"description": "Indicates to continue a previously failed build attempt"
},
"ForceNugetVersion": {
"type": "string",
"description": "force-nuget-version"
"force-nuget-version": {
"type": "string"
},
"Help": {
"type": "boolean",
@ -98,13 +95,11 @@
]
}
},
"SkipPreviewer": {
"type": "boolean",
"description": "skip-previewer"
"skip-previewer": {
"type": "boolean"
},
"SkipTests": {
"type": "boolean",
"description": "skip-tests"
"skip-tests": {
"type": "boolean"
},
"Target": {
"type": "array",
@ -134,9 +129,8 @@
]
}
},
"UpdateApiValidationSuppression": {
"type": "boolean",
"description": "update-api-suppression"
"update-api-suppression": {
"type": "boolean"
},
"Verbosity": {
"type": "string",

19
nukebuild/ApiDiffValidation.cs

@ -10,8 +10,10 @@ using Nuke.Common.Tooling;
public static class ApiDiffValidation
{
private static readonly HttpClient s_httpClient = new();
public static async Task ValidatePackage(
Tool apiCompatTool, string packagePath, Version baselineVersion,
Tool apiCompatTool, string packagePath, string baselineVersion,
string suppressionFilesFolder, bool updateSuppressionFile)
{
if (baselineVersion is null)
@ -25,7 +27,7 @@ public static class ApiDiffValidation
Directory.CreateDirectory(suppressionFilesFolder!);
}
using (var baselineStream = await DownloadBaselinePackage(packagePath, baselineVersion))
await using (var baselineStream = await DownloadBaselinePackage(packagePath, baselineVersion))
using (var target = new ZipArchive(File.Open(packagePath, FileMode.Open, FileAccess.Read), ZipArchiveMode.Read))
using (var baseline = new ZipArchive(baselineStream, ZipArchiveMode.Read))
using (Helpers.UseTempDir(out var tempFolder))
@ -43,7 +45,7 @@ public static class ApiDiffValidation
var baselineDllPath = Path.Combine("baseline", baselineDll.target, baselineDll.entry.Name);
var baselineDllRealPath = Path.Combine(tempFolder, baselineDllPath);
Directory.CreateDirectory(Path.GetDirectoryName(baselineDllRealPath)!);
using (var baselineDllFile = File.Create(baselineDllRealPath))
await using (var baselineDllFile = File.Create(baselineDllRealPath))
{
await baselineDll.entry.Open().CopyToAsync(baselineDllFile);
}
@ -58,7 +60,7 @@ public static class ApiDiffValidation
var targetDllPath = Path.Combine("target", targetDll.target, targetDll.entry.Name);
var targetDllRealPath = Path.Combine(tempFolder, targetDllPath);
Directory.CreateDirectory(Path.GetDirectoryName(targetDllRealPath)!);
using (var targetDllFile = File.Create(targetDllRealPath))
await using (var targetDllFile = File.Create(targetDllRealPath))
{
await targetDll.entry.Open().CopyToAsync(targetDllFile);
}
@ -96,7 +98,7 @@ public static class ApiDiffValidation
.ToArray();
}
static async Task<Stream> DownloadBaselinePackage(string packagePath, Version baselineVersion)
static async Task<Stream> DownloadBaselinePackage(string packagePath, string baselineVersion)
{
Build.Information("Downloading {0} baseline package for version {1}", Path.GetFileName(packagePath), baselineVersion);
@ -106,9 +108,10 @@ public static class ApiDiffValidation
Path.GetFileNameWithoutExtension(packagePath),
"""(\.\d+\.\d+\.\d+)$""", "");
using var httpClient = new HttpClient();
using var response = await httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get,
$"https://www.nuget.org/api/v2/package/{packageId}/{baselineVersion}"));
using var response = await s_httpClient.SendAsync(new HttpRequestMessage(HttpMethod.Get,
$"https://www.nuget.org/api/v2/package/{packageId}/{baselineVersion}"), HttpCompletionOption.ResponseHeadersRead);
response.EnsureSuccessStatusCode();
await using var stream = await response.Content.ReadAsStreamAsync();
var memoryStream = new MemoryStream();
await stream.CopyToAsync(memoryStream);

21
nukebuild/BuildParameters.cs

@ -10,22 +10,22 @@ using static Nuke.Common.IO.PathConstruction;
public partial class Build
{
[Parameter("configuration")]
[Parameter(Name = "configuration")]
public string Configuration { get; set; }
[Parameter("skip-tests")]
[Parameter(Name = "skip-tests")]
public bool SkipTests { get; set; }
[Parameter("force-nuget-version")]
[Parameter(Name = "force-nuget-version")]
public string ForceNugetVersion { get; set; }
[Parameter("skip-previewer")]
[Parameter(Name = "skip-previewer")]
public bool SkipPreviewer { get; set; }
[Parameter("api-baseline")]
[Parameter(Name = "api-baseline")]
public string ApiValidationBaseline { get; set; }
[Parameter("update-api-suppression")]
[Parameter(Name = "update-api-suppression")]
public bool UpdateApiValidationSuppression { get; set; }
public class BuildParameters
@ -63,7 +63,7 @@ public partial class Build
public string FileZipSuffix { get; }
public AbsolutePath ZipCoreArtifacts { get; }
public AbsolutePath ZipNuGetArtifacts { get; }
public Version ApiValidationBaseline { get; }
public string ApiValidationBaseline { get; }
public bool UpdateApiValidationSuppression { get; }
public AbsolutePath ApiValidationSuppressionFiles { get; }
@ -73,10 +73,6 @@ public partial class Build
Configuration = b.Configuration ?? "Release";
SkipTests = b.SkipTests;
SkipPreviewer = b.SkipPreviewer;
ApiValidationBaseline = b.ApiValidationBaseline is not null ?
new Version(b.ApiValidationBaseline) :
new Version(11, 0);
UpdateApiValidationSuppression = b.UpdateApiValidationSuppression;
// CONFIGURATION
MainRepo = "https://github.com/AvaloniaUI/Avalonia";
@ -115,6 +111,9 @@ public partial class Build
// VERSION
Version = b.ForceNugetVersion ?? GetVersion();
ApiValidationBaseline = b.ApiValidationBaseline ?? new Version(new Version(Version).Major, 0).ToString();
UpdateApiValidationSuppression = b.UpdateApiValidationSuppression;
if (IsRunningOnAzure)
{
if (!IsNuGetRelease)

Loading…
Cancel
Save