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

formula: set GOPATH #7776

Merged
merged 1 commit into from Jun 23, 2020
Merged

formula: set GOPATH #7776

merged 1 commit into from Jun 23, 2020

Conversation

dawidd6
Copy link
Member

@dawidd6 dawidd6 commented Jun 20, 2020

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This change can speed up subsequent builds of formulae using Go Modules.
I think for us, the benefit could be: quicker go formula builds on CI or quicker local rebuilds of formulae when applying some changes.

Ideally we would wait for: golang/go#34527

and then just set GOMODCACHE, which will be a better choice instead of GOPATH.

@jonchang
Copy link
Contributor

Looks like GOMODCACHE will be part of Go 1.15, which is due out on August 1: https://lwn.net/Articles/820217/

@MikeMcQuaid
Copy link
Member

Probably makes sense to set this in

test_env = {
CURL_HOME: ENV["CURL_HOME"] || ENV["HOME"],
TMPDIR: HOMEBREW_TEMP,
TEMP: HOMEBREW_TEMP,
TMP: HOMEBREW_TEMP,
TERM: "dumb",
PATH: PATH.new(ENV["PATH"], HOMEBREW_PREFIX/"bin"),
HOMEBREW_PATH: nil,
_JAVA_OPTIONS: "#{ENV["_JAVA_OPTIONS"]&.+(" ")}-Duser.home=#{HOMEBREW_CACHE}/java_cache",
GOCACHE: "#{HOMEBREW_CACHE}/go_cache",
CARGO_HOME: "#{HOMEBREW_CACHE}/cargo_cache",
}
(grep for GOCACHE).

@dawidd6
Copy link
Member Author

dawidd6 commented Jun 23, 2020

If I understood correctly, those ENV variables in formula.rb are only set for the test. I want set it for build too.

@MikeMcQuaid
Copy link
Member

If I understood correctly, those ENV variables in formula.rb are only set for the test. I want set it for build too.

Nope, the def stage is set at build-time (which is what we want done here too).

@dawidd6
Copy link
Member Author

dawidd6 commented Jun 23, 2020

Oh, I was looking at def run_test.

So we can cache dependencies and speed up subsequent builds.
@dawidd6 dawidd6 changed the title ENV/super: set GOPATH formula: set GOPATH Jun 23, 2020
@@ -2142,6 +2142,7 @@ def stage
stage_env[:_JAVA_OPTIONS] =
"#{ENV["_JAVA_OPTIONS"]&.+(" ")}-Duser.home=#{HOMEBREW_CACHE}/java_cache"
stage_env[:GOCACHE] = "#{HOMEBREW_CACHE}/go_cache"
stage_env[:GOPATH] = "#{HOMEBREW_CACHE}/go_mod_cache"
Copy link
Member

Choose a reason for hiding this comment

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

Worth setting in run_test too or is it basically never going to be used there?

Copy link
Member Author

Choose a reason for hiding this comment

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

Umm, I don't think we run any go command often in test blocks.

Copy link
Member

Choose a reason for hiding this comment

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

np, shipit!

@dawidd6 dawidd6 marked this pull request as ready for review June 23, 2020 16:29
@dawidd6
Copy link
Member Author

dawidd6 commented Jun 23, 2020

Note for the future generation. With the release of Go 1.15, we should change GOPATH to GOMODCACHE.

@dawidd6 dawidd6 merged commit 4fa540b into Homebrew:master Jun 23, 2020
@dawidd6 dawidd6 deleted the gopath branch June 23, 2020 16:45
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Dec 27, 2020
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Dec 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants