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

Disable go module strict mode #2236

Merged
merged 1 commit into from Jun 6, 2019

Conversation

@chrisgilmerproj
Copy link
Contributor

commented Jun 5, 2019

Description

Disable go module strict mode while enforcing that the project is built and run outside $GOPATH. This addresses issues with pre-commit golang interactions. This PR enforces two things:

  • GO111MODULE=auto is explicit about being automatic (the default)
  • ./scripts/check-gopath enforces that the project is being run outside of $GOPATH.

Read about different scenarios about this below.

Scenario 1: No problems with hook installation

  • Run pre-commit install-hooks to install hooks. For the golangci-lint hook the go dependencies are installed in $GOPATH.
  • Run direnv allow to set GO111MODULE=on

Scenario 2: Problems installing hooks

  • Run direnv allow to set GO111MODULE=on
  • Run pre-commit install-hooks to install hooks. For the golangci-lint hook the go dependencies are installed in ~/.cache/pre-commit/repo<hash>/golangenv-default/pkg.

The failure in the second case is:

Permission denied: '/Users/username/.cache/pre-commit/repo0i1br295/golangenv-default/pkg/mod/gopkg.in/yaml.v2@v2.2.1/decode_test.go'

The /gopkg.in/yaml.v2@v2.2.1 dependency was installed at /Users/username/.cache/pre-commit/repo0i1br295/golangenv-default/pkg/mod/ instead of in $GOPATH. It also gets permissions 777 which I haven't figured out but which makes it impossible for the pre-commit library to manage. Personal checks show that many directories or files get permissions which make it impossible for pre-commit to manage or for a person to delete or manage without using sudo.

Setup

First move your repo outside of $GOPATH.

rm -rf ~/.cache/pre-commit # Can use sudo if you need to
pre-commit install-hooks
pre-commit run -a

Code Review Verification Steps

  • Request review from a member of a different team.

References

  • Go modules is the resource for everything you want to know about go mod.
Disable go module strict mode while enforcing that the project is bui…
…lt and run outside $GOPATH. This addresses issues with pre-commit golang interactions.
@codecov

This comment has been minimized.

Copy link

commented Jun 6, 2019

Codecov Report

Merging #2236 into master will decrease coverage by <.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #2236      +/-   ##
==========================================
- Coverage      59%   58.99%   -<.01%     
==========================================
  Files         250      250              
  Lines       14085    14069      -16     
==========================================
- Hits         8310     8300      -10     
+ Misses       4774     4767       -7     
- Partials     1001     1002       +1
@Ryan-Koch
Copy link
Contributor

left a comment

LGTM. Using this method locally wound up working out.

@chrisgilmerproj chrisgilmerproj merged commit 9b327b2 into master Jun 6, 2019

18 of 19 checks passed

codecov/project/go 58.81% (-<.01%) compared to fe0c31d
Details
ci/circleci: acceptance_tests_experimental Your tests passed on CircleCI!
Details
ci/circleci: acceptance_tests_local Your tests passed on CircleCI!
Details
ci/circleci: acceptance_tests_staging Your tests passed on CircleCI!
Details
ci/circleci: build_app Your tests passed on CircleCI!
Details
ci/circleci: build_migrations Your tests passed on CircleCI!
Details
ci/circleci: build_tasks Your tests passed on CircleCI!
Details
ci/circleci: build_tools Your tests passed on CircleCI!
Details
ci/circleci: client_test Your tests passed on CircleCI!
Details
ci/circleci: integration_tests_api Your tests passed on CircleCI!
Details
ci/circleci: integration_tests_mymove Your tests passed on CircleCI!
Details
ci/circleci: integration_tests_office Your tests passed on CircleCI!
Details
ci/circleci: integration_tests_tsp Your tests passed on CircleCI!
Details
ci/circleci: pre_deps_golang Your tests passed on CircleCI!
Details
ci/circleci: pre_deps_yarn Your tests passed on CircleCI!
Details
ci/circleci: pre_test Your tests passed on CircleCI!
Details
ci/circleci: server_test Your tests passed on CircleCI!
Details
ci/circleci: server_test_coverage Your tests passed on CircleCI!
Details
codecov/patch Coverage not affected when comparing fe0c31d...d356000
Details

@chrisgilmerproj chrisgilmerproj deleted the cg_disable_gomodule_strict branch Jun 6, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.