-
Notifications
You must be signed in to change notification settings - Fork 158
Configure GeneratePackageVersions to support a "cooldown" on dependencies
#8371
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
553c11c
Configure package version update with delay
bouwkast ba6e3a8
Update nuget_version_cache
bouwkast 98af288
Run GeneratePackageVersions
bouwkast 48131da
Fix to add OpenFeature to udpater
bouwkast f194451
Decrease default cooldown period to 2 days
bouwkast a976fcc
Re-enable the auto_bump_test_package_versions
bouwkast c71f249
Address PR comments
bouwkast 7921ed4
Change default cooldown to 0 when --IncludePackages is provided
bouwkast 580786b
Scope cooldown baseline to entry version range for split-range packages
bouwkast 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
89 changes: 89 additions & 0 deletions
89
tracer/build/_build/GeneratePackageVersions/CooldownReport.cs
This file contains hidden or 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,89 @@ | ||
| // <copyright file="CooldownReport.cs" company="Datadog"> | ||
| // Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
| // This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
| // </copyright> | ||
|
|
||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.IO; | ||
| using System.Text; | ||
| using System.Threading.Tasks; | ||
|
|
||
| namespace GeneratePackageVersions; | ||
|
|
||
| /// <summary> | ||
| /// Collects package versions that were excluded by the cooldown filter | ||
| /// and renders them as a markdown report for inclusion in the PR body. | ||
| /// </summary> | ||
| public class CooldownReport | ||
| { | ||
| private readonly int _cooldownDays; | ||
| private readonly List<CooldownEntry> _entries = new(); | ||
| private readonly HashSet<(string PackageName, string Version)> _seen = new(); | ||
|
|
||
| public CooldownReport(int cooldownDays) | ||
| { | ||
| _cooldownDays = cooldownDays; | ||
| } | ||
|
|
||
| public bool HasEntries => _entries.Count > 0; | ||
|
|
||
| public IReadOnlyList<CooldownEntry> Entries => _entries; | ||
|
|
||
| public void Add(CooldownEntry entry) | ||
| { | ||
| // Deduplicate: the same version gets flagged once per framework and per selection group, | ||
| // but we only need to report it once. | ||
| if (_seen.Add((entry.PackageName, entry.OverriddenVersion))) | ||
| { | ||
| _entries.Add(entry); | ||
| } | ||
| } | ||
|
|
||
| public string ToMarkdown() | ||
| { | ||
| if (_entries.Count == 0) | ||
| { | ||
| return string.Empty; | ||
| } | ||
|
|
||
| var sb = new StringBuilder(); | ||
| sb.AppendLine($"## Package Version Cooldown Report"); | ||
| sb.AppendLine(); | ||
| sb.AppendLine($"The following versions were published less than **{_cooldownDays} days** ago and have been overridden."); | ||
| sb.AppendLine("These require manual review before inclusion."); | ||
| sb.AppendLine(); | ||
| sb.AppendLine("| Package | Integration | Overridden Version | Published | Age (days) | Using Instead |"); | ||
| sb.AppendLine("|---------|-------------|--------------------|-----------|------------|---------------|"); | ||
|
|
||
| foreach (var entry in _entries) | ||
| { | ||
| var published = entry.PublishedDate?.ToString("yyyy-MM-dd") ?? "unknown"; | ||
| var age = entry.PublishedDate.HasValue | ||
| ? ((int)(DateTimeOffset.UtcNow - entry.PublishedDate.Value).TotalDays).ToString() | ||
| : "?"; | ||
| var usingInstead = entry.ResolvedVersion ?? "(skipped)"; | ||
|
|
||
| sb.AppendLine($"| {entry.PackageName} | {entry.IntegrationName} | {entry.OverriddenVersion} | {published} | {age} | {usingInstead} |"); | ||
| } | ||
|
|
||
| return sb.ToString(); | ||
| } | ||
|
|
||
| public async Task SaveToFile(string path) | ||
| { | ||
| var markdown = ToMarkdown(); | ||
| if (!string.IsNullOrEmpty(markdown)) | ||
| { | ||
| // necessary to save to a file so that we can then output it in the PR description | ||
| await File.WriteAllTextAsync(path, markdown); | ||
| } | ||
| } | ||
|
|
||
| public record CooldownEntry( | ||
| string PackageName, | ||
| string IntegrationName, | ||
| string OverriddenVersion, | ||
| DateTimeOffset? PublishedDate, | ||
| string ResolvedVersion); | ||
| } |
Oops, something went wrong.
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.
Building
baselineas a single max tested version per package lets newer versions in lower compatibility ranges bypass the cooldown check.PackageVersionsGeneratorDefinitions.jsoncontains multiple entries for the same package with different ranges (for example,GraphQLhas4.1.0-6.0.0and7.0.0-9.0.0), so a high tested baseline from one range (e.g., 8.x) makes all 5.x versions satisfyversion <= baselineinApplyCooldown, even when they were published within the cooldown window. That defeats the remediation goal for split-range packages; baseline needs to be keyed by the specific entry/range (or assembly+package) instead of package name alone.Useful? React with 👍 / 👎.