From d23dcd09df3e13975a2b61f812a80316a56879ae Mon Sep 17 00:00:00 2001 From: Matthew McPherrin Date: Wed, 7 Aug 2019 20:50:16 -0700 Subject: [PATCH 1/2] Update rakefile to use modules --- .travis.yml | 1 - Rakefile | 17 ++++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 59cb4196b..b2f66e2a9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,7 +13,6 @@ before_install: install: - gem install rake - - go get github.com/tools/godep - go get github.com/kisielk/errcheck - rake install - wget https://releases.hashicorp.com/consul/0.7.1/consul_0.7.1_linux_amd64.zip diff --git a/Rakefile b/Rakefile index b1f98d503..0aa047fa7 100644 --- a/Rakefile +++ b/Rakefile @@ -2,7 +2,7 @@ require "json" def e(cmd) puts cmd - system(cmd) || raise("Error running `#{cmd}`") + system({"GO111MODULE" => "on"}, cmd) || raise("Error running `#{cmd}`") end def target(expand="") @@ -10,14 +10,9 @@ def target(expand="") File.expand_path(expand, File.join(root, 'target')) end -task :godep_check do - system("which godep") || abort("You do not have godep installed. Run `go get github.com/tools/godep` and ensure that it's on your PATH") -end - -desc 'Get deps for all projects.' -task :deps => :godep_check do - e "go get -v -t ./..." - e "godep save ./..." +desc 'Vendor dependencies for all projects.' +task :deps do + e "go mod vendor" end desc 'Build all projects' @@ -38,9 +33,9 @@ task :test_all => [:build] do end desc 'Update all dependencies' -task :update => :godep_check do +task :update do e "go get -u -t -v ./..." - e "godep update -r .../..." + e "go mod vendor" end desc 'Install all built binaries' From 1062fccd1dfe4840336b4939c79ed9ac8a459cf8 Mon Sep 17 00:00:00 2001 From: Matthew McPherrin Date: Thu, 8 Aug 2019 10:11:56 -0700 Subject: [PATCH 2/2] Remove broken sync_consul_deps This code won't work anymore, and should the team update Consul, won't be needed anymore either now that both p2 and consul use `go mod` for dependency management. --- Rakefile | 63 -------------------------------------------------------- 1 file changed, 63 deletions(-) diff --git a/Rakefile b/Rakefile index 0aa047fa7..bc4e894fb 100644 --- a/Rakefile +++ b/Rakefile @@ -80,66 +80,3 @@ end desc 'By default, gather dependencies, build and test' task :default => [:deps, :test, :install] - -task :sync_consul_deps do - p2_repo_dir = File.join(ENV["GOPATH"], "src", "github.com", "square", "p2") - - consul_vendor_contents = JSON.parse(File.read(File.join(ENV["GOPATH"], "src", "github.com", "hashicorp", "consul", "vendor", "vendor.json"))) - p2_godep_contents = JSON.parse(File.read(File.join(p2_repo_dir, "Godeps", "Godeps.json"))) - - # build a map of package names to revisions from consul's vendor.json - consul_deps = {} - consul_vendor_contents["package"].each do |package| - consul_deps[package["path"]] = package["revision"] - end - - success_count = 0 - failed_count = 0 - skipped_count = 0 - - # now iterate over our Godeps.json and find any versions that mismatch and print them - p2_godep_contents["Deps"].each do |package| - package_name = package["ImportPath"] - consul_rev = consul_deps[package_name] - next unless consul_rev - - our_rev = package["Rev"] - if consul_rev != our_rev - # grab just the first three items e.g. github.com/hashicorp/consul not github.com/hashicorp/consul/api/inner/package/thing - first_three = package_name.split("/")[0..2] - first_three_joined = first_three.join("/") - - # in case the consul dependency is new and not in $GOPATH, do a "go get" first - e "go get #{first_three_joined}/..." - begin - Dir.chdir(File.join(ENV["GOPATH"], "src", *first_three)) do - e "git fetch" - older_commit = `git merge-base #{our_rev} #{consul_rev}`.chomp - raise "could not determine which commit is newer for #{first_three_joined}" unless $?.exitstatus == 0 - if older_commit == our_rev - e "git checkout #{consul_rev}" - else - puts "No action taken for #{package_name}: consul's version #{consul_rev} is older than P2's #{our_rev}" - skipped_count += 1 - next - end - end - - Dir.chdir(p2_repo_dir) do - e "godep update #{first_three.join("/")}/..." - end - - puts "Successfully repaired mismatch in #{package_name}: consul has #{consul_rev} p2 had #{our_rev}" - success_count += 1 - rescue => e - puts "Failed to repair mismatch in #{package_name}: consul has #{consul_rev} p2 had #{our_rev}: #{e.message}" - failed_count += 1 - end - - end - end - - puts "Successfully updated #{success_count} packages" - puts "Failed to updated #{failed_count} packages" - puts "Skipped updating #{skipped_count} packages (because consul had an older version vendored)" -end