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 bumper script #1968

Merged
merged 1 commit into from
Jan 9, 2025
Merged

Add bumper script #1968

merged 1 commit into from
Jan 9, 2025

Conversation

oshoval
Copy link
Collaborator

@oshoval oshoval commented Jan 7, 2025

What this PR does / why we need it:
Ease go package bumping.

Special notes for your reviewer:

Release note:

None

@kubevirt-bot kubevirt-bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. labels Jan 7, 2025
@oshoval
Copy link
Collaborator Author

oshoval commented Jan 7, 2025

cc @RamLavi
also please see my comment on the gist, about why i didnt add vet yet, we can add in case needed, under mentioned limitations

We can add logic that if make vet target exists, run it and then it must pass

hack/bumper.sh Outdated
git pull upstream "$(git symbolic-ref --short HEAD)"
go mod edit -dropreplace="${PACK}"
go mod edit -require="${TARGET_PACK}"
make vendor
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
make vendor
make fmt vet

make fmt already does vendor
make vet checks bump didn't brake anything

Copy link
Collaborator Author

@oshoval oshoval Jan 7, 2025

Choose a reason for hiding this comment

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

this script is meant to be generic, not just for CNAO,
i am not sure we have on all our repos fmt / vet

We dont even have vendor on all repos, i had a better version that handled this case
for example here we dont have make vendor
https://github.com/k8snetworkplumbingwg/ovs-cni/blob/main/Makefile#L90
The better version knew to check if make vendor exists, otherwise to run go mod tidy / go mod vendor
it also doesnt have fmt and vet named targets (it has make format instead)

so i prefer to not add it now, before we make sure it works all over
whoever needs can just run the additonal commands and amend
more info / options here #1968 (comment)

atm i would prefer to not block due to that

Copy link
Collaborator

@RamLavi RamLavi Jan 7, 2025

Choose a reason for hiding this comment

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

I think we should fail before the PR is created,
how about adding go vet $WHAT where WHAT is defaulted to ./pkg/...?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Even if we don't fail and just run later commit amend it is fine basically (of course we can optimize)
i am against adding something like go vet $WHAT, because on some repos we don't run go vet.
What i can do is add make vet if make vet target exists, this way it is generic and robust, as this script is intended

hack/bumper.sh Show resolved Hide resolved
@oshoval
Copy link
Collaborator Author

oshoval commented Jan 8, 2025

found the better script, lets continue from there (will add vet as done already with vendor there)

Ease go package bumping.

Signed-off-by: Or Shoval <[email protected]>
Copy link

sonarqubecloud bot commented Jan 8, 2025

@oshoval
Copy link
Collaborator Author

oshoval commented Jan 8, 2025

added the vet
script is bit more advance than the previous version, changes are based on cases i saw required once used it
please also notice the "reset" it does, so use only on repos where it fits

@oshoval
Copy link
Collaborator Author

oshoval commented Jan 9, 2025

/retest

@oshoval oshoval requested a review from RamLavi January 9, 2025 08:11
Copy link
Collaborator

@RamLavi RamLavi left a comment

Choose a reason for hiding this comment

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

Looks good overall,
Added some comments, PTAL.

rm -rf build/_output/
make vendor
else
go mod tidy
Copy link
Collaborator

Choose a reason for hiding this comment

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

should we do -compat=${desired_version}?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i would say not yet
because it was meant for OVS, which doesnt do it as well, so they should be the same
https://github.com/k8snetworkplumbingwg/ovs-cni/blob/main/Makefile#L91

btw what we can do for OVS, is to add make format if exists
https://github.com/k8snetworkplumbingwg/ovs-cni/blob/main/Makefile#L55
which does fmt / vet

Copy link
Collaborator

Choose a reason for hiding this comment

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

I would say on long term align, and on short term just add all options? wdyt?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

i would suggest please to start simple, as is
and adapt OVS / make sure all the other repos are aligned, and finally change this one, wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

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

yeah I'm good with that


# ./hack/bumper.sh CVE-2021-38561 golang.org/x/[email protected] release-0.89

# to skip semver check (for example in case package is dropped from go.mod after updating)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't get the scenario where SKIP would be true.
Why would we bump a package, and it would end up getting removed?

Copy link
Collaborator Author

@oshoval oshoval Jan 9, 2025

Choose a reason for hiding this comment

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

Nice question
for example if there was a static replace, which the script removes
https://github.com/kubevirt/cluster-network-addons-operator/pull/1968/files#diff-958372dc14cde9068a295622a0c8af96ac251e37b948589228f81ac0a7d0da6cR31
and once the script done, the new set doesn't need anymore the old package at all.

This what happened to me, so I added it.

Copy link
Collaborator

Choose a reason for hiding this comment

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

ah you mean there was a lonely replace without a require?

Copy link
Collaborator Author

@oshoval oshoval Jan 9, 2025

Choose a reason for hiding this comment

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

there were both (as far as i remember, anyhow it is the same thing, unless there isn't such thing replace without require)
the require was mandatory until some point, because else it conflicted,
but once the package could be updated, the script temporary updated it, removed the replace which enforce specific version, run make vendor, and then the package become unrequired at all given the new go.mod set
(auto removed by vendor it self)

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK I guess. I just never encountered this scenario before.

@RamLavi
Copy link
Collaborator

RamLavi commented Jan 9, 2025

/lgtm

@kubevirt-bot kubevirt-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 9, 2025
@oshoval
Copy link
Collaborator Author

oshoval commented Jan 9, 2025

Thanks
/approve

@kubevirt-bot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: oshoval

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

@kubevirt-bot kubevirt-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 9, 2025
@kubevirt-bot kubevirt-bot merged commit 8739346 into kubevirt:main Jan 9, 2025
15 checks passed
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. dco-signoff: yes Indicates the PR's author has DCO signed all their commits. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/M
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants