-
Notifications
You must be signed in to change notification settings - Fork 407
Improve go mod checks with hack/verify-go-modules.sh #3373
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
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
I'll push a separate PR that gets go mod in line with what this script expects. |
hack/verify-go-modules.sh
Outdated
mapfile -t DIRS < <(find "${REPO_ROOT}" -name go.mod -print0 | xargs -0 dirname) | ||
# This is the list of directories that host the individual kcp go modules. | ||
# | ||
# KEEP IT UP TO DATE and SORTED! |
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.
You might consider using go list
from the root to a) get a full list of modules and b) build the DAG for dependencies, so that keeping the list in order and updated is not a human problem.
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.
Yeah I was also thinking about that too, but then we have only a couple of these nested go modules in the repo so I wasn't sure if that warrants all the code complexity that would bring. If I have time I could push this in a separate commit to see the diff and decide?
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.
Adding a Go workspace at the root would make it pretty simple as well. Up to you
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.
@stevekuznetsov I've pushed 4a0a660 that generates the list and sorts it. Does that look more or less reasonable?
4a0a660
to
583c0f4
Compare
The more I look at this the more I wonder if it's a good idea? Tests are currently failing for I'm mostly concerned about vulnerable dependencies we need to upgrade to pull in a patch (as is sometimes the case with I can see why we initially wanted to do this in previous issues / PRs, but would better test coverage maybe be the way to go here? |
I think this could he helpers script to check this , but does not do this blocking way. This way we still have flexibility to "deviate" when we need to (due to security reasons). |
@gman0 already added this in #3312, check out e.g. https://public-prow.kcp.k8c.io/view/s3/prow-public-data/pr-logs/pull/kcp-dev_kcp/3380/pull-kcp-verify/1912205336006103040#1:build-log.txt%3A219. |
That's all good points Marvin, thanks! While that's true that the stdlib dependencies should be exempt from the checks, we still could check dependencies to modules from k8s.io and make sure they are in line? Otherwise I could revert the exiting on failure functionality in this PR and we leave it as a warning if that would be better? This PR checks that gomod files are tidy'd, and i think that's an improvement. |
I think this is a good point. It might make sense to do this for |
Now the output looks like this:
|
The script now exits with an error if go.mod and/or go.sum are dirty, or if dependencies from '*k8s.io/*' pull in different versions than the ones used in k8s.io/kubernetes. On-behalf-of: SAP [email protected] Signed-off-by: Robert Vasek <[email protected]>
a07094e
to
2fea1a2
Compare
On-behalf-of: SAP [email protected] Signed-off-by: Robert Vasek <[email protected]>
/test pull-kcp-test-e2e-multiple-runs |
Is this new? |
/test pull-kcp-test-e2e-multiple-runs |
@gman0: The following test failed, say
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. I understand the commands that are listed here. |
Summary
This PR makes it so that:
go mod tidy -diff
),/kind feature
Part of: #3375
Release Notes