goma_server: add $GOPATH/bin to $PATH.

To run go generate, we need to have protoc-gen-go in $PATH.

Bug: 954455
Change-Id: I3d8feb5a6b98fca2bdac18b6bbe383a3a9f79929
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/build/+/1611622
Reviewed-by: Takuto Ikuta <tikuta@chromium.org>
Commit-Queue: Yoshisato Yanagisawa <yyanagisawa@chromium.org>
diff --git a/scripts/slave/README.recipes.md b/scripts/slave/README.recipes.md
index 1f08aa8..98e8489 100644
--- a/scripts/slave/README.recipes.md
+++ b/scripts/slave/README.recipes.md
@@ -4978,9 +4978,9 @@
 
 [DEPS](/scripts/slave/recipes/goma_server.py#5): [depot\_tools/cipd][depot_tools/recipe_modules/cipd], [depot\_tools/git][depot_tools/recipe_modules/git], [depot\_tools/tryserver][depot_tools/recipe_modules/tryserver], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step]
 
-&mdash; **def [RunSteps](/scripts/slave/recipes/goma_server.py#37)(api):**
+&mdash; **def [RunSteps](/scripts/slave/recipes/goma_server.py#41)(api):**
 
-&mdash; **def [SetupExecutables](/scripts/slave/recipes/goma_server.py#21)(api, pkg_dir):**
+&mdash; **def [SetupExecutables](/scripts/slave/recipes/goma_server.py#25)(api, pkg_dir):**
 
 Set up go and protoc to run the script.
 
diff --git a/scripts/slave/recipes/goma_server.expected/goma_server_presubmit.json b/scripts/slave/recipes/goma_server.expected/goma_server_presubmit.json
index 29df4bd..729d39d 100644
--- a/scripts/slave/recipes/goma_server.expected/goma_server_presubmit.json
+++ b/scripts/slave/recipes/goma_server.expected/goma_server_presubmit.json
@@ -169,7 +169,8 @@
       ],
       "PATH": [
         "[START_DIR]/packages",
-        "[START_DIR]/packages/bin"
+        "[START_DIR]/packages/bin",
+        "[CACHE]/builder/go/bin"
       ]
     },
     "name": "list modules"
@@ -190,7 +191,8 @@
       ],
       "PATH": [
         "[START_DIR]/packages",
-        "[START_DIR]/packages/bin"
+        "[START_DIR]/packages/bin",
+        "[CACHE]/builder/go/bin"
       ]
     },
     "name": "generate proto"
@@ -211,7 +213,8 @@
       ],
       "PATH": [
         "[START_DIR]/packages",
-        "[START_DIR]/packages/bin"
+        "[START_DIR]/packages/bin",
+        "[CACHE]/builder/go/bin"
       ]
     },
     "name": "build"
@@ -234,7 +237,8 @@
       ],
       "PATH": [
         "[START_DIR]/packages",
-        "[START_DIR]/packages/bin"
+        "[START_DIR]/packages/bin",
+        "[CACHE]/builder/go/bin"
       ]
     },
     "name": "test"
@@ -255,7 +259,8 @@
       ],
       "PATH": [
         "[START_DIR]/packages",
-        "[START_DIR]/packages/bin"
+        "[START_DIR]/packages/bin",
+        "[CACHE]/builder/go/bin"
       ]
     },
     "name": "go vet"
@@ -276,7 +281,8 @@
       ],
       "PATH": [
         "[START_DIR]/packages",
-        "[START_DIR]/packages/bin"
+        "[START_DIR]/packages/bin",
+        "[CACHE]/builder/go/bin"
       ]
     },
     "name": "go fmt"
@@ -297,7 +303,8 @@
       ],
       "PATH": [
         "[START_DIR]/packages",
-        "[START_DIR]/packages/bin"
+        "[START_DIR]/packages/bin",
+        "[CACHE]/builder/go/bin"
       ]
     },
     "infra_step": true,
diff --git a/scripts/slave/recipes/goma_server.py b/scripts/slave/recipes/goma_server.py
index 56e7ba5..c5d1285 100644
--- a/scripts/slave/recipes/goma_server.py
+++ b/scripts/slave/recipes/goma_server.py
@@ -18,6 +18,10 @@
 PROTOC_VERSION = 'protobuf_version:v3.6.1'
 
 
+# TODO(yyanagisawa): install go and protoc from the script in source.
+#                    The compiler should be matched with the source, and the
+#                    script in the source code should install them like clang in
+#                    Chromium build.
 def SetupExecutables(api, pkg_dir):
   """Set up go and protoc to run the script.
 
@@ -44,7 +48,7 @@
   cipd_root = api.path['start_dir'].join('packages')
   env_prefixes = {
       'GOPATH': [gopath_dir],
-      'PATH': SetupExecutables(api, cipd_root),
+      'PATH': SetupExecutables(api, cipd_root) + [gopath_dir.join('bin')],
   }
   env = {
       'GO111MODULE': 'on',