rollers: Check if roll is backwards
Backwards rolls never happened, but they caused infra failures when
running `git log $OLD..$NEW`. Now rollers check if the roll is in
reverse and marks the run as successful. This is needed because
occasionally LUCI config changes result in luci-scheduler thinking a
roller is new and triggering 30 rolls that all fail. Now they'll still
be triggered but they won't do anything and then they'll pass.
Added this logic to the roll_message module, which is now renamed to
roll_util.
Tested by retriggering a past successful roll.
$ led get-build 8868516989406765792 | led edit-recipe-bundle | \
led edit -p 'dry_run=true' | led launch
LUCI UI: https://ci.chromium.org/swarming/task/4ecf5393d5a23d10
Also tested by pausing a roller and manually triggering after another CL
went in.
$ led get-builder luci.pigweed.ci:pigweed-stm32-roller | \
led edit-recipe-bundle | led edit -p dry_run=true | led launch
LUCI UI: https://ci.chromium.org/swarming/task/4ed09708b7433d10
Change-Id: I057272a5221626312a96b195eccdaf9dd8dc053d
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/18683
Reviewed-by: Oliver Newman <olivernewman@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/recipe_modules/roll_util/test_api.py b/recipe_modules/roll_util/test_api.py
new file mode 100644
index 0000000..efb98a2
--- /dev/null
+++ b/recipe_modules/roll_util/test_api.py
@@ -0,0 +1,37 @@
+# Copyright 2020 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+from recipe_engine import post_process, recipe_test_api
+
+
+class RollUtilTestApi(recipe_test_api.RecipeTestApi):
+
+ def commit(self, hash, message):
+ return ' '.join((hash, message))
+
+ def commit_data(self, *commits):
+ return self.step_data('roll message.git log',
+ stdout=self.m.raw_io.output('\0'.join(commits)))
+
+ def cancelled(self):
+ return self.post_process(post_process.MustRunRE, '.*cancelling roll.*')
+
+ def not_cancelled(self):
+ return self.post_process(post_process.DoesNotRunRE, '.*cancelling roll.*')
+
+ def rolls_forward(self, prefix='', name='check roll direction'):
+ return self.step_data(prefix + name, retcode=0)
+
+ def rolls_backward(self, prefix='', name='check roll direction'):
+ return self.step_data(prefix + name, retcode=1)