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

Add failing test for bug in GetLatestMaskedVersion #77

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

borland
Copy link
Contributor

@borland borland commented Dec 19, 2024

No description provided.

// Now the real test; it should still return the same result even if the versions are not in the correct order
var reversedVersions = versions.ToList();
reversedVersions.Reverse();
Assert.AreEqual("0.0.7+branchA.1", mask.GetLatestMaskedVersion(reversedVersions)!.ToString());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This currently returns 0.0.7+branchA instead of A.1

Copy link
Contributor

Choose a reason for hiding this comment

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

The Semver spec says that version metadata (everything after +) shouldn't affect precedence:

Build metadata MUST be ignored when determining version precedence. Thus two versions that differ only in the build metadata, have the same precedence. Examples: 1.0.0-alpha+001, 1.0.0+20130313144700, 1.0.0-beta+exp.sha.5114f85, 1.0.0+21AF26D3----117B344092BD.

https://semver.org/#spec-item-10

Copy link
Contributor Author

@borland borland Feb 19, 2025

Choose a reason for hiding this comment

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

Be that as it may, the side-effect of indeterminate precedence is that in Octopus, when it tries to do auto-deploy or other things the release it selects is nondeterministic where two builds with the same version but different metadata happens. It just picks whatever happens to come out of SQL server first which is not reliable from a customer perspective.

If we don't want deterministic ordering in our library here, then we'll need to make some compensating change for it in Octopus instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem here stems from OctopusVersionMask.CompareTo(object). We have tests here ensuring that version metadata doesn't affect versioning (OctopusVersionCompareTests.TestVersionComparisons(...)). I'm inclined to leave the tests as-is, and instead create a new GetLatestMaskedVersions method that returns all versions considered to be "latest". Then we can let Octopus decide how to handle that. What are your thoughts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants