summaryrefslogtreecommitdiff
path: root/support
diff options
context:
space:
mode:
authorJacob Vosmaer <jacob@gitlab.com>2019-08-19 05:02:05 +0000
committerAsh McKenzie <amckenzie@gitlab.com>2019-08-19 05:02:05 +0000
commit4d330cb1dd0fa2d6470d459fc33a987e8f550887 (patch)
treea11de1a5bb9a3c27bcd6c9b31c0663bd91c5c8c8 /support
parent81f5854513a527c3a00398e91930a12ebad70272 (diff)
downloadgitlab-shell-4d330cb1dd0fa2d6470d459fc33a987e8f550887.tar.gz
Use go mod
Diffstat (limited to 'support')
-rwxr-xr-xsupport/go-format2
-rwxr-xr-xsupport/go-test4
-rwxr-xr-xsupport/go-update-vendor26
-rw-r--r--support/go_build.rb21
4 files changed, 15 insertions, 38 deletions
diff --git a/support/go-format b/support/go-format
index b5f47b7..59af23c 100755
--- a/support/go-format
+++ b/support/go-format
@@ -1,7 +1,7 @@
#!/usr/bin/env ruby
def main(check)
- go_files = Dir['go/**/*.go'].reject { |p| p.start_with?('go/vendor/') }
+ go_files = Dir['go/**/*.go']
cmd = %w[gofmt -s -l]
cmd << '-w' unless check
cmd += go_files
diff --git a/support/go-test b/support/go-test
index e4f87b7..0c043f6 100755
--- a/support/go-test
+++ b/support/go-test
@@ -4,8 +4,8 @@ require_relative 'go_build'
include GoBuild
def main
- create_fresh_build_dir
- run!(GO_ENV, %W[go test #{GO_PACKAGE}/...])
+ ensure_build_dir_exists
+ run!(GO_ENV, %w[go test ./...], chdir: GO_DIR)
puts 'OK'
end
diff --git a/support/go-update-vendor b/support/go-update-vendor
deleted file mode 100755
index 020bb87..0000000
--- a/support/go-update-vendor
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'fileutils'
-
-require_relative 'go_build'
-include GoBuild
-
-def main(dependency)
- # Govendor wants to run in a GOPATH so let's make one for it.
- create_fresh_build_dir
- run!(GO_ENV, %w[go get github.com/kardianos/govendor])
-
- gitlab_shell_build_go_dir = File.join(BUILD_DIR, 'src', GO_PACKAGE)
- run!(GO_ENV, %W[govendor fetch #{dependency}], chdir: gitlab_shell_build_go_dir)
-
- # Now we have updated go/vendor in the temporary build dir. We must sync
- # the changes back so that Git will see them.
- FileUtils.rm_rf('go/vendor')
- FileUtils.cp_r(File.join(gitlab_shell_build_go_dir, 'vendor'), 'go')
-end
-
-unless ARGV.count == 1
- abort "usage: #{$PROGRAM_NAME} DEPENDENCY"
-end
-
-main(ARGV.first)
diff --git a/support/go_build.rb b/support/go_build.rb
index d11cc38..1ef2e17 100644
--- a/support/go_build.rb
+++ b/support/go_build.rb
@@ -8,19 +8,22 @@ require_relative '../lib/gitlab_init'
module GoBuild
GO_DIR = 'go'.freeze
BUILD_DIR = File.join(ROOT_PATH, 'go_build')
- GO_PACKAGE = File.join('gitlab.com/gitlab-org/gitlab-shell', GO_DIR)
GO_ENV = {
- 'GOPATH' => BUILD_DIR,
- 'GO15VENDOREXPERIMENT' => '1',
- 'GO111MODULE' => 'off'
+ # $GOBIN controls where 'go install' puts binaries. Prior to go mod,
+ # this was $GOPATH/bin.
+ 'GOBIN' => File.join(BUILD_DIR, 'bin'),
+ # Force the use of go mod, even if $GOPATH is set.
+ 'GO111MODULE' => 'on',
+ # Downloading dependencies via proxy.golang.org is faster and more
+ # reliable than downloading from canonical sources. We need this
+ # environment variable because as of Go 1.12, the default is still to
+ # download from canonical sources.
+ 'GOPROXY' => 'https://proxy.golang.org'
}.freeze
- def create_fresh_build_dir
- FileUtils.rm_rf(BUILD_DIR)
- build_source_dir = File.join(BUILD_DIR, 'src', GO_PACKAGE)
- FileUtils.mkdir_p(build_source_dir)
- FileUtils.cp_r(File.join(ROOT_PATH, GO_DIR, '.'), build_source_dir)
+ def ensure_build_dir_exists
+ FileUtils.mkdir_p(BUILD_DIR)
end
def run!(env, cmd, options = {})