static_checks: Mark "WIP" changes as WIP
Also match "work in progress".
Bug: b/374993770
Change-Id: Ia8b8697a3f1cd989f8cb2d98a73b7eecee5943c6
Reviewed-on: https://pigweed-review.googlesource.com/c/infra/recipes/+/244192
Reviewed-by: Taylor Cramer <cramertj@google.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
diff --git a/recipes/static_checks.expected/do-not-submit.dry.json b/recipes/static_checks.expected/do-not-submit.dry.json
index a612234..48d7dd8 100644
--- a/recipes/static_checks.expected/do-not-submit.dry.json
+++ b/recipes/static_checks.expected/do-not-submit.dry.json
@@ -268,6 +268,45 @@
"name": "check dns"
},
{
+ "cmd": [
+ "[START_DIR]/cipd_tool/infra/tools/luci/gerrit/0e548aa33f8113a45a5b3b62201e114e98e63d00f97296912380138f44597b07/gerrit",
+ "wip",
+ "-host",
+ "https://chromium-review.googlesource.com",
+ "-input",
+ "{\"change_id\": \"1234\", \"input\": {}}",
+ "-output",
+ "/path/to/tmp/json"
+ ],
+ "infra_step": true,
+ "luci_context": {
+ "realm": {
+ "name": "project:try"
+ },
+ "resultdb": {
+ "current_invocation": {
+ "name": "invocations/build:8945511751514863184",
+ "update_token": "token"
+ },
+ "hostname": "rdbhost"
+ }
+ },
+ "name": "check dns.wip",
+ "timeout": 600,
+ "~followup_annotations": [
+ "@@@STEP_NEST_LEVEL@1@@@",
+ "@@@STEP_LOG_END@json.output (invalid)@@@",
+ "@@@STEP_LOG_LINE@json.output (exception)@No JSON object could be decoded@@@",
+ "@@@STEP_LOG_END@json.output (exception)@@@",
+ "@@@STEP_LOG_LINE@json.input@{@@@",
+ "@@@STEP_LOG_LINE@json.input@ \"change_id\": \"1234\",@@@",
+ "@@@STEP_LOG_LINE@json.input@ \"input\": {}@@@",
+ "@@@STEP_LOG_LINE@json.input@}@@@",
+ "@@@STEP_LOG_END@json.input@@@",
+ "@@@STEP_LINK@gerrit link@https://chromium-review.googlesource.com/q/1234@@@"
+ ]
+ },
+ {
"name": "$result"
}
]
\ No newline at end of file
diff --git a/recipes/static_checks.py b/recipes/static_checks.py
index ee820ed..f872fcc 100644
--- a/recipes/static_checks.py
+++ b/recipes/static_checks.py
@@ -122,12 +122,13 @@
@nest_step
-def _check_dns(api, details):
+def _check_dns(api, details, *, dry_run):
"""Check that the commit message doesn't contain "do not submit"."""
regexes = [
re.compile(r'do.not.(submit|com+it|merge)', re.IGNORECASE),
re.compile(r'\bWIP\b', re.IGNORECASE),
+ re.compile(r'\bwork.in.progres+\b', re.IGNORECASE),
]
match: re.Pattern | None = None
@@ -137,11 +138,20 @@
else:
return
+ # We only get here if the current change has matched "work in progress",
+ # "do not commit", or similar.
+
if api.cv.run_mode == api.cv.FULL_RUN:
raise api.step.StepFailure(
f'found "{match.group(0)}" in commit message'
)
+ if not details.get('work_in_progress', False):
+ if dry_run: # pragma: no cover
+ api.step.empty('would mark change as wip, but in dry run')
+ else:
+ api.gerrit.wip('wip', details['_number'])
+
@nest_step
def _check_tested(api, details):
@@ -249,7 +259,7 @@
str(props.commit_message_regexp_failure_message),
)
- _check_dns(api, details)
+ _check_dns(api, details, dry_run=props.dry_run)
for readability in props.readability:
_check_readability(api, details, comments, readability)