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

Set GitHub release as latest if target release is highest semver #3559

Merged
merged 1 commit into from
Apr 10, 2024

Conversation

embik
Copy link
Member

@embik embik commented Apr 5, 2024

What type of PR is this?

/kind feature

What this PR does / why we need it:

This PR attempts to implement heuristics to determine if a GitHub release created by krel (and other tools using pkg/announce?) should be marked as "latest". It's an overdue follow-up to the extension of release-sdk in kubernetes-sigs/release-sdk#288 that added a field to mark a GitHub release as latest.

The idea here is: Unless a release is a pre-release, we start with the assumption that "our" release is the latest one. Since we already query the first page of GitHub releases for determining if this is an existing or new release, my changes now extend that loop and compare our version to the already existing releases by doing a semver parse and comparison.

As soon as we have determined our release is not the latest, this check will be skipped.

Since there doesn't seem to be an easy way to test krel, I think this makes sense but I hope it gets scrutinised appropriately during review.

Which issue(s) this PR fixes:

Towards kubernetes/kubernetes#119472

Special notes for your reviewer:

Does this PR introduce a user-facing change?

Mark GitHub release as latest if no newer releases were found

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-priority labels Apr 5, 2024
@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 5, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @embik!

It looks like this is your first PR to kubernetes/release 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes/release has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot
Copy link
Contributor

Hi @embik. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added area/release-eng Issues or PRs related to the Release Engineering subproject sig/release Categorizes an issue or PR as relevant to SIG Release. labels Apr 5, 2024
@embik
Copy link
Member Author

embik commented Apr 5, 2024

/cc @xmudrii

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 5, 2024
@embik embik changed the title Set GitHub release as 'latest' if target release is newest Set GitHub release as latest if target release is highest server Apr 5, 2024
@embik embik changed the title Set GitHub release as latest if target release is highest server Set GitHub release as latest if target release is highest semver Apr 5, 2024
@cpanato
Copy link
Member

cpanato commented Apr 5, 2024

can we add tests?

@cpanato
Copy link
Member

cpanato commented Apr 5, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 5, 2024
@embik
Copy link
Member Author

embik commented Apr 5, 2024

can we add tests?

Sure thing. I'll need to figure out where I can place tests since the pkg/announce package doesn't have them, but I'll try to find a way to test this.

Copy link
Member

@xmudrii xmudrii left a comment

Choose a reason for hiding this comment

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

Thank you for this contribution, @embik!
I left a comment about if we should consider an alternative approach, but even this looks fine so we can give it a try. Just please add tests as requested by @cpanato and let us know if you need any help with that.

pkg/announce/github_page.go Show resolved Hide resolved
@xmudrii
Copy link
Member

xmudrii commented Apr 8, 2024

@cpanato I looked into adding tests together with @embik and I don't think it's doable at the moment. This package doesn't follow our usual pattern of using mock-able interfaces, so writing tests for it would require significant effort, mainly to refactor the whole package to adhere to the pattern that we use elsewhere.

This is also a bit though situation, even if @embik adds tests, the actual calls to GitHub will be mocked and we wouldn't know if it works properly. We should try to do some coordinated test in production, e.g. try this for some release that's not that much time sensitive.

I propose accepting this without tests once we're happy with the code and creating a follow up issue to refactor the package and write tests for it.

@cpanato
Copy link
Member

cpanato commented Apr 9, 2024

@cpanato I looked into adding tests together with @embik and I don't think it's doable at the moment. This package doesn't follow our usual pattern of using mock-able interfaces, so writing tests for it would require significant effort, mainly to refactor the whole package to adhere to the pattern that we use elsewhere.

This is also a bit though situation, even if @embik adds tests, the actual calls to GitHub will be mocked and we wouldn't know if it works properly. We should try to do some coordinated test in production, e.g. try this for some release that's not that much time sensitive.

I propose accepting this without tests once we're happy with the code and creating a follow up issue to refactor the package and write tests for it.

thanks

@xmudrii
Copy link
Member

xmudrii commented Apr 9, 2024

I created #3565 to follow up on refactoring the package

Signed-off-by: Marvin Beckers <mail@embik.me>
Copy link
Member

@xmudrii xmudrii left a comment

Choose a reason for hiding this comment

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

After doing extensive rubber ducking session with Marvin, this looks fine to me. Thank you very much for bearing with my comments, and for this contribution of course!
/lgtm
/approve
/hold
@cpanato Are we good to merge this with tests to follow up later on?

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 9, 2024
@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Apr 9, 2024
Copy link
Member

@cpanato cpanato left a comment

Choose a reason for hiding this comment

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

if this wil not impact in the existing workflow i am fine

/lgtm
/hold @xmudrii lift when you are ready

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cpanato, embik, xmudrii

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@xmudrii
Copy link
Member

xmudrii commented Apr 10, 2024

Thank you once again, @embik!
/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 10, 2024
@k8s-ci-robot k8s-ci-robot merged commit 3cf5251 into kubernetes:master Apr 10, 2024
11 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.30 milestone Apr 10, 2024
@embik embik deleted the mark-latest-release-gh branch April 10, 2024 10:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. area/release-eng Issues or PRs related to the Release Engineering subproject cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-priority ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/release Categorizes an issue or PR as relevant to SIG Release. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants