Repository navigation
Refactor duplicated base64-encoded retry-artifact manifest logic #11574
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 all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
15b5364
Initial plan
Copilot 5af974d
Share retry artifact manifest protocol
Copilot 7e1f42c
Clarify manifest decode boundaries
Copilot 87f662f
Clarify encoded manifest kind contract
Copilot 97bf38d
Make manifest split contract explicit
Copilot 846b4a9
Clarify manifest null-kind sentinel
Copilot d19e291
Add WriteEntry API and migrate report writer to shared manifest helper
Copilot ea0a25f
Test retry artifact manifest writers
Copilot 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
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
49 changes: 49 additions & 0 deletions
49
src/Platform/SharedExtensionHelpers/RetryArtifactManifest.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,49 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
|
||
| namespace Microsoft.Testing.Extensions; | ||
|
|
||
| #pragma warning disable RS0051 // Recovery infrastructure is shared-source implementation detail, not package API. | ||
|
|
||
| internal static class RetryArtifactManifest | ||
| { | ||
| public const long MaxBytes = 16L * 1024 * 1024; | ||
| public const int MaxLineLength = 64 * 1024; | ||
| public const int MaxRecords = 10_000; | ||
|
|
||
| public static bool TrySplitEntry( | ||
| string line, | ||
| [NotNullWhen(true)] out string? encodedPath, | ||
| [NotNullWhen(true)] out string? encodedKindOrNullSentinel) | ||
| { | ||
| int separatorIndex = line.IndexOf('\t'); | ||
| if (separatorIndex <= 0) | ||
| { | ||
| encodedPath = null; | ||
| encodedKindOrNullSentinel = null; | ||
| return false; | ||
| } | ||
|
|
||
| encodedPath = line.Substring(0, separatorIndex); | ||
| encodedKindOrNullSentinel = line.Substring(separatorIndex + 1); | ||
| return true; | ||
| } | ||
|
|
||
| public static string DecodePath(string encodedPath) | ||
| => Encoding.UTF8.GetString(Convert.FromBase64String(encodedPath)); | ||
|
|
||
| public static string? DecodeKind(string encodedKindOrNullSentinel) | ||
| => encodedKindOrNullSentinel == "-" | ||
| ? null | ||
| : Encoding.UTF8.GetString(Convert.FromBase64String(encodedKindOrNullSentinel)); | ||
|
|
||
| public static string WriteEntryWithEncodedKind(string path, string encodedKindOrNullSentinel) | ||
| => $"{Convert.ToBase64String(Encoding.UTF8.GetBytes(path))}\t{encodedKindOrNullSentinel}"; | ||
|
|
||
| public static string WriteEntry(string path, string? kind) | ||
| => WriteEntryWithEncodedKind( | ||
|
Evangelink marked this conversation as resolved.
Resolved
|
||
| path, | ||
| kind is null ? "-" : Convert.ToBase64String(Encoding.UTF8.GetBytes(kind))); | ||
| } | ||
|
|
||
| #pragma warning restore RS0051 | ||
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.
Uh oh!
There was an error while loading. Please reload this page.