aboutsummaryrefslogtreecommitdiffhomepage
path: root/infra/bots/recipe_modules
diff options
context:
space:
mode:
authorGravatar borenet <borenet@chromium.org>2016-10-24 06:36:30 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-10-24 06:36:30 -0700
commit09732a6b0e7c4b087279095762f9d27a4f556aba (patch)
tree1c741c75b5a231ad92ef74c887fdbe818b2a2d0b /infra/bots/recipe_modules
parent1326068147ee60de138061a3fc1157fcfd5d017b (diff)
Add infra recipe module, use for updating Go DEPS
Diffstat (limited to 'infra/bots/recipe_modules')
-rw-r--r--infra/bots/recipe_modules/infra/__init__.py9
-rw-r--r--infra/bots/recipe_modules/infra/api.py32
-rw-r--r--infra/bots/recipe_modules/run/api.py12
3 files changed, 53 insertions, 0 deletions
diff --git a/infra/bots/recipe_modules/infra/__init__.py b/infra/bots/recipe_modules/infra/__init__.py
new file mode 100644
index 0000000000..ba20b52f95
--- /dev/null
+++ b/infra/bots/recipe_modules/infra/__init__.py
@@ -0,0 +1,9 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+DEPS = [
+ 'recipe_engine/step',
+ 'run',
+ 'vars',
+]
diff --git a/infra/bots/recipe_modules/infra/api.py b/infra/bots/recipe_modules/infra/api.py
new file mode 100644
index 0000000000..17d3729b87
--- /dev/null
+++ b/infra/bots/recipe_modules/infra/api.py
@@ -0,0 +1,32 @@
+# Copyright 2016 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+
+from recipe_engine import recipe_api
+
+
+INFRA_GO_PKG = 'go.skia.org/infra'
+UPDATE_GO_ATTEMPTS = 5
+
+
+class InfraApi(recipe_api.RecipeApi):
+ @property
+ def go_env(self):
+ return {'GOPATH': self.gopath}
+
+ @property
+ def gopath(self):
+ return self.m.vars.checkout_root.join('gopath')
+
+ def update_go_deps(self):
+ """Attempt to update go dependencies.
+
+ This fails flakily sometimes, so perform multiple attempts.
+ """
+ self.m.run.with_retry(
+ self.m.step,
+ 'update go pkgs',
+ UPDATE_GO_ATTEMPTS,
+ cmd=['go', 'get', '-u', '%s/...' % INFRA_GO_PKG],
+ env=self.go_env)
diff --git a/infra/bots/recipe_modules/run/api.py b/infra/bots/recipe_modules/run/api.py
index ffcced1947..3ef69d806b 100644
--- a/infra/bots/recipe_modules/run/api.py
+++ b/infra/bots/recipe_modules/run/api.py
@@ -115,3 +115,15 @@ for pattern in build_products_whitelist:
''' % str(BUILD_PRODUCTS_ISOLATE_WHITELIST),
args=[src, dst],
infra_step=True)
+
+ def with_retry(self, steptype, name, attempts, *args, **kwargs):
+ for attempt in xrange(attempts):
+ step_name = name
+ if attempt > 0:
+ step_name += ' (attempt %d)' % (attempt + 1)
+ try:
+ steptype(step_name, *args, **kwargs)
+ return
+ except self.m.step.StepFailure:
+ if attempt == attempts - 1:
+ raise