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

unit tests and fmt checks don't work when offline #2063

Closed
patrick-east opened this issue Feb 6, 2020 · 1 comment · Fixed by #2077
Closed

unit tests and fmt checks don't work when offline #2063

patrick-east opened this issue Feb 6, 2020 · 1 comment · Fixed by #2077
Assignees
Labels

Comments

@patrick-east
Copy link
Contributor

Expected Behavior

A dev should be able to run the unit tests and any of the checks for formatting/vetting offline with just the go tools locally installed and the source code.

Actual Behavior

Builds fail sometimes because they are reaching out to hit package servers (ie git repos) due to our usage of go modules.

Ex from a Travis failure:

./build/check-fmt.sh
go: finding github.com/golang/protobuf v0.0.0-20181025225059-d3de96c4c28e
go: finding github.com/peterh/liner v0.0.0-20170211195444-bf27d3ba8e1d
go: finding github.com/prometheus/common v0.0.0-20181020173914-7e9e6cabbd39
go: finding github.com/matttproud/golang_protobuf_extensions v1.0.1
go: finding github.com/gogo/protobuf v1.3.0
go: finding github.com/pkg/errors v0.0.0-20181023235946-059132a15dd0
go: finding github.com/mattn/go-runewidth v0.0.0-20181025052659-b20a3daf6a39
go: finding github.com/stretchr/objx v0.1.1
go: finding github.com/OneOfOne/xxhash v1.2.2
go: finding github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72
go: finding golang.org/x/net v0.0.0-20190620200207-3b0461eec859
go: finding golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7
go: finding golang.org/x/sync v0.0.0-20190423024810-112230192c58
go: finding github.com/kisielk/errcheck v1.2.0
go: finding github.com/kisielk/gotool v1.0.0
go: finding golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563
go: finding golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
go: finding golang.org/x/text v0.3.0
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/sys" (https fetch: Get https://golang.org/x/sys?go-get=1: dial tcp 74.125.31.141:443: i/o timeout)
go: golang.org/x/[email protected]: unrecognized import path "golang.org/x/sys" (https fetch: Get https://golang.org/x/sys?go-get=1: dial tcp 74.125.31.141:443: i/o timeout)
go: golang.org/x/[email protected]: git fetch -f https://go.googlesource.com/sync refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/55179c5d8c4db2eaed9fae4682d4c84a1fd3612df666b372bef3bbb997c9601f: exit status 128:
	fatal: unable to access 'https://go.googlesource.com/sync/': Failed to connect to go.googlesource.com port 443: Connection timed out
go: github.com/pkg/[email protected]: git fetch -f https://github.com/pkg/errors refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/9b57de15915a2564a133192909d2d779433a38d49df7d581dc764e6764a41406: exit status 128:
	fatal: unable to access 'https://github.com/pkg/errors/': Failed to connect to github.com port 443: Connection timed out
go: golang.org/x/[email protected]: unknown revision v0.3.0
go: error loading module requirements

Steps to Reproduce the Problem

  1. Disconnect local machine from internet
  2. Run make check test
  3. Observe the commands getting stuck

Additional Info

We can maybe allow the default to reach out to the internet, but really none of the package versions should change.. and everything is vendored. There isn't a good reason for it to need to do anything.

I'd be reasonably ok if we even just had a like OFFLINE env var or something to allow for it.

@tsandall
Copy link
Member

tsandall commented Feb 6, 2020

Can we make it offline by default? We don't have very many dependencies so the common case should rely on the vendored files.

@patrick-east patrick-east self-assigned this Feb 7, 2020
patrick-east added a commit to patrick-east/opa that referenced this issue Feb 7, 2020
There are a handful of scripts that were making `go run` calls without
the required environment vars setup force go to use modules and only
use the vendor directory.

For golang 1.11/12 if OPA was in a path outside of the GOPATH it would
switch into module mode automatically (by default) and then try to
fetch packages and stuff remotely rather than use the vendor dir.

For golang 1.13+ any directory for OPA would (by default) result in
trying to use the remote modules rather than vendor dir.

Fixes: open-policy-agent#2063
Signed-off-by: Patrick East <[email protected]>
tsandall pushed a commit that referenced this issue Feb 11, 2020
There are a handful of scripts that were making `go run` calls without
the required environment vars setup force go to use modules and only
use the vendor directory.

For golang 1.11/12 if OPA was in a path outside of the GOPATH it would
switch into module mode automatically (by default) and then try to
fetch packages and stuff remotely rather than use the vendor dir.

For golang 1.13+ any directory for OPA would (by default) result in
trying to use the remote modules rather than vendor dir.

Fixes: #2063
Signed-off-by: Patrick East <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants