[rollers] Migrate to auto_roller Options
Uses the new API introduced in https://fxrev.dev/631608. Long-term these
could be moved into nested properties to reduce plumbing.
Change-Id: I5b8e768f632c3507e61fa1bcf34a35c194fb926a
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/97340
Commit-Queue: Oliver Newman <olivernewman@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
Pigweed-Auto-Submit: Oliver Newman <olivernewman@google.com>
diff --git a/infra/config/recipes.cfg b/infra/config/recipes.cfg
index 62c7300..b4d2438 100644
--- a/infra/config/recipes.cfg
+++ b/infra/config/recipes.cfg
@@ -17,7 +17,7 @@
"deps": {
"fuchsia": {
"branch": "refs/heads/main",
- "revision": "64e1bfe1678f35ac7f2ab51c626aff87b34e3678",
+ "revision": "13869fb3978e6da5f42e0a5adf4f8dc4e673a56e",
"url": "https://fuchsia.googlesource.com/infra/recipes"
},
"recipe_engine": {
diff --git a/recipes/cipd_roller.py b/recipes/cipd_roller.py
index dad980f..016111d 100644
--- a/recipes/cipd_roller.py
+++ b/recipes/cipd_roller.py
@@ -224,9 +224,14 @@
)
change = api.auto_roller.attempt_roll(
- gerrit_host=checkout.gerrit_host(),
- gerrit_project=checkout.gerrit_project(),
- upstream_ref=checkout.options.branch,
+ api.auto_roller.Options(
+ remote=checkout.options.remote,
+ upstream_ref=checkout.options.branch,
+ dry_run=dry_run,
+ labels_to_set=api.roll_util.labels_to_set,
+ labels_to_wait_on=api.roll_util.labels_to_wait_on,
+ bot_commit=props.bot_commit,
+ ),
repo_dir=api.path.dirname(cipd_json_path),
commit_message=COMMIT_MESSAGE.format(
package_name=package_name,
@@ -236,10 +241,6 @@
builder=api.buildbucket.builder_name,
build_id=api.buildbucket_util.id,
),
- dry_run=dry_run,
- labels_to_set=api.roll_util.labels_to_set,
- labels_to_wait_on=api.roll_util.labels_to_wait_on,
- bot_commit=props.bot_commit,
)
return api.auto_roller.raw_result(change)
@@ -299,7 +300,8 @@
return api.step_data(
'find shared tag.cipd describe {}'.format(package_paths[1]),
api.cipd.example_describe(
- package_paths[1], test_data_tags=['{}:{}'.format(tagname, 0)],
+ package_paths[1],
+ test_data_tags=['{}:{}'.format(tagname, 0)],
),
)
diff --git a/recipes/multiple_submodule_roller.py b/recipes/multiple_submodule_roller.py
index 6516705..ac43408 100644
--- a/recipes/multiple_submodule_roller.py
+++ b/recipes/multiple_submodule_roller.py
@@ -137,7 +137,8 @@
submodule.branch = 'main'
submodule.remote = api.roll_util.normalize_remote(
- parser.get(section, 'url'), checkout.options.remote,
+ parser.get(section, 'url'),
+ checkout.options.remote,
)
change = _update_submodule(
@@ -183,25 +184,26 @@
# include_cc() writes steps, so we want things sorted before calling it.
cc = sorted(set(cc))
- cc = [x for x in cc if include_cc(x)]
+ cc_emails = [x.email for x in cc if include_cc(x)]
roll_kwargs = {}
if always_cc:
- roll_kwargs['cc'] = [x.email for x in cc]
+ roll_kwargs['cc_emails'] = cc_emails
else:
- roll_kwargs['cc_on_failure'] = [x.email for x in cc]
+ roll_kwargs['cc_on_failure_emails'] = cc_emails
change = api.auto_roller.attempt_roll(
- gerrit_host=checkout.gerrit_host(),
- gerrit_project=checkout.gerrit_project(),
- upstream_ref=checkout.options.branch,
+ api.auto_roller.Options(
+ remote=checkout.options.remote,
+ upstream_ref=checkout.options.branch,
+ dry_run=dry_run,
+ labels_to_set=api.roll_util.labels_to_set,
+ labels_to_wait_on=api.roll_util.labels_to_wait_on,
+ bot_commit=props.bot_commit,
+ **roll_kwargs
+ ),
repo_dir=checkout.root,
commit_message=api.roll_util.message(*rolls.values()),
- dry_run=dry_run,
- labels_to_set=api.roll_util.labels_to_set,
- labels_to_wait_on=api.roll_util.labels_to_wait_on,
- bot_commit=props.bot_commit,
- **roll_kwargs
)
return api.auto_roller.raw_result(change)
@@ -266,7 +268,9 @@
yield (
api.status_check.test('success')
+ properties(
- submodules('a1', 'b2'), cc_authors_on_rolls=True, always_cc=True,
+ submodules('a1', 'b2'),
+ cc_authors_on_rolls=True,
+ always_cc=True,
)
+ commit_data('a1', prefix='')
+ commit_data('b2', prefix='')
diff --git a/recipes/repo_roller.py b/recipes/repo_roller.py
index cea71dc..1dafdc1 100644
--- a/recipes/repo_roller.py
+++ b/recipes/repo_roller.py
@@ -243,13 +243,13 @@
# include_cc() writes steps, so we want things sorted before calling it.
cc = sorted(set(cc))
- cc = [x for x in cc if include_cc(x)]
+ cc_emails = [x.email for x in cc if include_cc(x)]
roll_kwargs = {}
if always_cc:
- roll_kwargs['cc'] = [x.email for x in cc]
+ roll_kwargs['cc_emails'] = cc_emails
else:
- roll_kwargs['cc_on_failure'] = [x.email for x in cc]
+ roll_kwargs['cc_on_failure_emails'] = cc_emails
author_override = None
with api.step.nest('authors') as pres:
@@ -260,16 +260,17 @@
)._asdict()
change = api.auto_roller.attempt_roll(
- gerrit_host=checkout.gerrit_host(),
- gerrit_project=checkout.gerrit_project(),
- upstream_ref=checkout.options.branch,
+ api.auto_roller.Options(
+ remote=checkout.options.remote,
+ upstream_ref=checkout.options.branch,
+ dry_run=dry_run,
+ labels_to_set=api.roll_util.labels_to_set,
+ labels_to_wait_on=api.roll_util.labels_to_wait_on,
+ bot_commit=props.bot_commit,
+ **roll_kwargs
+ ),
repo_dir=checkout.root,
commit_message=api.roll_util.message(roll),
- dry_run=dry_run,
- labels_to_set=api.roll_util.labels_to_set,
- labels_to_wait_on=api.roll_util.labels_to_wait_on,
- bot_commit=props.bot_commit,
- **roll_kwargs
)
return api.auto_roller.raw_result(change)
diff --git a/recipes/submodule_roller.py b/recipes/submodule_roller.py
index c19a095..7330d31 100644
--- a/recipes/submodule_roller.py
+++ b/recipes/submodule_roller.py
@@ -176,7 +176,9 @@
else:
api.roll_util.skip_roll_step(
- dep.remote, old_revision, dep.commit,
+ dep.remote,
+ old_revision,
+ dep.commit,
)
pres.step_summary_text = 'already applied'
@@ -251,7 +253,8 @@
submodule_dir = checkout.root.join(submodule_path)
remote = api.roll_util.normalize_remote(
- parser.get(section, 'url'), checkout.options.remote,
+ parser.get(section, 'url'),
+ checkout.options.remote,
)
# If this was triggered by a gitiles poller, check that the triggering
@@ -312,9 +315,9 @@
roll_kwargs = {}
if always_cc:
- roll_kwargs['cc'] = [x.email for x in cc]
+ roll_kwargs['cc_emails'] = [x.email for x in cc]
else:
- roll_kwargs['cc_on_failure'] = [x.email for x in cc]
+ roll_kwargs['cc_on_failure_emails'] = [x.email for x in cc]
author_override = None
with api.step.nest('authors') as pres:
@@ -325,17 +328,18 @@
)._asdict()
change = api.auto_roller.attempt_roll(
- gerrit_host=checkout.gerrit_host(),
- gerrit_project=checkout.gerrit_project(),
- upstream_ref=checkout.options.branch,
+ api.auto_roller.Options(
+ remote=checkout.options.remote,
+ upstream_ref=checkout.options.branch,
+ dry_run=dry_run,
+ labels_to_set=api.roll_util.labels_to_set,
+ labels_to_wait_on=api.roll_util.labels_to_wait_on,
+ bot_commit=props.bot_commit,
+ **roll_kwargs
+ ),
repo_dir=checkout.root,
commit_message=api.roll_util.message(*rolls.values()),
- dry_run=dry_run,
- labels_to_set=api.roll_util.labels_to_set,
- labels_to_wait_on=api.roll_util.labels_to_wait_on,
- bot_commit=props.bot_commit,
author_override=author_override,
- **roll_kwargs
)
return api.auto_roller.raw_result(change)
@@ -432,10 +436,13 @@
yield (
api.status_check.test(
- 'relative-dotdot-dotdot-always-cc-reviewers', status='failure',
+ 'relative-dotdot-dotdot-always-cc-reviewers',
+ status='failure',
)
+ properties(
- submodule_path='a1', cc_reviewers_on_rolls=True, always_cc=True,
+ submodule_path='a1',
+ cc_reviewers_on_rolls=True,
+ always_cc=True,
)
+ trigger('https://pigweed.googlesource.com/a1')
+ commit_data('a1', prefix='')
@@ -552,10 +559,13 @@
prefix='',
)
+ api.cq_deps.details(
- 'foo:2000', message='Requires: {}'.format(','.join(requires)),
+ 'foo:2000',
+ message='Requires: {}'.format(','.join(requires)),
)
+ api.roll_util.commit_data(
- 'spam', api.roll_util.commit('2' * 40), prefix='',
+ 'spam',
+ api.roll_util.commit('2' * 40),
+ prefix='',
)
+ api.roll_util.forward_roll()
)
@@ -565,7 +575,9 @@
requires_test('with-requires', 'foo:444')
+ api.cq_deps.details('foo:444', status='MERGED', project='ham')
+ api.roll_util.commit_data(
- 'ham', api.roll_util.commit('2' * 40), prefix='applying foo:444.',
+ 'ham',
+ api.roll_util.commit('2' * 40),
+ prefix='applying foo:444.',
)
+ api.roll_util.forward_roll('applying foo:444.')
+ api.auto_roller.dry_run_success()
@@ -590,7 +602,9 @@
yield (
requires_test('with-requires-not-in-checkout', 'foo:444')
+ api.cq_deps.details(
- 'foo:444', status='MERGED', project='not-in-this-checkout',
+ 'foo:444',
+ status='MERGED',
+ project='not-in-this-checkout',
)
+ api.auto_roller.dry_run_success()
)
@@ -605,12 +619,16 @@
message='Requires: foo:555',
)
+ api.roll_util.commit_data(
- 'ham', api.roll_util.commit('2' * 40), prefix='applying foo:444.',
+ 'ham',
+ api.roll_util.commit('2' * 40),
+ prefix='applying foo:444.',
)
+ api.roll_util.forward_roll('applying foo:444.')
+ api.cq_deps.details('foo:555', status='MERGED', project='eggs')
+ api.roll_util.commit_data(
- 'eggs', api.roll_util.commit('2' * 40), prefix='applying foo:555.',
+ 'eggs',
+ api.roll_util.commit('2' * 40),
+ prefix='applying foo:555.',
)
+ api.roll_util.forward_roll('applying foo:555.')
+ api.auto_roller.dry_run_success()
@@ -626,7 +644,9 @@
message='Requires: foo:2000',
)
+ api.roll_util.commit_data(
- 'ham', api.roll_util.commit('2' * 40), prefix='applying foo:444.',
+ 'ham',
+ api.roll_util.commit('2' * 40),
+ prefix='applying foo:444.',
)
+ api.roll_util.forward_roll('applying foo:444.')
+ api.auto_roller.dry_run_success()
@@ -637,14 +657,22 @@
def parent_child_test(*args, **kwargs):
return (
requires_test(*args, **kwargs)
- + api.cq_deps.details('foo:444', status='MERGED', project='ham',)
+ + api.cq_deps.details(
+ 'foo:444',
+ status='MERGED',
+ project='ham',
+ )
+ api.roll_util.commit_data(
'ham',
api.roll_util.commit('4' * 40),
prefix='applying foo:444.',
)
+ api.roll_util.forward_roll('applying foo:444.')
- + api.cq_deps.details('foo:555', status='MERGED', project='ham',)
+ + api.cq_deps.details(
+ 'foo:555',
+ status='MERGED',
+ project='ham',
+ )
)
# CL 2000 requires CL 444 in ham and CL 555 in ham, both of which are
@@ -653,7 +681,9 @@
parent_child_test('with-requires-child', 'foo:444', 'foo:555')
+ api.roll_util.forward_roll('applying foo:555.')
+ api.roll_util.commit_data(
- 'ham', api.roll_util.commit('5' * 40), prefix='applying foo:555.',
+ 'ham',
+ api.roll_util.commit('5' * 40),
+ prefix='applying foo:555.',
)
+ api.auto_roller.dry_run_success()
)
diff --git a/recipes/target_to_git.expected/success.json b/recipes/target_to_git.expected/success.json
index 2227109..7ec3ab2 100644
--- a/recipes/target_to_git.expected/success.json
+++ b/recipes/target_to_git.expected/success.json
@@ -2331,7 +2331,7 @@
"-host",
"https://pigweed-review.googlesource.com",
"-input",
- "{\"params\": {\"o\": [\"CURRENT_COMMIT\", \"CURRENT_REVISION\", \"MESSAGES\"], \"q\": \"change:generated~~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c\"}}",
+ "{\"params\": {\"o\": [\"CURRENT_COMMIT\", \"CURRENT_REVISION\", \"MESSAGES\"], \"q\": \"change:generated~main~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c\"}}",
"-output",
"/path/to/tmp/json"
],
@@ -2361,7 +2361,7 @@
"@@@STEP_LOG_LINE@json.input@ \"CURRENT_REVISION\", @@@",
"@@@STEP_LOG_LINE@json.input@ \"MESSAGES\"@@@",
"@@@STEP_LOG_LINE@json.input@ ], @@@",
- "@@@STEP_LOG_LINE@json.input@ \"q\": \"change:generated~~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c\"@@@",
+ "@@@STEP_LOG_LINE@json.input@ \"q\": \"change:generated~main~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c\"@@@",
"@@@STEP_LOG_LINE@json.input@ }@@@",
"@@@STEP_LOG_LINE@json.input@}@@@",
"@@@STEP_LOG_END@json.input@@@"
@@ -2399,7 +2399,7 @@
"--push-option",
"nokeycheck",
"origin",
- "HEAD:refs/for/%l=Commit-Queue+2"
+ "HEAD:refs/for/main%l=Commit-Queue+2"
],
"cwd": "[START_DIR]/export_repo",
"infra_step": true,
@@ -2420,7 +2420,7 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@stdout@@@@",
"@@@STEP_LOG_END@stdout@@@",
- "@@@STEP_LINK@gerrit link@https://pigweed-review.googlesource.com/q/generated~~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c@@@"
+ "@@@STEP_LINK@gerrit link@https://pigweed-review.googlesource.com/q/generated~main~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c@@@"
]
},
{
@@ -2434,7 +2434,7 @@
"-host",
"https://pigweed-review.googlesource.com",
"-input",
- "{\"change_id\": \"generated~~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c\", \"params\": {\"o\": [\"CURRENT_REVISION\"]}}",
+ "{\"change_id\": \"generated~main~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c\", \"params\": {\"o\": [\"CURRENT_REVISION\"]}}",
"-output",
"/path/to/tmp/json"
],
@@ -2466,7 +2466,7 @@
"@@@STEP_LOG_LINE@json.output@}@@@",
"@@@STEP_LOG_END@json.output@@@",
"@@@STEP_LOG_LINE@json.input@{@@@",
- "@@@STEP_LOG_LINE@json.input@ \"change_id\": \"generated~~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c\", @@@",
+ "@@@STEP_LOG_LINE@json.input@ \"change_id\": \"generated~main~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c\", @@@",
"@@@STEP_LOG_LINE@json.input@ \"params\": {@@@",
"@@@STEP_LOG_LINE@json.input@ \"o\": [@@@",
"@@@STEP_LOG_LINE@json.input@ \"CURRENT_REVISION\"@@@",
@@ -2474,7 +2474,7 @@
"@@@STEP_LOG_LINE@json.input@ }@@@",
"@@@STEP_LOG_LINE@json.input@}@@@",
"@@@STEP_LOG_END@json.input@@@",
- "@@@STEP_LINK@gerrit link@https://pigweed-review.googlesource.com/q/generated~~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c@@@"
+ "@@@STEP_LINK@gerrit link@https://pigweed-review.googlesource.com/q/generated~main~I28135185e8ac8c69d0b894c4be54ddbb0ea69d5c@@@"
]
},
{
diff --git a/recipes/target_to_git.py b/recipes/target_to_git.py
index 07a7f42..dadb80e 100644
--- a/recipes/target_to_git.py
+++ b/recipes/target_to_git.py
@@ -82,15 +82,16 @@
api.git('git add --intent-to-add', 'add', '--intent-to-add', '.')
change = api.auto_roller.attempt_roll(
- gerrit_host=api.gerrit.host_from_remote_url(props.remote),
- gerrit_project=urlparse(props.remote).path.strip('/'),
- upstream_ref=props.branch,
+ api.auto_roller.Options(
+ remote=props.remote,
+ upstream_ref=props.branch,
+ dry_run=props.dry_run,
+ labels_to_set=api.roll_util.labels_to_set,
+ labels_to_wait_on=api.roll_util.labels_to_wait_on,
+ bot_commit=props.bot_commit,
+ ),
repo_dir=export_repo,
commit_message='Update for {}'.format(checkout.revision()),
- dry_run=props.dry_run,
- labels_to_set=api.roll_util.labels_to_set,
- labels_to_wait_on=api.roll_util.labels_to_wait_on,
- bot_commit=props.bot_commit,
)
return api.auto_roller.raw_result(change)
diff --git a/recipes/tokendb_updater.py b/recipes/tokendb_updater.py
index 9ca457c..bc6a6a9 100644
--- a/recipes/tokendb_updater.py
+++ b/recipes/tokendb_updater.py
@@ -78,6 +78,9 @@
if props.tokendb_host:
tokendb_host = '{}.googlesource.com'.format(props.tokendb_host)
tokendb_project = props.tokendb_project or checkout.gerrit_project()
+ tokendb_remote = 'https://{}/{}'.format(
+ tokendb_host.rstrip('/'), tokendb_project.strip('/')
+ )
# If the token database is in the top-level repo we just use that. If not
# we need to checkout the repo even though it's already in our checkout.
@@ -87,9 +90,6 @@
if props.tokendb_host and props.tokendb_project:
tokendb_repo = api.path['start_dir'].join('tokendb')
- tokendb_remote = 'https://{}/{}'.format(
- tokendb_host.rstrip('/'), tokendb_project.strip('/')
- )
tokendb_branch = props.tokendb_branch or "main"
api.checkout(
CheckoutOptions(
@@ -111,15 +111,16 @@
message = 'Update token db for commit {}'.format(checkout.revision()[0:15])
change = api.auto_roller.attempt_roll(
- gerrit_host=tokendb_host,
- gerrit_project=tokendb_project,
- upstream_ref=tokendb_branch,
+ api.auto_roller.Options(
+ remote=tokendb_remote,
+ upstream_ref=tokendb_branch,
+ dry_run=props.dry_run,
+ labels_to_set=api.roll_util.labels_to_set,
+ labels_to_wait_on=api.roll_util.labels_to_wait_on,
+ bot_commit=props.bot_commit,
+ ),
repo_dir=tokendb_repo,
commit_message=message,
- dry_run=props.dry_run,
- labels_to_set=api.roll_util.labels_to_set,
- labels_to_wait_on=api.roll_util.labels_to_wait_on,
- bot_commit=props.bot_commit,
)
return api.auto_roller.raw_result(change)
diff --git a/recipes/txt_roller.py b/recipes/txt_roller.py
index 448184b..5d6ad18 100644
--- a/recipes/txt_roller.py
+++ b/recipes/txt_roller.py
@@ -83,7 +83,9 @@
project_checkout = api.checkout(
CheckoutOptions(
- remote=project_remote, branch=project_branch, use_trigger=True,
+ remote=project_remote,
+ branch=project_branch,
+ use_trigger=True,
),
root=project_dir,
)
@@ -98,7 +100,9 @@
full_txt_path = checkout.root.join(txt_path)
old_revision = api.file.read_text(
- 'read old revision', full_txt_path, test_data='1' * 40,
+ 'read old revision',
+ full_txt_path,
+ test_data='1' * 40,
).strip()
api.file.write_text('write new revision', full_txt_path, new_revision)
@@ -135,15 +139,16 @@
)._asdict()
change = api.auto_roller.attempt_roll(
- gerrit_host=checkout.gerrit_host(),
- gerrit_project=checkout.gerrit_project(),
- upstream_ref=checkout.options.branch,
+ api.auto_roller.Options(
+ remote=checkout.options.remote,
+ upstream_ref=checkout.options.branch,
+ dry_run=props.dry_run,
+ labels_to_set=api.roll_util.labels_to_set,
+ labels_to_wait_on=api.roll_util.labels_to_wait_on,
+ bot_commit=props.bot_commit,
+ ),
repo_dir=checkout.root,
commit_message=api.roll_util.message(*rolls.values()),
- dry_run=props.dry_run,
- labels_to_set=api.roll_util.labels_to_set,
- labels_to_wait_on=api.roll_util.labels_to_wait_on,
- bot_commit=props.bot_commit,
author_override=author_override,
)
diff --git a/recipes/update_python_versions.py b/recipes/update_python_versions.py
index 6a3cbeb..b222e2b 100644
--- a/recipes/update_python_versions.py
+++ b/recipes/update_python_versions.py
@@ -38,7 +38,9 @@
def RunSteps(api, props): # pylint: disable=invalid-name
checkout = api.checkout(props.checkout_options)
env = api.environment.init(
- checkout.root, props.environment_options, use_constraint_file=False,
+ checkout.root,
+ props.environment_options,
+ use_constraint_file=False,
)
with env():
@@ -74,17 +76,16 @@
api.step('freeze package list', cmd)
change = api.auto_roller.attempt_roll(
- gerrit_host=api.gerrit.host_from_remote_url(checkout.options.remote),
- gerrit_project=api.gerrit.project_from_remote_url(
- checkout.options.remote
+ api.auto_roller.Options(
+ remote=checkout.options.remote,
+ upstream_ref=checkout.options.branch,
+ dry_run=props.dry_run,
+ labels_to_set=api.roll_util.labels_to_set,
+ labels_to_wait_on=api.roll_util.labels_to_wait_on,
+ bot_commit=props.bot_commit,
),
- upstream_ref=checkout.options.branch,
repo_dir=checkout.root,
commit_message='roll: Update Python package versions',
- dry_run=props.dry_run,
- labels_to_set=api.roll_util.labels_to_set,
- labels_to_wait_on=api.roll_util.labels_to_wait_on,
- bot_commit=props.bot_commit,
)
return api.auto_roller.raw_result(change)