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

*: use go mod to manage dependency #1269

Merged
merged 1 commit into from
Oct 15, 2018
Merged

*: use go mod to manage dependency #1269

merged 1 commit into from
Oct 15, 2018

Conversation

disksing
Copy link
Contributor

@disksing disksing commented Oct 11, 2018

What problem does this PR solve?

Use go mod to manage dependency

What is changed and how it works?

Changes:

  • update Makefile
  • go mod init to generate go.mod file from dep configuration.
  • remove vendor/ and recreate it with make vendor
  • upgrade megacheck to new branch that supports go modules

Notes:

Check List

Tests

  • Integration test

@disksing disksing added DNM do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Oct 11, 2018
@disksing
Copy link
Contributor Author

/run-all-tests

@disksing disksing changed the title Use go mod to manage dependency *: use go mod to manage dependency Oct 11, 2018
@@ -32,23 +44,29 @@ ci: build check basic-test

build:
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be able to do build: export GO111MODULE=on

@gregwebs
Copy link
Contributor

It could be useful to keep using a vendor/ directory with go modules, at least temporarily.
https://arslan.io/2018/08/26/using-go-modules-with-vendor-support-on-travis-ci/

go.mod Outdated
google.golang.org/genproto v0.0.0-20180427144745-86e600f69ee4 // indirect
google.golang.org/grpc v1.12.2
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
Copy link
Contributor

Choose a reason for hiding this comment

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

How did these airbrakes end up getting added? They weren't there before and shouldn't be PD dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

From go mod why gopkg.in/gemnasium/logrus-airbrake-hook.v2 we can see it is imported by github.com/sirupsen/logrus.test.

Copy link
Contributor

Choose a reason for hiding this comment

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

I did run that, but I didn't know what logrus.test is. It isn't listed in our dependencies.

It seems that go modules adds all transitive testing dependencies.

This makes me prefer dep to go modules for now until they get more feedback on go modules.

Copy link
Contributor

@gregwebs gregwebs Oct 12, 2018

Choose a reason for hiding this comment

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

I looked at the logrus repo and I don't see how it can reference airbrake (testing or not): https://github.com/sirupsen/logrus/search?q=airbrake&unscoped_q=airbrake

This actually seems like an issue with how they defined their go.mod. Perhaps you can ask them about it?

I still don't understand why go mod tidy doesn't remove this since it isn't needed.

GO111MODULE=on go mod why github.com/sirupsen/logrus.test
go: finding github.com/golang/protobuf/proto/testdata latest
go: finding github.com/golang/protobuf/proto latest
# github.com/sirupsen/logrus.test
(main module does not need package github.com/sirupsen/logrus.test)

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like there is actually an open issue about testing dependencies here: golang/go#26955. It is milestoned for 1.12 although not necessarily accepted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It looks the best effort now is to keep the vendor/ directory, setup -mod=vendor in Makefile, and only use go mod when we need to update imports. The update procedure should include ./hack/clean-vendor to cleanup test files.
I'll take a try.

Copy link
Contributor

Choose a reason for hiding this comment

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

👍 but I don't think clean-vendor will end up removing exteraneous deps like airbrake. And now go mod is built-in automatically to go commands, so I don't know if it is possible to avoid it updating imports.

@disksing
Copy link
Contributor Author

Hi @gregwebs Please take another look. I have reset the branch and go mod init && go mod vendor && ./hack/clean_test. Now everything seems just fine. No extra dependencies anymore. I must have done something wrong before.

@disksing disksing removed DNM do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. labels Oct 12, 2018
@disksing
Copy link
Contributor Author

/run-all-tests

Copy link
Contributor

@gregwebs gregwebs left a comment

Choose a reason for hiding this comment

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

Deps look good now! Looks like this is actually significantly decreasing the amount of code being dragged into vendor now.

I think keeping the vendor directory will help ease the transition go go modules now. In the long-term we may want to remove it, although I am not sure.

@disksing
Copy link
Contributor Author

disksing commented Oct 13, 2018

Yep, vendor/ should be removed in the long term. Go modules will definitely be better and better supported in the go ecosystem.

@disksing
Copy link
Contributor Author

PTAL @rleungx @nolouch

Copy link
Contributor

@nolouch nolouch left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants