Skip to content

Commit 9f151b7

Browse files
Added PR comment about build start.
1 parent f30f0b7 commit 9f151b7

File tree

4 files changed

+108
-19
lines changed

4 files changed

+108
-19
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "redis-benchmarks-specification"
3-
version = "0.1.87"
3+
version = "0.1.89"
44
description = "The Redis benchmarks specification describes the cross-language/tools requirements and expectations to foster performance and observability standards around redis related technologies. Members from both industry and academia, including organizations and individuals are encouraged to contribute."
55
authors = ["filipecosta90 <[email protected]>","Redis Performance Group <[email protected]>"]
66
readme = "Readme.md"

redis_benchmarks_specification/__builder__/builder.py

Lines changed: 56 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import argparse
2+
import datetime
23
import io
34
import json
45
import logging
@@ -36,6 +37,7 @@
3637
generate_build_finished_pr_comment,
3738
update_comment_if_needed,
3839
create_new_pr_comment,
40+
generate_build_started_pr_comment,
3941
)
4042
from redis_benchmarks_specification.__common__.package import (
4143
populate_with_poetry_data,
@@ -378,9 +380,41 @@ def builder_process_stream(
378380
"redis-server",
379381
build_vars_str,
380382
)
383+
build_start_datetime = datetime.datetime.utcnow()
381384
logging.info(
382-
"Using the following build command {}".format(build_command)
385+
"Using the following build command {}.".format(build_command)
383386
)
387+
if is_actionable_pr:
388+
logging.info(
389+
f"updating on github we'll start the build at {build_start_datetime}"
390+
)
391+
comment_body = generate_build_started_pr_comment(
392+
build_start_datetime,
393+
commit_datetime,
394+
commit_summary,
395+
git_branch,
396+
git_hash,
397+
tests_groups_regexp,
398+
tests_priority_lower_limit,
399+
tests_priority_upper_limit,
400+
tests_regexp,
401+
)
402+
if contains_regression_comment:
403+
update_comment_if_needed(
404+
auto_approve_github_comments,
405+
comment_body,
406+
old_regression_comment_body,
407+
regression_comment,
408+
verbose,
409+
)
410+
else:
411+
regression_comment = create_new_pr_comment(
412+
auto_approve_github_comments,
413+
comment_body,
414+
github_pr,
415+
pr_link,
416+
)
417+
384418
docker_client.containers.run(
385419
image=build_image,
386420
volumes={
@@ -391,6 +425,10 @@ def builder_process_stream(
391425
working_dir="/mnt/redis/",
392426
command=build_command,
393427
)
428+
build_end_datetime = datetime.datetime.utcnow()
429+
build_duration = build_end_datetime - build_start_datetime
430+
build_duration_secs = build_duration.total_seconds()
431+
394432
build_stream_fields = {
395433
"id": id,
396434
"git_hash": git_hash,
@@ -416,9 +454,6 @@ def builder_process_stream(
416454
build_stream_fields["git_branch"] = git_branch
417455
if git_version is not None:
418456
build_stream_fields["git_version"] = git_version
419-
if git_timestamp_ms is not None:
420-
build_stream_fields["git_timestamp_ms"] = git_timestamp_ms
421-
422457
if git_timestamp_ms is not None:
423458
build_stream_fields["git_timestamp_ms"] = git_timestamp_ms
424459
for artifact in build_artifacts:
@@ -456,18 +491,24 @@ def builder_process_stream(
456491
f"Adding information of build->benchmark stream info in list {builder_list_completed}. Adding benchmark stream id: {benchmark_stream_id_decoded}"
457492
)
458493
benchmark_stream_ids = [benchmark_stream_id_decoded]
459-
comment_body = generate_build_finished_pr_comment(
460-
benchmark_stream_ids,
461-
commit_datetime,
462-
commit_summary,
463-
git_branch,
464-
git_hash,
465-
tests_groups_regexp,
466-
tests_priority_lower_limit,
467-
tests_priority_upper_limit,
468-
tests_regexp,
469-
)
494+
470495
if is_actionable_pr:
496+
logging.info(
497+
f"updating on github that the build finished after {build_duration_secs} seconds"
498+
)
499+
comment_body = generate_build_finished_pr_comment(
500+
benchmark_stream_ids,
501+
commit_datetime,
502+
commit_summary,
503+
git_branch,
504+
git_hash,
505+
tests_groups_regexp,
506+
tests_priority_lower_limit,
507+
tests_priority_upper_limit,
508+
tests_regexp,
509+
build_start_datetime,
510+
build_duration_secs,
511+
)
471512
if contains_regression_comment:
472513
update_comment_if_needed(
473514
auto_approve_github_comments,

redis_benchmarks_specification/__cli__/cli.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ def trigger_tests_cli_command_logic(args, project_name, project_version):
351351
)
352352

353353
if args.wait_build is True:
354+
build_start_datetime = datetime.datetime.utcnow()
354355
decoded_stream_id = stream_id.decode()
355356
builder_list_streams = (
356357
f"builder:{decoded_stream_id}:builds_completed"
@@ -409,6 +410,9 @@ def trigger_tests_cli_command_logic(args, project_name, project_version):
409410
logging.info(
410411
f"FINAL total of {len_list} already build benchmark stream ids for this build: {benchmark_stream_ids}"
411412
)
413+
build_end_datetime = datetime.datetime.utcnow()
414+
build_duration = build_end_datetime - build_start_datetime
415+
build_duration_secs = build_duration.total_seconds()
412416

413417
comment_body = generate_build_finished_pr_comment(
414418
benchmark_stream_ids,
@@ -420,6 +424,8 @@ def trigger_tests_cli_command_logic(args, project_name, project_version):
420424
tests_priority_lower_limit,
421425
tests_priority_upper_limit,
422426
tests_regexp,
427+
build_start_datetime,
428+
build_duration_secs,
423429
)
424430
if is_actionable_pr:
425431
if contains_regression_comment:

redis_benchmarks_specification/__common__/github.py

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,41 @@
22
from github import Github
33

44

5+
def generate_build_started_pr_comment(
6+
build_datetime,
7+
commit_datetime,
8+
commit_summary,
9+
git_branch,
10+
git_hash,
11+
tests_groups_regexp,
12+
tests_priority_lower_limit,
13+
tests_priority_upper_limit,
14+
tests_regexp,
15+
):
16+
comment_body = (
17+
f"### CE Performance Automation : step 1 of 2 (build) STARTING...\n\n"
18+
)
19+
comment_body += (
20+
"This comment was automatically generated given a benchmark was triggered.\n"
21+
)
22+
comment_body += f"Started building at {build_datetime}\n"
23+
comment_body += "You can check each build/benchmark progress in grafana:\n"
24+
comment_body += f" - git hash: {git_hash}\n"
25+
comment_body += f" - git branch: {git_branch}\n"
26+
comment_body += f" - commit date and time: {commit_datetime}\n"
27+
comment_body += f" - commit summary: {commit_summary}\n"
28+
comment_body += f" - test filters:\n"
29+
comment_body += (
30+
f" - command priority lower limit: {tests_priority_lower_limit}\n"
31+
)
32+
comment_body += (
33+
f" - command priority upper limit: {tests_priority_upper_limit}\n"
34+
)
35+
comment_body += f" - test name regex: {tests_regexp}\n"
36+
comment_body += f" - command group regex: {tests_groups_regexp}\n\n"
37+
return comment_body
38+
39+
540
def generate_build_finished_pr_comment(
641
benchmark_stream_ids,
742
commit_datetime,
@@ -12,11 +47,15 @@ def generate_build_finished_pr_comment(
1247
tests_priority_lower_limit,
1348
tests_priority_upper_limit,
1449
tests_regexp,
50+
build_start_datetime,
51+
build_duration_seconds,
1552
):
16-
comment_body = "### CE Performance Automation : step 1 of 2 (build) done\n\n"
53+
build_duration_seconds = int(build_duration_seconds)
54+
comment_body = f"### CE Performance Automation : step 1 of 2 (build) DONE.\n\n"
1755
comment_body += (
1856
"This comment was automatically generated given a benchmark was triggered.\n"
1957
)
58+
comment_body += f"Started building at {build_start_datetime} and took {build_duration_seconds} seconds.\n"
2059
comment_body += "You can check each build/benchmark progress in grafana:\n"
2160
comment_body += f" - git hash: {git_hash}\n"
2261
comment_body += f" - git branch: {git_branch}\n"
@@ -80,6 +119,9 @@ def check_github_available_and_actionable(
80119
print("".join(["-" for x in range(1, 80)]))
81120
else:
82121
logging.info("Does not contain PR comment")
122+
logging.info(
123+
f"contains_regression_comment: {contains_regression_comment}, is_actionable_pr: {is_actionable_pr}, pr_link: {pr_link}"
124+
)
83125
return (
84126
contains_regression_comment,
85127
github_pr,
@@ -112,12 +154,12 @@ def update_comment_if_needed(
112154
user_input = "n"
113155
if comment_body == old_regression_comment_body:
114156
logging.info(
115-
"The old regression comment is the same as the new comment. skipping..."
157+
"The old github comment is the same as the new comment. skipping..."
116158
)
117159
same_comment = True
118160
else:
119161
logging.info(
120-
"The old regression comment is different from the new comment. updating it..."
162+
"The old github comment is different from the new comment. updating it..."
121163
)
122164
comment_body_arr = comment_body.split("\n")
123165
old_regression_comment_body_arr = old_regression_comment_body.split("\n")

0 commit comments

Comments
 (0)