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

go.mod is out of sync a lot #5755

Open
jmhodges opened this issue Jan 23, 2020 · 8 comments
Open

go.mod is out of sync a lot #5755

jmhodges opened this issue Jan 23, 2020 · 8 comments
Labels
Component: Build/CI Type: Enhancement Logical improvement (somewhere between a bug and feature)

Comments

@jmhodges
Copy link
Contributor

I keep merging in master to a branch I'm making for a patch, and I've found that I'm consistently seeing the post-commit hooks causing changes to go.mod after a merge that (haven't been committed). It seems like maybe the CI jobs aren't detecting or folks aren't committing changes to go.mod somehow?

It would be cool to resolve this.

@jmhodges
Copy link
Contributor Author

Currently, for instance, my local go.mod differs from master with:

-       github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
-       github.com/modern-go/reflect2 v1.0.1 // indirect

@sougou
Copy link
Contributor

sougou commented Jan 24, 2020

This has been bugging me a lot. Are we using go modules the wrong way? Is there a more stable way to do this? Any inputs welcome.

@jmhodges
Copy link
Contributor Author

jmhodges commented Jan 24, 2020

I think it's the use of go run commands without versions in the commit hooks. Everyone's machine is picking up different versions of dependencies for those packages. (That plus folks having different GO111MODULE settings?)

@gedgar
Copy link
Contributor

gedgar commented Jan 24, 2020

FWIW, just running make build is enough to introduce those changes to go.mod. Per go mod tidy -v, those modern-go/ deps (and many others) appear to be unused:

$ go mod tidy -v
warning: ignoring symlink /home/gary/go/src/vitess.io/vitess/py-vtdb
unused github.com/Bowery/prompt
unused github.com/boltdb/bolt
unused github.com/bombsimon/wsl
unused github.com/cockroachdb/cmux
unused github.com/dchest/safefile
unused github.com/go-critic/go-critic
unused github.com/golangci/gocyclo
unused github.com/golangci/golangci-lint
unused github.com/golangci/revgrep
unused github.com/google/shlex
unused github.com/gostaticanalysis/analysisutil
unused github.com/mattn/go-isatty
unused github.com/modern-go/concurrent
unused github.com/modern-go/reflect2
unused github.com/pelletier/go-toml
unused github.com/securego/gosec
unused github.com/spf13/afero
unused github.com/spf13/cast
unused github.com/spf13/jwalterweatherman
unused github.com/spf13/viper
unused github.com/ugorji/go
unused github.com/uudashr/gocognit
unused mvdan.cc/unparam
unused sourcegraph.com/sqs/pbtypes

I admittedly don't have much experience with go modules but took a stab at cleaning things up in #5765

go.sum looks to be consistent after running both go mod tidy and make build, though there is a descrepancy in go.mod related to ugorji/go:

go mod tidy: github.com/ugorji/go/codec v1.1.7 // indirect
make build: github.com/ugorji/go v1.1.7 // indirect

Again, this is outside my wheelhouse so I'll defer to someone who actually has experience with go modules :)

@jmhodges
Copy link
Contributor Author

The make commands run various go run things, don’t they? And tidy won’t ever see those go run commands as things to add to go.sum. That would explain what you’re seeing, I believe

@jmhodges
Copy link
Contributor Author

I'm poking at this some, and specifying versions for go run commands won't help because mod tidy still won't see those commands.

I think we'd be better off requiring that developers install certain commands in $PATH to work correctly. We maybe could a helper script to do so that ensures they don't accidentally fudge with go.mod when they install those tools.

@jmhodges
Copy link
Contributor Author

Hrm, we already have a tools package that would be preventing some of this (since it's used to depend on our tooling), but we kind of undo its work by relying on go run, because it can update go.mod itself.

So, I'd recommend ripping out the go runs, start relying on the commands in $PATH for our hooks, and mention installing tools in more of the contributor documentation.

As sugar, it would be nice if the CI jobs could error if go.mod changes during the course of their run and instruct the developer to update go.mod in their patch.

(Currently, there's no useful for us solution in the Go tooling. In Go 1.14, they're adding a -g command to go get, go run, etc. that skips over go.mod entirely. That, of course, would mean if we keep the go runs but add -g, everyone would have different versions of the tools on their machines. But, in any case, it's moot because 1.14 is not out)

jmhodges added a commit to jmhodges/vitess that referenced this issue Jan 25, 2020
This addresses symptoms, but not causes, discussed in vitessio#5755 and vitessio#5756

Signed-off-by: Jeff Hodges <jeff@somethingsimilar.com>
@dweitzman
Copy link
Member

I haven't been working with the go mod stuff yet, but I notice that CI still doesn't have mod=readonly, which would create some degree of a security and maintainability problem

That was going to be deferred for a future PR when the original go.mod landed: #5109 (comment)

jmhodges added a commit to jmhodges/vitess that referenced this issue Jan 29, 2020
This is a significant, but not complete expansion of the ALTER support in
sqlparser.

It adds support for these ALTER commands:

* `ADD COLUMN`
* `DROP COLUMN`
* `ADD INDEX`
* `DROP INDEX`
* `DROP FOREIGN KEY`
* `DROP PRIMARY KEY`
* `ADD PARTITION`
* `DROP PARTITION`
* `ADD CHECK` (as a no-op; it's parsed but never executed by mysql servers)

The main addition with this API is an additional field on `DDL` that is a slice
of newly created `AlterSpecs`. An `AlterSpec` represents one of the commands
that can occur in the same `ALTER` statement with other commands. This
differentiates them from the `ALTER` statement parse states already in `sql.y`
which are concerned with `ALTER` commands that must be the sole commands in the
statement.

The `ADD PARTITION` and `DROP PARTITION` states are the exception and are new
singleton commands that `sql.y` now supports.

This patch also includes some incidental updates to `go.mod` because of tooling
issues (described in vitessio#5755) and are duplicated in vitessio#5766

Updates vitessio#5705

Signed-off-by: Jeff Hodges <jeff@somethingsimilar.com>
@GuptaManan100 GuptaManan100 added Component: Build/CI P3 Type: Enhancement Logical improvement (somewhere between a bug and feature) labels Dec 1, 2020
@ajm188 ajm188 removed the P3 label Mar 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Build/CI Type: Enhancement Logical improvement (somewhere between a bug and feature)
Projects
None yet
Development

No branches or pull requests

6 participants