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

Fix GO source vendoring #12010

Closed
wants to merge 1 commit into from
Closed

Fix GO source vendoring #12010

wants to merge 1 commit into from

Conversation

ElXreno
Copy link

@ElXreno ElXreno commented Jun 22, 2020

This commit fixes error like this:

CC= GOOS= GOARCH= go generate -mod=vendor -tags 'bindata pam sqlite sqlite_unlock_notify' 
go: inconsistent vendoring in /builddir/build/BUILD/gitea-1.12.1:
	src.techknowlogick.com/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
go: inconsistent vendoring in /builddir/build/BUILD/gitea-1.12.1:
	src.techknowlogick.com/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
make: *** [Makefile:518: generate] Error 1

Maybe somebody's got a better fix? I'm not sure if my decision is right because the vendor is already in the repository.

Copy link
Member

@techknowlogick techknowlogick left a comment

Choose a reason for hiding this comment

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

The release targets in the makefile are useful shortcuts for the Gitea project itself for releasing Gitea via Drone. As well go modules are disabled during release steps. I am hesitant about this change as if you would like to build Gitea then the make build step is what you need to use.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 22, 2020
@silverwind
Copy link
Member

I think make vendor should fix inconsistent vendoring. Did someone forget to run it?

gitea/Makefile

Lines 332 to 343 in 121103f

.PHONY: vendor
vendor:
$(GO) mod tidy && $(GO) mod vendor
.PHONY: test-vendor
test-vendor: vendor
@diff=$$(git diff vendor/); \
if [ -n "$$diff" ]; then \
echo "Please run 'make vendor' and commit the result:"; \
echo "$${diff}"; \
exit 1; \
fi;

@ElXreno
Copy link
Author

ElXreno commented Jun 22, 2020

@techknowlogick this pull request fixes the generation of an archive with all dependencies for offline build. It is generated, and is called as gitea-src-$VERSION.tar.gz, so I think it's required.

@ElXreno
Copy link
Author

ElXreno commented Jun 22, 2020

@silverwind Thank you for the find! I didn't even notice it once.

This commit fixes error like this:
```
CC= GOOS= GOARCH= go generate -mod=vendor -tags 'bindata pam sqlite sqlite_unlock_notify'
go: inconsistent vendoring in /builddir/build/BUILD/gitea-1.12.1:
	src.techknowlogick.com/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
go: inconsistent vendoring in /builddir/build/BUILD/gitea-1.12.1:
	src.techknowlogick.com/[email protected]: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt

run 'go mod vendor' to sync, or use -mod=mod or -mod=readonly to ignore the vendor directory
make: *** [Makefile:518: generate] Error 1
```
@silverwind
Copy link
Member

test-vendor already runs as part of every CI job (example) and the build would fail if there were inconsistencies. So I don't think adding this to the release task is a good idea. Question is how did your vendoring get inconsistent, assuming you're building of one of our tested branches?

@ElXreno
Copy link
Author

ElXreno commented Jun 22, 2020

@silverwind To be honest, I don't know why it breaks. Everything was compiled without the Internet to version 1.11.6 inclusive. The next step was to manually re-pack the archive, pre-making a go mod vendor.
And sorry for my bad English, I may have misunderstood your question.

@silverwind
Copy link
Member

I think the issue is that the release tasks do go get -u src.techknowlogick.com/xgo which will add xgo to the module dependencies. One way to workaround this would be to cd outside the project while installing global commands. I wonder why this doesn't fail for our release tasks.

@techknowlogick
Copy link
Member

go get -u src.techknowlogick.com/xgo shouldn't be run when doing the release targets during drone because the docker container already has the xgo binary in it.

@silverwind
Copy link
Member

This issue is essentially golang/go#30515.

We could potentially GO111MODULE=off go get -u src.techknowlogick.com/xgo to avoid having go touch the module files.

silverwind added a commit to silverwind/gitea that referenced this pull request Jun 23, 2020
Prevent `go get` from touching `go.mod` and `go.sum` when executing
global binaries during the build process. Once
golang/go#30515 is fixed, we should is
whatever solution is provided there.

Fixes: go-gitea#12010
@silverwind
Copy link
Member

Alternative PR: #12030

lafriks pushed a commit that referenced this pull request Jun 26, 2020
Prevent `go get` from touching `go.mod` and `go.sum` when executing
global binaries during the build process. Once
golang/go#30515 is fixed, we should is
whatever solution is provided there.

Fixes: #12010

Co-authored-by: techknowlogick <[email protected]>
stblassitude pushed a commit to stblassitude/gitea that referenced this pull request Jun 28, 2020
Prevent `go get` from touching `go.mod` and `go.sum` when executing
global binaries during the build process. Once
golang/go#30515 is fixed, we should is
whatever solution is provided there.

Fixes: go-gitea#12010

Co-authored-by: techknowlogick <[email protected]>
lafriks pushed a commit that referenced this pull request Jun 28, 2020
Prevent `go get` from touching `go.mod` and `go.sum` when executing
global binaries during the build process. Once
golang/go#30515 is fixed, we should is
whatever solution is provided there.

Fixes: #12010

Co-authored-by: techknowlogick <[email protected]>

Co-authored-by: silverwind <[email protected]>
Co-authored-by: techknowlogick <[email protected]>
ydelafollye pushed a commit to ydelafollye/gitea that referenced this pull request Jul 31, 2020
Prevent `go get` from touching `go.mod` and `go.sum` when executing
global binaries during the build process. Once
golang/go#30515 is fixed, we should is
whatever solution is provided there.

Fixes: go-gitea#12010

Co-authored-by: techknowlogick <[email protected]>
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants