-
Notifications
You must be signed in to change notification settings - Fork 0
Version 1.1.1 #5
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
3 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| using System.Xml.Linq; | ||
|
|
||
| namespace Seek.Cli.Tests; | ||
|
|
||
| public sealed partial class ToolPackagingTests { | ||
| [Test] | ||
| public async Task CliProject_ToolPackageRuntimeIdentifiers_ExcludeWindowsRidPackages(CancellationToken cancellationToken) { | ||
| var projectContents = await File.ReadAllTextAsync( | ||
| Path.Combine(FindRepositoryRoot(), "src", "Seek.Cli", "Seek.Cli.csproj"), | ||
| cancellationToken); | ||
|
|
||
| var runtimeIdentifiers = ParseToolPackageRuntimeIdentifiers(projectContents); | ||
|
|
||
| await Assert.That(runtimeIdentifiers).Contains("linux-x64"); | ||
| await Assert.That(runtimeIdentifiers).Contains("linux-arm64"); | ||
| await Assert.That(runtimeIdentifiers).Contains("osx-x64"); | ||
| await Assert.That(runtimeIdentifiers).Contains("osx-arm64"); | ||
| await Assert.That(runtimeIdentifiers).Contains("any"); | ||
| await Assert.That(runtimeIdentifiers).DoesNotContain("win-x64"); | ||
| await Assert.That(runtimeIdentifiers).DoesNotContain("win-arm64"); | ||
| } | ||
|
|
||
| [Test] | ||
| public async Task PublishReleaseWorkflow_NugetRidMatrix_SkipsWindowsRidPackagesButKeepsWindowsBinaryReleases(CancellationToken cancellationToken) { | ||
| var workflowContents = await File.ReadAllTextAsync( | ||
| Path.Combine(FindRepositoryRoot(), ".github", "workflows", "publish-release.yml"), | ||
| cancellationToken); | ||
|
|
||
| var nugetRidSection = ExtractSection(workflowContents, "nuget-rid", "nuget-publish"); | ||
| var binariesSection = ExtractSection(workflowContents, "binaries", string.Empty); | ||
|
|
||
| await Assert.That(nugetRidSection).Contains("linux-x64"); | ||
| await Assert.That(nugetRidSection).Contains("linux-arm64"); | ||
| await Assert.That(nugetRidSection).Contains("osx-x64"); | ||
| await Assert.That(nugetRidSection).Contains("osx-arm64"); | ||
| await Assert.That(nugetRidSection).DoesNotContain("win-x64"); | ||
| await Assert.That(nugetRidSection).DoesNotContain("win-arm64"); | ||
|
|
||
| await Assert.That(binariesSection).Contains("win-x86"); | ||
| await Assert.That(binariesSection).Contains("win-x64"); | ||
| await Assert.That(binariesSection).Contains("win-arm64"); | ||
| } | ||
|
|
||
| private static string FindRepositoryRoot() { | ||
| for (var current = new DirectoryInfo(AppContext.BaseDirectory); current is not null; current = current.Parent) { | ||
| var projectPath = Path.Combine(current.FullName, "src", "Seek.Cli", "Seek.Cli.csproj"); | ||
| var workflowPath = Path.Combine(current.FullName, ".github", "workflows", "publish-release.yml"); | ||
| if (File.Exists(projectPath) && File.Exists(workflowPath)) { | ||
| return current.FullName; | ||
| } | ||
| } | ||
|
|
||
| throw new DirectoryNotFoundException("Could not locate the repository root from the test output directory."); | ||
| } | ||
|
|
||
| private static string[] ParseToolPackageRuntimeIdentifiers(string projectContents) { | ||
| var project = XDocument.Parse(projectContents); | ||
| var runtimeIdentifiers = project.Root? | ||
| .Elements() | ||
| .Where(element => element.Name.LocalName == "PropertyGroup") | ||
| .Elements() | ||
| .FirstOrDefault(element => element.Name.LocalName == "ToolPackageRuntimeIdentifiers") | ||
| ?.Value; | ||
|
|
||
| if (string.IsNullOrWhiteSpace(runtimeIdentifiers)) { | ||
| throw new InvalidOperationException("Could not find ToolPackageRuntimeIdentifiers in Seek.Cli.csproj."); | ||
| } | ||
|
|
||
| return runtimeIdentifiers | ||
| .Split(';', StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries); | ||
| } | ||
|
|
||
| private static string ExtractSection(string contents, string sectionName, string nextSectionName) { | ||
| var sectionHeader = $"{sectionName}:"; | ||
| var startIndex = contents.IndexOf(sectionHeader, StringComparison.Ordinal); | ||
| if (startIndex < 0) { | ||
| throw new InvalidOperationException($"Could not find the {sectionName} section in publish-release.yml."); | ||
| } | ||
|
|
||
| var sectionStart = startIndex + sectionHeader.Length; | ||
| if (nextSectionName.Length == 0) { | ||
| return contents[sectionStart..]; | ||
| } | ||
|
|
||
| var nextSectionHeader = $"{nextSectionName}:"; | ||
| var endIndex = contents.IndexOf(nextSectionHeader, sectionStart, StringComparison.Ordinal); | ||
| if (endIndex < 0) { | ||
| throw new InvalidOperationException($"Could not find the {nextSectionName} section in publish-release.yml."); | ||
| } | ||
|
|
||
| return contents[sectionStart..endIndex]; | ||
| } | ||
| } |
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.
If
WINGET_PACKAGE_IDENTIFIERis configured butWINGET_TOKENis absent (for example after a secret rotation or in another release environment), this step is simply skipped and the job still finishes green because it has no other work. That leaves the GitHub release published but WinGet stale with no signal to the releaser that the install channel was not updated.Useful? React with 👍 / 👎.
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.
Initial winget release needs to be manual. As such the
WINGET_PACKAGE_IDENTIFIERwas removed on purpose to skip this part.After the manual PR to winget packages was made, the variable was added to the repo to be used in the future.