-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Run test-go-mod
on local modules
#4975
Conversation
/cc @natasha41575 |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: annasong20, yuwenma 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 |
/lgtm cc @koba1t who made the go workspace improvements for kustomize. |
/cc @koba1t |
9ece1fc
to
7a64e19
Compare
This PR has multiple commits, and the default merge method is: merge. 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. |
New changes are detected. LGTM label has been removed. |
/label tide/merge-method-squash |
7a64e19
to
4a962c8
Compare
test-go-mod
on local modules
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.
The test-go-mod
rule should now add replace
statements, run go mod tidy
, then remove said replace
statements on all modules.
I left my concerns below.
read -a modules <<< $(go list -m) | ||
read -a module_paths <<< $(go list -m -f {{.Dir}}) |
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.
I'd like to move this into Makefile
to avoid re-calculating it for each module, but I don't know how to export variables in Makefile
so that they're accessible here.
read -a modules <<< $(go list -m) | ||
read -a module_paths <<< $(go list -m -f {{.Dir}}) |
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.
I'm assuming go list -m
returns the modules in the same order on every call.
I've considered 2 alternatives:
go list -m -json
returns all information, including name and directory path, for all modules, but I'd have to parse the json output- fetch the module name as I navigate to each module with
hack/for-each-module.sh
; however,go list -m
lists all modules in the workspace regardless of the working directory, so the best I could come up with was parsing thego.mod
file for the module name
./hack/for-each-module.sh $$(pwd)/hack/replace.sh; \ | ||
./hack/for-each-module.sh "go mod tidy -v"; \ | ||
./hack/for-each-module.sh $$(pwd)/hack/dropReplace.sh |
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.
I tried inlining the scripts in replace.sh
and dropReplace.sh
, but couldn't figure out how to escape the relevant characters.
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.
I think calling a script from here is better than inlining the details anyway. :)
I'd suggest making a single script we can invoke from here like ./hack/for-each-module.sh "\$$KUSTOMIZE_ROOT/hack/go-mod-tidy-kust-dev.sh"
and then adding a bunch of comments in that file to explain the steps and why we're doing them. Or to be more flexible, we can make a script that itself takes a command to run in the context of the "pinned" module, invoked like: ./hack/for-each-module.sh "\$$KUSTOMIZE_ROOT/hack/with-pinned-kust-dev.sh 'go mod tidy -v'"
.
@@ -152,7 +152,9 @@ functions-examples-all: | |||
done | |||
|
|||
test-go-mod: | |||
./hack/for-each-module.sh "go list -m -json all > /dev/null && go mod tidy -v" | |||
./hack/for-each-module.sh $$(pwd)/hack/replace.sh; \ |
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.
I tried using $$KUSTOMIZE_ROOT
instead of $$(pwd)
, but couldn't figure out how to use the exported hack/for-each-module.sh
variable here.
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.
I think "\$$KUSTOMIZE_ROOT/hack/...
should work!
Closing because #5011 will merge soon |
This PR comments out thetest-go-mod
prow-presubmit job.This PR changes
test-go-mod
so thatgo mod tidy
is run with local module dependencies instead of the latest released modules. This makes the CI much friendlier to changes that across multiple modules.The failed job as a result of cross-module changes in #4959 motivated this change.