-
Notifications
You must be signed in to change notification settings - Fork 1
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
Extract release report #7
Open
Falco20019
wants to merge
7
commits into
richlander:main
Choose a base branch
from
Falco20019:extract-release-report
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
e831240
Add missing fields that make usage fail
Falco20019 7a08255
Extract ReleaseReportGenerator for easier usage in own stuff
Falco20019 97666dc
Use pre-calculated inputs on GetReportOverviewAsync
Falco20019 75b7a5f
Avoid default base url in code
Falco20019 6b2e55b
Add unsupported EOL entries to report
Falco20019 abb8419
Mark (EOL, Unlisted) as not covered
Falco20019 9f9e6d9
Remove unused usings
Falco20019 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\DotnetRelease\DotnetRelease.csproj" /> | ||
<ProjectReference Include="..\EndOfLifeDate\EndOfLifeDate.csproj" /> | ||
</ItemGroup> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using DotnetRelease; | ||
using EndOfLifeDate; | ||
|
||
public class ReleaseReportGenerator | ||
{ | ||
public static async Task<ReportOverview> GetReportOverviewAsync(SupportedOSMatrix? matrix, MajorReleaseOverview? majorRelease) | ||
{ | ||
string version = matrix?.ChannelVersion | ||
?? majorRelease?.ChannelVersion | ||
?? "0.0"; | ||
HttpClient client = new(); | ||
DateOnly threeMonthsDate = DateOnly.FromDateTime(DateTime.UtcNow.AddMonths(3)); | ||
DateOnly initialRelease = majorRelease?.Releases.FirstOrDefault(r => r.ReleaseVersion.Equals($"{version}.0"))?.ReleaseDate ?? DateOnly.MaxValue; | ||
DateOnly eolDate = majorRelease?.EolDate ?? DateOnly.MaxValue; | ||
ReportOverview report = new(DateTime.UtcNow, version, []); | ||
|
||
foreach (SupportFamily family in matrix?.Families ?? throw new Exception()) | ||
{ | ||
ReportFamily reportFamily = new(family.Name, []); | ||
report.Families.Add(reportFamily); | ||
|
||
foreach (SupportDistribution distro in family.Distributions) | ||
{ | ||
IList<SupportCycle>? cycles; | ||
List<string> activeReleases = []; | ||
List<string> unsupportedActiveRelease = []; | ||
List<string> soonEolReleases = []; | ||
List<string> supportedUnActiveReleases = []; | ||
List<string> unsupportedUnActiveReleases = []; | ||
List<string> missingReleases = []; | ||
|
||
try | ||
{ | ||
cycles = await EndOfLifeDate.Product.GetProduct(client, distro.Id); | ||
if (cycles is null) | ||
{ | ||
continue; | ||
} | ||
} | ||
catch (HttpRequestException) | ||
{ | ||
Console.WriteLine($"No data found at endoflife.date for: {distro.Id}"); | ||
Console.WriteLine(); | ||
continue; | ||
} | ||
|
||
foreach (SupportCycle cycle in cycles) | ||
{ | ||
SupportInfo support = cycle.GetSupportInfo(); | ||
// dotnet statements | ||
bool isSupported = distro.SupportedVersions.Contains(cycle.Cycle); | ||
bool isUnsupported = distro.UnsupportedVersions?.Contains(cycle.Cycle) ?? false; | ||
// EndofLife.Date statement | ||
bool isActive = support.IsActive; | ||
bool hasOverlappingLifecycle = initialRelease <= support.EolDate && cycle.ReleaseDate <= eolDate; | ||
|
||
if (isActive) | ||
{ | ||
activeReleases.Add(cycle.Cycle); | ||
} | ||
|
||
/* | ||
Cases (EOLDate, dotnet): | ||
1. (Active, Supported) | ||
2. (Active, Unsupported) | ||
3. (OverlappingLifecycle, Unlisted) | ||
4. (EOL, Supported) | ||
5. (Active - EolSoon, Supported) | ||
6. (EOL, Unsupported | Unlisted) | ||
// these are not covered | ||
7. (Listed, Unlisted) | ||
8. (Unlisted, Listed) | ||
*/ | ||
|
||
// Case 1 | ||
if (isActive && isSupported) | ||
{ | ||
// nothing to do | ||
} | ||
// Case 2 | ||
else if (isActive && isUnsupported) | ||
{ | ||
unsupportedActiveRelease.Add(cycle.Cycle); | ||
} | ||
// Case 3 | ||
else if (hasOverlappingLifecycle && !isSupported && !isUnsupported) | ||
{ | ||
missingReleases.Add(cycle.Cycle); | ||
} | ||
// Case 4 | ||
else if (!isActive && isSupported) | ||
{ | ||
supportedUnActiveReleases.Add(cycle.Cycle); | ||
} | ||
// Case 6 | ||
else if (!isActive && !isSupported) | ||
{ | ||
unsupportedUnActiveReleases.Add(cycle.Cycle); | ||
} | ||
|
||
// Case 5 | ||
if (isActive && support.EolDate < threeMonthsDate) | ||
{ | ||
soonEolReleases.Add(cycle.Cycle); | ||
} | ||
} | ||
|
||
ReportDistribution reportDistribution = new(distro.Name, activeReleases, unsupportedActiveRelease, soonEolReleases, supportedUnActiveReleases, missingReleases); | ||
reportFamily.Distributions.Add(reportDistribution); | ||
} | ||
} | ||
|
||
return report; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having that case would allow me to check for former supported versions and adding them to a table. That's the only thing that was blocking me from using this report directly and needing to duplicate the whole logic.