diff options
author | David Bradford <david.bradford@mongodb.com> | 2021-05-11 13:26:16 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-05-12 19:27:50 +0000 |
commit | 42004e2c2bf59e586a8086d7c84724bc77085d68 (patch) | |
tree | e13590367c17a6c315ffa8900579771261dad471 | |
parent | db4e97e3cc339ac406cf579a37922310db7601ee (diff) | |
download | mongo-42004e2c2bf59e586a8086d7c84724bc77085d68.tar.gz |
SERVER-56751: Add patch build task for todo comment checks
(cherry picked from commit d2da02cf6654b60948408cdcaaf9c520e8d1bc0e)
-rwxr-xr-x[-rw-r--r--] | buildscripts/todo_check.py | 26 | ||||
-rw-r--r-- | etc/evergreen.yml | 15 |
2 files changed, 35 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 61a4330b855..05b1b7da7e5 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -8256,7 +8256,10 @@ tasks: - name: check_for_todos exec_timeout_secs: 600 # 10 minute timeout commands: + - command: manifest.load + - func: "git get project" - func: "set task expansion macros" + - func: "configure evergreen api credentials" - func: "set up venv" - command: shell.exec type: test @@ -8264,13 +8267,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 @@ -8278,8 +8283,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 @@ -10072,6 +10078,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 |