Skip to content

Commit

Permalink
pw_presubmit: Allow Bazel issues in TODOs
Browse files Browse the repository at this point in the history
Changes the pw_presubmit TODO checks to allow Bazel GitHub issues.

Change-Id: Idbdc6f90cd656ec3ac3be3de95091d385a2e8b6b
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/190970
Reviewed-by: Ted Pudlik <[email protected]>
Commit-Queue: Auto-Submit <[email protected]>
Pigweed-Auto-Submit: Armando Montanez <[email protected]>
  • Loading branch information
armandomontanez authored and CQ Bot Account committed Feb 10, 2024
1 parent ca188a7 commit 69cff2d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
12 changes: 11 additions & 1 deletion pw_presubmit/py/pw_presubmit/todo_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
)

# todo-check: disable
# pylint: disable=line-too-long
BUGS_ONLY = re.compile(
r'(?:\bTODO\(b/\d+(?:, ?b/\d+)*\).*\w)|'
r'(?:\bTODO: b/\d+(?:, ?b/\d+)* - )|'
r'(?:\bTODO: https://issues.pigweed.dev/issues/\d+ - )'
r'(?:\bTODO: https://issues.pigweed.dev/issues/\d+ - )|'
r'(?:\bTODO: https://github\.com/bazelbuild/[a-z][-_a-z0-9]*/issues/\d+[ ]-[ ])'
)
BUGS_OR_USERNAMES = re.compile(
r"""
Expand Down Expand Up @@ -78,11 +80,19 @@
(?:,[ ]?(?:fxbug\.dev/\d+|[a-z]+))* # Additional usernames or bugs.
\)
.*\w # Explanation.
)|
(?: # Bazel GitHub issues. No usernames allowed.
\bTODO:[ ]
(?:
https://github\.com/bazelbuild/[a-z][-_a-z0-9]*/issues/\d+
)
[ ]-[ ].*\w # Explanation.
)
""",
re.VERBOSE,
)
_TODO = re.compile(r'\bTODO\b')
# pylint: enable=line-too-long
# todo-check: enable

# If seen, ignore this line and the next.
Expand Down
20 changes: 20 additions & 0 deletions pw_presubmit/py/todo_check_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,26 @@ def test_fuchsia_two_bugs(self) -> None:
self._run_bugs_users('TODO(fxbug.dev/123,fxbug.dev/321): bar\n')
self.ctx.fail.assert_not_called()

def test_bazel_gh_issue(self) -> None:
contents = (
'TODO: https://github.com/bazelbuild/bazel/issues/12345 - '
'Bazel sometimes works\n'
)
self._run_bugs_users(contents)
self.ctx.fail.assert_not_called()
self._run_bugs(contents)
self.ctx.fail.assert_not_called()

def test_bazel_gh_issue_underscore(self) -> None:
contents = (
'TODO: https://github.com/bazelbuild/rules_cc/issues/678910 - '
'Sometimes it does not work\n'
)
self._run_bugs_users(contents)
self.ctx.fail.assert_not_called()
self._run_bugs(contents)
self.ctx.fail.assert_not_called()


if __name__ == '__main__':
unittest.main()
Expand Down

0 comments on commit 69cff2d

Please sign in to comment.