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

Use exceptional versions from JSON #1

Open
wants to merge 1 commit into
base: feature/distroessed-exceptional
Choose a base branch
from
Open
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
57 changes: 3 additions & 54 deletions src/DistroessedExceptional/Program.cs
Original file line number Diff line number Diff line change
@@ -1,57 +1,11 @@
using DotnetRelease;
using ExceptionalVersions = System.Collections.Generic.List<string>;
using ExceptionsPerVersion = System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>>;
using ExceptionsPerFamily = System.Collections.Generic.Dictionary<string, System.Collections.Generic.Dictionary<string, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<string>>>>;

if (args.Length is 0 || !int.TryParse(args[0], out int majorVersion))
{
ReportInvalidArgs();
return;
}

ExceptionsPerFamily exceptions = new()
{
["Windows"] = new()
{
["Windows"] = new()
{
["6.0"] = [ "10-1507-e-lts" ],
["7.0"] = [ "10-1507-e-lts" ],
["8.0"] = [ "10-1507-e-lts" ]
},
["Windows Server"] = new()
{
["6.0"] = [ "2012", "2012-R2" ],
["7.0"] = [ "2012", "2012-R2" ],
["8.0"] = [ "2012", "2012-R2" ],
["9.0"] = [ "2012", "2012-R2" ]
},
["Windows Server Core"] = new()
{
["6.0"] = [ "2012", "2012-R2" ],
["7.0"] = [ "2012", "2012-R2" ],
["8.0"] = [ "2012", "2012-R2" ],
["9.0"] = [ "2012", "2012-R2" ]
}
},
["Linux"] = new()
{
["CentOS Stream"] = new()
{
["8.0"] = [ "8" ]
},
["Debian"] = new()
{
["6.0"] = [ "11" ],
["8.0"] = [ "12" ]
},
["Red Hat Enterprise Linux"] = new()
{
["8.0"] = [ "7" ]
}
}
};

string? baseUrl = args.Length > 1 ? args[1] : null;

string version = $"{majorVersion}.0";
Expand Down Expand Up @@ -84,15 +38,10 @@
}
foreach (var family in report.Families)
{
exceptions.TryGetValue(family.Name, out var familyExceptions);

foreach (var distribution in family.Distributions)
{
ExceptionsPerVersion? versionExceptions = null;
ExceptionalVersions? distroExceptions = null;
var distroName = distribution.Name;
familyExceptions?.TryGetValue(distroName, out versionExceptions);
versionExceptions?.TryGetValue(reportVersion, out distroExceptions);
var distroExceptions = distribution.Exceptions.ToDictionary(e => e.Version, e => e.Note);

foreach (var dVersion in distribution.ActiveReleasesEOLSoon)
{
Expand All @@ -116,9 +65,9 @@ static void ReportInvalidArgs()
Console.WriteLine("Expected: version [URL or Path, absolute or root location]");
}

void PrintIfNotExpected(string distroName, string distroVersion, ExceptionalVersions? distroExceptions, string text)
void PrintIfNotExpected(string distroName, string distroVersion, IReadOnlyDictionary<string, string> distroExceptions, string text)
{
if (distroExceptions?.Contains(distroVersion) == true) return;
if (distroExceptions?.ContainsKey(distroVersion) == true) return;

Console.WriteLine($"** {distroName} {distroVersion}: {text}");
}
4 changes: 3 additions & 1 deletion src/DotnetRelease/ReleaseReportRecords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@ public record ReportOverview(DateTime Timestamp, string Version, IList<ReportFam

public record ReportFamily(string Name, IList<ReportDistribution> Distributions);

public record ReportDistribution(string Name, IList<string> ActiveReleases, IList<string> ActiveReleasesUnsupported, IList<string> ActiveReleasesEOLSoon, IList<string> NotActiveReleasesSupported, IList<string> NotActiveReleasesUnsupported, IList<string> ReleasesMissing);
public record ReportDistribution(string Name, IList<string> ActiveReleases, IList<string> ActiveReleasesUnsupported, IList<string> ActiveReleasesEOLSoon, IList<string> NotActiveReleasesSupported, IList<string> NotActiveReleasesUnsupported, IList<string> ReleasesMissing, IList<ReportException> Exceptions);

Choose a reason for hiding this comment

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

IList<ReportException> Exceptions

Could we make this an IList<ExceptionalVersion> ? We can re-use the types from the other project and then we can simplify the code (no foreach).


public record ReportException(string Version, string Note);
12 changes: 12 additions & 0 deletions src/DotnetRelease/SupportedOSMatrixRecords.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,25 @@ public record SupportDistribution(
[Description("Once but not longer supported versions for distribution.")]
public IList<string>? UnsupportedVersions { get; set; } = null;

[Description("Versions that are handled differently compared to the lifecycle.")]
public IList<ExceptionalVersion>? ExceptionalVersions { get; set; } = null;

[Description("Link to lifecycle page for distribution.")]
public string? Lifecycle { get; set; } = null;

[Description("Support notes for distribution. For example, use notes if a given distribution architecture or version is only supported in certain circumstances.")]
public IList<string>? Notes { get; set; } = null;
}

[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
[Description("A version that has exceptional handling compared to the regular lifecycle.")]
public record ExceptionalVersion(
[property: Description("The version affected.")]
string Version,

[property: Description("Note describing the reason for special handling.")]
string Note);

[JsonUnmappedMemberHandling(JsonUnmappedMemberHandling.Disallow)]
[Description("Minimum supported libc versions, for both glibc and musl, with the allowance for different versions per architecture.")]
public record SupportLibc(
Expand Down
11 changes: 10 additions & 1 deletion src/ReleaseReport/ReleaseReportGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static async Task<ReportOverview> GetReportOverviewAsync(SupportedOSMatri
List<string> supportedUnActiveReleases = [];
List<string> unsupportedUnActiveReleases = [];
List<string> missingReleases = [];
List<ReportException> exceptions = [];

try
{
Expand Down Expand Up @@ -106,7 +107,15 @@ public static async Task<ReportOverview> GetReportOverviewAsync(SupportedOSMatri
}
}

ReportDistribution reportDistribution = new(distro.Name, activeReleases, unsupportedActiveRelease, soonEolReleases, supportedUnActiveReleases, unsupportedUnActiveReleases, missingReleases);
if (distro.ExceptionalVersions != null)
{
foreach (var exception in distro.ExceptionalVersions)
{
exceptions.Add(new ReportException(exception.Version, exception.Note));
}
}

ReportDistribution reportDistribution = new(distro.Name, activeReleases, unsupportedActiveRelease, soonEolReleases, supportedUnActiveReleases, unsupportedUnActiveReleases, missingReleases, exceptions);
reportFamily.Distributions.Add(reportDistribution);
}
}
Expand Down