pw_presubmit: Remove code for exiting early
Bug: b/295020927
Change-Id: I485e42b0c1546d88ea2608f3d08fcc6f2ebbdd35
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/170711
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Reviewed-by: Ted Pudlik <tpudlik@google.com>
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
diff --git a/recipes/pw_presubmit.expected/one_step_exit_early_failing.json b/recipes/pw_presubmit.expected/one_step_exit_early_failing.json
deleted file mode 100644
index ed9b757..0000000
--- a/recipes/pw_presubmit.expected/one_step_exit_early_failing.json
+++ /dev/null
@@ -1,109 +0,0 @@
-[
- {
- "cmd": [],
- "name": "checking CI status"
- },
- {
- "cmd": [],
- "name": "checking CI status.fetch project cr-buildbucket.cfg",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "luci-auth",
- "token",
- "-lifetime",
- "3m"
- ],
- "infra_step": true,
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checking CI status.fetch project cr-buildbucket.cfg.get access token for default account",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@2@@@"
- ]
- },
- {
- "cmd": [
- "vpython3",
- "-u",
- "RECIPE_MODULE[recipe_engine::url]/resources/pycurl.py",
- "--url",
- "https://luci-config.appspot.com/_ah/api/config/v1/config_sets/projects/project/config/cr-buildbucket.cfg",
- "--status-json",
- "/path/to/tmp/json",
- "--outfile",
- "/path/to/tmp/json",
- "--headers-json",
- "{\"Authorization\": \"Bearer extra.secret.token.should.not.be.logged\"}"
- ],
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checking CI status.fetch project cr-buildbucket.cfg.get",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@2@@@"
- ]
- },
- {
- "cmd": [
- "bb",
- "ls",
- "-host",
- "cr-buildbucket.appspot.com",
- "-json",
- "-nopage",
- "-n",
- "5",
- "-fields",
- "status",
- "-predicate",
- "{\"builder\": {\"bucket\": \"ci\", \"builder\": \"builder\", \"project\": \"project\"}, \"status\": \"ENDED_MASK\"}"
- ],
- "infra_step": true,
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checking CI status.buildbucket.search",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@",
- "@@@STEP_LOG_LINE@raw_io.output_text@{\"status\": \"FAILURE\"}@@@",
- "@@@STEP_LOG_END@raw_io.output_text@@@",
- "@@@STEP_LINK@0@https://cr-buildbucket.appspot.com/build/8945511751514863184@@@"
- ]
- },
- {
- "name": "$result",
- "summaryMarkdown": "Exiting early since [project/ci/builder](https://ci.chromium.org/ui/p/project/builders/ci/builder) has not recently passed."
- }
-]
\ No newline at end of file
diff --git a/recipes/pw_presubmit.expected/one_step_exit_early_led.json b/recipes/pw_presubmit.expected/one_step_exit_early_led.json
deleted file mode 100644
index 730891d..0000000
--- a/recipes/pw_presubmit.expected/one_step_exit_early_led.json
+++ /dev/null
@@ -1,17 +0,0 @@
-[
- {
- "cmd": [],
- "name": "checking CI status"
- },
- {
- "cmd": [],
- "name": "checking CI status.builder was launched by led, ignoring",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "name": "$result",
- "summaryMarkdown": "Exiting early since this is a led build."
- }
-]
\ No newline at end of file
diff --git a/recipes/pw_presubmit.expected/one_step_no_exit_not_in_cv.json b/recipes/pw_presubmit.expected/one_step_no_exit_not_in_cv.json
index 47ac0de..de97848 100644
--- a/recipes/pw_presubmit.expected/one_step_no_exit_not_in_cv.json
+++ b/recipes/pw_presubmit.expected/one_step_no_exit_not_in_cv.json
@@ -1,17 +1,6 @@
[
{
"cmd": [],
- "name": "checking CI status"
- },
- {
- "cmd": [],
- "name": "checking CI status.builder was not triggered by CV, ignoring",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [],
"name": "checkout pigweed",
"~followup_annotations": [
"@@@STEP_LINK@applied pigweed:123456@https://pigweed-review.googlesource.com/c/123456@@@"
diff --git a/recipes/pw_presubmit.expected/one_step_no_exit_not_tryjob.json b/recipes/pw_presubmit.expected/one_step_no_exit_not_tryjob.json
index ed9341e..1f1ba70 100644
--- a/recipes/pw_presubmit.expected/one_step_no_exit_not_tryjob.json
+++ b/recipes/pw_presubmit.expected/one_step_no_exit_not_tryjob.json
@@ -1,17 +1,6 @@
[
{
"cmd": [],
- "name": "checking CI status"
- },
- {
- "cmd": [],
- "name": "checking CI status.builder is not a tryjob, ignoring",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [],
"name": "checkout pigweed",
"~followup_annotations": [
"@@@STEP_LINK@applied pigweed:1234@https://pigweed-review.googlesource.com/c/1234@@@"
diff --git a/recipes/pw_presubmit.expected/one_step_no_exit_passing_in_ci.json b/recipes/pw_presubmit.expected/one_step_no_exit_passing_in_ci.json
index 3ce8edc..de97848 100644
--- a/recipes/pw_presubmit.expected/one_step_no_exit_passing_in_ci.json
+++ b/recipes/pw_presubmit.expected/one_step_no_exit_passing_in_ci.json
@@ -1,116 +1,6 @@
[
{
"cmd": [],
- "name": "checking CI status"
- },
- {
- "cmd": [],
- "name": "checking CI status.fetch project cr-buildbucket.cfg",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [
- "luci-auth",
- "token",
- "-lifetime",
- "3m"
- ],
- "infra_step": true,
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checking CI status.fetch project cr-buildbucket.cfg.get access token for default account",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@2@@@"
- ]
- },
- {
- "cmd": [
- "vpython3",
- "-u",
- "RECIPE_MODULE[recipe_engine::url]/resources/pycurl.py",
- "--url",
- "https://luci-config.appspot.com/_ah/api/config/v1/config_sets/projects/project/config/cr-buildbucket.cfg",
- "--status-json",
- "/path/to/tmp/json",
- "--outfile",
- "/path/to/tmp/json",
- "--headers-json",
- "{\"Authorization\": \"Bearer extra.secret.token.should.not.be.logged\"}"
- ],
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checking CI status.fetch project cr-buildbucket.cfg.get",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@2@@@"
- ]
- },
- {
- "cmd": [
- "bb",
- "ls",
- "-host",
- "cr-buildbucket.appspot.com",
- "-json",
- "-nopage",
- "-n",
- "5",
- "-fields",
- "status",
- "-predicate",
- "{\"builder\": {\"bucket\": \"ci\", \"builder\": \"builder\", \"project\": \"project\"}, \"status\": \"ENDED_MASK\"}"
- ],
- "infra_step": true,
- "luci_context": {
- "realm": {
- "name": "project:try"
- },
- "resultdb": {
- "current_invocation": {
- "name": "invocations/build:8945511751514863184",
- "update_token": "token"
- },
- "hostname": "rdbhost"
- }
- },
- "name": "checking CI status.buildbucket.search",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@",
- "@@@STEP_LOG_LINE@raw_io.output_text@{\"status\": \"SUCCESS\"}@@@",
- "@@@STEP_LOG_END@raw_io.output_text@@@",
- "@@@STEP_LINK@0@https://cr-buildbucket.appspot.com/build/8945511751514863184@@@"
- ]
- },
- {
- "cmd": [],
- "name": "checking CI status.builder recently passed in CI",
- "~followup_annotations": [
- "@@@STEP_NEST_LEVEL@1@@@"
- ]
- },
- {
- "cmd": [],
"name": "checkout pigweed",
"~followup_annotations": [
"@@@STEP_LINK@applied pigweed:123456@https://pigweed-review.googlesource.com/c/123456@@@"
diff --git a/recipes/pw_presubmit.py b/recipes/pw_presubmit.py
index 05b4fc7..5e977a2 100644
--- a/recipes/pw_presubmit.py
+++ b/recipes/pw_presubmit.py
@@ -21,20 +21,16 @@
from PB.recipe_engine import result
DEPS = [
- 'fuchsia/buildbucket_util',
- 'fuchsia/builder_status',
'fuchsia/gsutil',
'pigweed/checkout',
'pigweed/environment',
'pigweed/pw_presubmit',
'pigweed/util',
- 'recipe_engine/buildbucket',
'recipe_engine/cq',
'recipe_engine/cv',
'recipe_engine/file',
'recipe_engine/futures',
'recipe_engine/json',
- 'recipe_engine/led',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/raw_io',
@@ -68,54 +64,10 @@
).stdout
-def _check_ci_status(api, props):
- if not props.num_ci_failures_to_trigger_exiting_early:
- return None
-
- with api.step.nest('checking CI status'):
- if not api.buildbucket_util.is_tryjob:
- api.step('builder is not a tryjob, ignoring', None)
- return None
-
- if api.led.launched_by_led:
- api.step('builder was launched by led, ignoring', None)
- return result.RawResult(
- summary_markdown=('Exiting early since this is a led build.'),
- status=common.SUCCESS,
- )
-
- if not api.cv.active:
- api.step('builder was not triggered by CV, ignoring', None)
- return None
-
- bucket = re.sub(r'\btry\b', 'ci', api.buildbucket.build.builder.bucket)
- status = api.builder_status.retrieve(
- bucket=bucket,
- n=props.num_ci_failures_to_trigger_exiting_early,
- include_incomplete=False,
- )
- if api.builder_status.has_recently_passed(status):
- api.step('builder recently passed in CI', None)
- return None
-
- full_name = '/'.join((status.project, bucket, status.builder))
- return result.RawResult(
- summary_markdown=(
- f'Exiting early since [{full_name}]({status.link}) has not '
- 'recently passed.'
- ),
- status=common.SUCCESS,
- )
-
-
def RunSteps(api, props):
"""Run Pigweed presubmit checks."""
gcs_bucket = props.gcs_bucket
- res = _check_ci_status(api, props)
- if res:
- return res
-
checkout = api.checkout(props.checkout_options)
env = api.environment.init(checkout, props.environment_options)
@@ -347,48 +299,25 @@
yield (
api.test('one_step_no_exit_passing_in_ci')
- + properties(step=['step1'], num_ci_failures_to_trigger_exiting_early=5)
+ + properties(step=['step1'])
+ api.checkout.try_test_data()
+ api.cv(run_mode=api.cq.DRY_RUN)
- + api.buildbucket.simulated_search_results(
- [api.builder_status.passed()],
- step_name='checking CI status.buildbucket.search',
- )
)
yield (
api.test('one_step_no_exit_not_tryjob')
- + properties(step=['step1'], num_ci_failures_to_trigger_exiting_early=5)
+ + properties(step=['step1'])
+ api.checkout.ci_test_data()
+ api.cv(run_mode=api.cv.DRY_RUN)
)
yield (
api.test('one_step_no_exit_not_in_cv')
- + properties(step=['step1'], num_ci_failures_to_trigger_exiting_early=5)
+ + properties(step=['step1'])
+ api.checkout.try_test_data()
)
yield (
- api.test('one_step_exit_early_led')
- + properties(step=['step1'], num_ci_failures_to_trigger_exiting_early=5)
- + api.properties(**{'$recipe_engine/led': {'led_run_id': '123'}})
- + api.checkout.try_test_data()
- + api.cv(run_mode=api.cv.DRY_RUN)
- )
-
- yield (
- api.test('one_step_exit_early_failing')
- + properties(step=['step1'], num_ci_failures_to_trigger_exiting_early=5)
- + api.checkout.try_test_data()
- + api.cv(run_mode=api.cv.DRY_RUN)
- + api.buildbucket.simulated_search_results(
- [api.builder_status.failure()],
- step_name='checking CI status.buildbucket.search',
- )
- )
-
- yield (
api.test('two_steps')
+ properties(step=['step1', 'step2'], gcs_bucket='bucket')
+ api.checkout.try_test_data(