summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Bradford <david.bradford@mongodb.com>2021-05-11 13:26:16 -0400
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-05-12 00:38:08 +0000
commitd2da02cf6654b60948408cdcaaf9c520e8d1bc0e (patch)
tree8c11f430ec8068f5eb90a632e3ffc6558982eeeb
parent100811c3e5cc533c922e23ede0e5935eabc5da0c (diff)
downloadmongo-d2da02cf6654b60948408cdcaaf9c520e8d1bc0e.tar.gz
SERVER-56751: Add patch build task for todo comment checks
-rwxr-xr-x[-rw-r--r--]buildscripts/todo_check.py26
-rw-r--r--etc/evergreen.yml13
2 files changed, 33 insertions, 6 deletions
diff --git a/buildscripts/todo_check.py b/buildscripts/todo_check.py
index 3a2bc407d62..f21a1f31da2 100644..100755
--- a/buildscripts/todo_check.py
+++ b/buildscripts/todo_check.py
@@ -8,7 +8,9 @@ from dataclasses import dataclass
from typing import Iterable, Callable, Optional, NamedTuple, Dict, List
import click
+from evergreen import RetryingEvergreenApi
+EVG_CONFIG_FILE = "./.evergreen.yml"
BASE_SEARCH_DIR = "."
IGNORED_PATHS = [".git"]
ISSUE_RE = re.compile('(BUILD|SERVER|WT|PM|TOOLS|TIG|PERF|BF)-[0-9]+')
@@ -194,12 +196,26 @@ def walk_fs(root: str, action: Callable[[str, Iterable[str]], None]) -> None:
continue
+def get_summary_for_patch(version_id: str) -> str:
+ """
+ Get the description provided for the given patch build.
+
+ :param version_id: Version ID of the patch build to query.
+ :return: Description provided for the patch build.
+ """
+ evg_api = RetryingEvergreenApi.get_api(config_file=EVG_CONFIG_FILE)
+ return evg_api.version_by_id(version_id).message
+
+
@click.command()
@click.option("--ticket", help="Only report on TODOs associated with given Jira ticket.")
@click.option("--base-dir", default=BASE_SEARCH_DIR, help="Base directory to search in.")
@click.option("--commit-message",
help="For commit-queue execution only, ensure no TODOs for this commit")
-def main(ticket: Optional[str], base_dir: str, commit_message: Optional[str]):
+@click.option("--patch-build", type=str,
+ help="For patch build execution only, check for any TODOs from patch description")
+def main(ticket: Optional[str], base_dir: str, commit_message: Optional[str],
+ patch_build: Optional[str]):
"""
Search for and report on TODO comments in the code base.
@@ -242,12 +258,18 @@ def main(ticket: Optional[str], base_dir: str, commit_message: Optional[str]):
\f
:param ticket: Only report on TODOs associated with this jira ticket.
:param base_dir: Search files in this base directory.
- :param commit_message: Commit message if running in the commit-queue.[
+ :param commit_message: Commit message if running in the commit-queue.
+ :param patch_build: Version ID of patch build to check.
"""
if commit_message and ticket is not None:
raise click.UsageError("--ticket cannot be used in commit queue.")
+ if patch_build:
+ if ticket is not None:
+ raise click.UsageError("--ticket cannot be used in patch builds.")
+ commit_message = get_summary_for_patch(patch_build)
+
todo_checker = TodoChecker()
todo_checker.check_all_files(base_dir)
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index 022921feaef..22caadc1485 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -7799,6 +7799,7 @@ tasks:
- *f_expansions_write
- func: "set task expansion macros"
- *f_expansions_write
+ - func: "configure evergreen api credentials"
- func: "set up venv"
- command: shell.exec
type: test
@@ -7806,13 +7807,15 @@ tasks:
working_dir: src
shell: bash
script: |
+ ${activate_virtualenv}
+
set -o verbose
set -o errexit
+ # Since `commit_message` is an evergreen expansion, we need a way to ensure we
+ # properly deal with any special characters that could cause issues (like "). To
+ # do this, we will write it out to a file, then read that file into a variable.
if [ "${is_commit_queue}" = "true" ]; then
- # Since `commit_message` is an evergreen expansion, we need a way to ensure we
- # properly deal with any special characters that could cause issues (like "). To
- # do this, we will write it out to a file, then read that file into a variable.
cat > commit_message.txt <<END_OF_COMMIT_MSG
${commit_message}
END_OF_COMMIT_MSG
@@ -7820,8 +7823,9 @@ tasks:
commit_message_content=$(cat commit_message.txt)
rm commit_message.txt
- ${activate_virtualenv}
$python buildscripts/todo_check.py --commit-message "$commit_message_content"
+ else
+ $python buildscripts/todo_check.py --patch-build ${version_id}
fi
- <<: *task_template
@@ -9792,6 +9796,7 @@ buildvariants:
- name: test_api_version_compatibility
- name: burn_in_tests_gen
- name: burn_in_tests_multiversion_gen
+ - name: check_for_todos
- name: .aggfuzzer
- name: .aggregation
- name: audit