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

Set go version to 1.14, to enable vendor builds by default. #2749

Merged
merged 4 commits into from
Jun 22, 2020
Merged

Set go version to 1.14, to enable vendor builds by default. #2749

merged 4 commits into from
Jun 22, 2020

Conversation

pstibrany
Copy link
Contributor

@pstibrany pstibrany commented Jun 18, 2020

What this PR does: After #2480, we can enable go 1.14 in go.mod. That enables -mod=vendor by default for all builds.

Requiring go 1.14 for builds also allows us to use new features from this version.

Pinging Loki team: @slim-bean @cyriltovena @owen-d.

Checklist

  • [NA] Tests updated
  • [NA] Documentation added
  • [NA] CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
@pracucci
Copy link
Contributor

Minimum version in Thanos is still 1.13 (even if built with 1.14). Could this change be a problem? @bwplotka

@pstibrany
Copy link
Contributor Author

Minimum version in Thanos is still 1.13 (even if built with 1.14). Could this change be a problem? @bwplotka

This should not be a problem for dependencies. This sets expected language version for the module, but go 1.14 doesn’t change the language. It changes how vendoring works, but that is no concern when used as a dependency. Usage of some go new methods in 1.14 (eg. testing.T.Cleanup) is also not a problem, unless used in integration tests.

Copy link
Contributor

@pracucci pracucci left a comment

Choose a reason for hiding this comment

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

I'm OK with the change in go.mod. I'm just not sure about the reason of the change in tools/test but I guess there's a good reason 😉

tools/test Outdated
@@ -104,6 +104,7 @@ run_test() {
local dir=$1
if [ -z "$NO_GO_GET" ]; then
go get -t -tags "${TAGS[@]}" "$dir"
go mod vendor # re-vendor everything
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you explain why we need to run go mod vendor in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reason is to avoid error when go get fetches additional depedendency, but doesn’t put it into vendor. In go 1.14, if you have vendor directory, it is used by default, but vendor/modules.txt is verified against go.mod. Without calling go mod vendor here, that verification fails.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I would prefer if our test didn’t do additional go get, but I’m not sure why it’s here, so left it for now.
In case of cover tool later in the file, I think that should be part of the build image instead.

Copy link
Contributor

Choose a reason for hiding this comment

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

What if we remove the -go-get and -no-go-get support at all, always enforcing the behaviour of NO_GO_GET=true (current default)? -go-get is not used by any script we have, so the only way to use it is to manually call tools/test -go-get.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What if we remove the -go-get and -no-go-get support at all, always enforcing the behaviour of NO_GO_GET=true (current default)? -go-get is not used by any script we have, so the only way to use it is to manually call tools/test -go-get.

I will remove it. This doesn't fix problem with cover tool, used when run under CIRCLECI.

Signed-off-by: Peter Štibraný <peter.stibrany@grafana.com>
@bwplotka
Copy link
Contributor

#2749 (comment)

Thanos is basing on 1.14 as minimum, we will fix the docs. So all good ! (:

@pracucci
Copy link
Contributor

If we merge it soon we'll get it into next Cortex release.

@@ -147,6 +135,8 @@ fi

if [ -n "$SLOW" ] && [ -z "$COVERDIR" ]; then
go get github.com/weaveworks/tools/cover
go mod vendor # re-vendor everything
Copy link
Contributor

Choose a reason for hiding this comment

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

What about putting the cover tool into the build image, like we do with various other tools?

RUN GO111MODULE=on go get -tags netgo \
github.com/client9/misspell/cmd/misspell@v0.3.4 \
github.com/golang/protobuf/protoc-gen-go@v1.3.1 \
github.com/gogo/protobuf/protoc-gen-gogoslick@v1.3.0 \
github.com/gogo/protobuf/gogoproto@v1.3.0 && \

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will send PR to include cover tool in build image.

@pstibrany pstibrany merged commit e43e3cc into cortexproject:master Jun 22, 2020
@pstibrany
Copy link
Contributor Author

pstibrany commented Jun 22, 2020 via email

@pstibrany pstibrany mentioned this pull request Jul 13, 2020
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants