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

Define scripts/ as a submodule #2141

Merged
merged 3 commits into from
Jun 10, 2020

Conversation

chizhg
Copy link
Member

@chizhg chizhg commented Jun 2, 2020

What this PR does, why we need it:
I did some experiment with Go multiple modules to vendor scripts/, and did not see any issues.

The only changes needed in each repo will be changing the floating deps from knative.dev/test-infra to knative.dev/test-infra/scripts in for example https://github.com/knative/serving/blob/master/hack/update-deps.sh#L35. And even if it's not changed, it can still work in the old way.

Which issue(s) this PR fixes:
Fixes #2078

/cc @chaodaiG @albertomilan

@googlebot googlebot added the cla: yes Indicates the PR's author has signed the CLA. label Jun 2, 2020
@knative-prow-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: chizhg

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

@knative-prow-robot knative-prow-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 2, 2020
@chaodaiG
Copy link
Contributor

chaodaiG commented Jun 2, 2020

Looks promising, can you fix the build error first?

@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 3, 2020
@chizhg chizhg force-pushed the define-scripts-module branch 3 times, most recently from bf3d5fa to b065380 Compare June 3, 2020 05:07
@chizhg
Copy link
Member Author

chizhg commented Jun 3, 2020

Looks promising, can you fix the build error first?

I didn't find an elegant way to fix the build error. It seems go build -v ./... cannot work with a repo that has multiple Go modules and will get an error go: directory scripts is outside main module, I'm not getting the error when I run the command locally though...

I think we can just skip building the submodule it contains mainly scripts, and since we are already skipping a few directories, the approach is not that dirty.

@chaodaiG
Copy link
Contributor

chaodaiG commented Jun 3, 2020

Looks promising, can you fix the build error first?

I didn't find an elegant way to fix the build error. It seems go build -v ./... cannot work with a repo that has multiple Go modules and will get an error go: directory scripts is outside main module, I'm not getting the error when I run the command locally though...

I think we can just skip building the submodule it contains mainly scripts, and since we are already skipping a few directories, the approach is not that dirty.

I couldn't repro the error locally either, maybe we should figure out why this happened instead of going straight to the workaround?

@chaodaiG
Copy link
Contributor

chaodaiG commented Jun 3, 2020

/hold

@knative-prow-robot knative-prow-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jun 3, 2020
@knative-prow-robot knative-prow-robot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jun 7, 2020
@chizhg chizhg force-pushed the define-scripts-module branch 3 times, most recently from e3a0bee to d66f654 Compare June 7, 2020 06:49
@chizhg
Copy link
Member Author

chizhg commented Jun 7, 2020

Looks promising, can you fix the build error first?

I didn't find an elegant way to fix the build error. It seems go build -v ./... cannot work with a repo that has multiple Go modules and will get an error go: directory scripts is outside main module, I'm not getting the error when I run the command locally though...
I think we can just skip building the submodule it contains mainly scripts, and since we are already skipping a few directories, the approach is not that dirty.

I couldn't repro the error locally either, maybe we should figure out why this happened instead of going straight to the workaround?

I can reproduce the error by running ./test/presubmit-tests.sh --build-tests. The error happens in running command go test -c -tags="e2e library local tools" ./scripts.

There are two issues with this command:

  1. Currently the build test runner is assuming all packages that have build tags are test packages, but it's not necessarily true.
  2. As we are now defining ./scripts as a go submodule, even go build -tags="tools" ./scripts will get the go: directory scripts is outside main module error, the right way to build it will be cd scripts/ && go build -tags="tools" ..

Given the first issue and the fact the submodule only contains a dummy.go file, I think it does make sense for us to explicitly skip building it for now. I have added a TODO to support building normal go packages with build tags if we need it in the future.

@chaodaiG
Copy link
Contributor

chaodaiG commented Jun 9, 2020

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 9, 2020
@chizhg
Copy link
Member Author

chizhg commented Jun 10, 2020

/hold cancel

@knative-prow-robot knative-prow-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jun 10, 2020
@knative-prow-robot knative-prow-robot merged commit 8b4a528 into knative:master Jun 10, 2020
chizhg added a commit that referenced this pull request Jun 10, 2020
knative-prow-robot pushed a commit that referenced this pull request Jun 10, 2020
@chizhg chizhg deleted the define-scripts-module branch October 9, 2020 20:18
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. cla: yes Indicates the PR's author has signed the CLA. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate using multiple Go modules to solve the scripts vendor issue
4 participants