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

fix: Rework git tag semver resolution (#20083) #20096

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

PaulSonOfLars
Copy link
Contributor

Testing a potential fix for #20083, where ArgoCD's semver resolution is too lax, which causes non-semver tags to be incorrectly coerced into semver. This then causes unexpected tags to be used when they shouldn't be.

Checklist:

  • Either (a) I've created an enhancement proposal and discussed it with the community, (b) this is a bug fix, or (c) this does not need to be in the release notes.
  • The title of the PR states what changed and the related issues number (used for the release note).
  • The title of the PR conforms to the Toolchain Guide
  • I've included "Closes [ISSUE #]" or "Fixes [ISSUE #]" in the description to automatically close the associated issue.
  • I've updated both the CLI and UI to expose my feature, or I plan to submit a second PR with them.
  • Does this PR require documentation updates?
  • I've updated documentation as required by this PR.
  • I have signed off all my commits as required by DCO
  • I have written unit and/or e2e tests for my change. PRs without these are unlikely to be merged.
  • My build is green (troubleshooting builds).
  • My new feature complies with the feature status guidelines.
  • I have added a brief description of why this PR is necessary and/or what this PR solves.
  • Optional. My organization is added to USERS.md.
  • Optional. For bug fixes, I've indicated what older releases this fix should be cherry-picked into (this may or may not happen depending on risk/complexity).

Copy link

bunnyshell bot commented Sep 25, 2024

❗ Preview Environment deployment failed on Bunnyshell

See: Environment Details | Pipeline Logs

Available commands (reply to this comment):

  • 🚀 /bns:deploy to redeploy the environment
  • /bns:delete to remove the environment

Copy link

bunnyshell bot commented Sep 25, 2024

✅ Preview Environment created on Bunnyshell but will not be auto-deployed

See: Environment Details

Available commands (reply to this comment):

  • 🚀 /bns:deploy to deploy the environment

@PaulSonOfLars PaulSonOfLars changed the title Testing strict semver functionality (#20083) fix: Testing strict semver functionality (#20083) Sep 25, 2024
Copy link
Contributor

@nitishfy nitishfy left a comment

Choose a reason for hiding this comment

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

can you fix the CI failures?

@PaulSonOfLars
Copy link
Contributor Author

@nitishfy apologies for that, the PR is just aiming to be a draft for now - to see if the silly basic approach would work against the full testsuite (onboarding and spinning up the tests locally is quite painful if you're not a regular contributor!). Clearly it doesn't!

I've now narrowed down on the exact issue, and should be able to make the git semver logic match the helm logic, avoiding any big "breaking" changes.

I'll aim to have that in a proper PR open with tests and the actual fix later tonight, ready for tomorrow's contributors meeting.

@PaulSonOfLars PaulSonOfLars marked this pull request as ready for review September 25, 2024 16:53
@PaulSonOfLars PaulSonOfLars requested review from a team as code owners September 25, 2024 16:53
Copy link

codecov bot commented Sep 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.86%. Comparing base (fa54ce2) to head (0672dac).

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #20096      +/-   ##
==========================================
+ Coverage   55.84%   55.86%   +0.01%     
==========================================
  Files         321      321              
  Lines       44497    44501       +4     
==========================================
+ Hits        24851    24860       +9     
+ Misses      17075    17074       -1     
+ Partials     2571     2567       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -723,6 +731,7 @@ func (m *nativeGitClient) resolveSemverRevision(constraint *semver.Constraints,
return ""
}

log.Infof("Semver constraint '%s' resolved to tag '%s', at reference '%s'", revision, maxVersion.Original(), maxVersionHash.String())
Copy link
Member

Choose a reason for hiding this comment

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

Should we make this a debug log?

Copy link
Member

@blakepettersson blakepettersson left a comment

Choose a reason for hiding this comment

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

I agree with @rumstead's comment, otherwise LGTM. To unblock this error I'd ship this as-is, but I would like to see a follow-up PR which consolidates this with the Helm semver resolution.

@PaulSonOfLars PaulSonOfLars changed the title fix: Testing strict semver functionality (#20083) fix: Rework git tag semver resolution (#20083) Sep 29, 2024
Copy link
Member

@gdsoumya gdsoumya left a comment

Choose a reason for hiding this comment

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

LGTM

Comment on lines +214 to +253
name: "pinned rc version",
ref: "v1.0.0-rc1",
expected: mapTagRefs["v1.0.0-rc1"],
}, {
name: "lt rc constraint",
ref: "< v1.0.0-rc3",
expected: mapTagRefs["v1.0.0-rc2"],
}, {
name: "pinned major version",
ref: "v1.0.0",
expected: mapTagRefs["v1.0.0"],
}, {
name: "pinned patch version",
ref: "v1.0.1",
expected: mapTagRefs["v1.0.1"],
}, {
name: "pinned minor version",
ref: "v1.1.0",
expected: mapTagRefs["v1.1.0"],
}, {
name: "patch wildcard constraint",
ref: "v1.0.*",
expected: mapTagRefs["v1.0.1"],
}, {
name: "patch tilde constraint",
ref: "~v1.0.0",
expected: mapTagRefs["v1.0.1"],
}, {
name: "minor wildcard constraint",
ref: "v1.*",
expected: mapTagRefs["v1.1.0"],
}, {
name: "minor gte constraint",
ref: ">= v1.0.0",
expected: mapTagRefs["v1.1.0"],
}, {
name: "multiple constraints",
ref: "> v1.0.0 < v1.1.0",
expected: mapTagRefs["v1.0.1"],
}, {
Copy link
Member

@gdsoumya gdsoumya Sep 30, 2024

Choose a reason for hiding this comment

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

According to the definition of a constraint in https://github.com/Masterminds/semver something like 4.1 can also be considered a constraint which can match any 4.1.x while at the same time it's also a valid semver.Version that translates to 4.1.0. This can still cause ambiguity, might require some proper documentation on this behaviour.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Changes Requested
Development

Successfully merging this pull request may close these issues.

5 participants