Skip to content

Enabled git version benchmark builds/runs #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "redis-benchmarks-specification"
version = "0.1.15"
version = "0.1.16"
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."
authors = ["filipecosta90 <filipecosta.90@gmail.com>","Redis Performance Group <performance@redis.com>"]
readme = "Readme.md"
Expand All @@ -22,6 +22,8 @@ tox-docker = "^3.0.0"
PyGithub = "^1.55"
GitPython = "^3.1.20"
redistimeseries = "1.4.3"
semver = "^2.13.0"
node-semver = "^0.8.1"

[tool.poetry.dev-dependencies]
black = "20.8b1"
Expand Down
5 changes: 5 additions & 0 deletions redis_benchmarks_specification/__builder__/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,13 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
)
buffer = conn.get(binary_zip_key)
git_branch = None
git_version = None
if b"git_branch" in testDetails:
git_branch = testDetails[b"git_branch"]
if b"ref_label" in testDetails:
git_branch = testDetails[b"ref_label"]
if b"git_version" in testDetails:
git_version = testDetails[b"git_version"]
git_timestamp_ms = None
use_git_timestamp = False
if b"use_git_timestamp" in testDetails:
Expand Down Expand Up @@ -279,6 +282,8 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
}
if git_branch is not None:
build_stream_fields["git_branch"] = git_branch
if git_version is not None:
build_stream_fields["git_version"] = git_version
if git_timestamp_ms is not None:
build_stream_fields["git_timestamp_ms"] = git_timestamp_ms
for artifact in build_artifacts:
Expand Down
91 changes: 74 additions & 17 deletions redis_benchmarks_specification/__cli__/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import subprocess
import tempfile
import git
import packaging
import redis
from packaging import version

# logging settings
from redisbench_admin.cli import populate_with_poetry_data
Expand Down Expand Up @@ -65,7 +67,24 @@ def main():
)
parser.add_argument("--redis_repo", type=str, default=None)
parser.add_argument("--trigger-unstable-commits", type=bool, default=True)
parser.add_argument("--dry-run", type=bool, default=False)
parser.add_argument(
"--use-tags",
default=False,
action="store_true",
help="Iterate over the git tags.",
)
parser.add_argument(
"--use-commits",
default=False,
action="store_true",
help="Iterate over the git commits.",
)
parser.add_argument(
"--dry-run",
default=False,
action="store_true",
help="Only check how many benchmarks we would trigger. Don't request benchmark runs at the end.",
)
args = parser.parse_args()
redisDirPath = args.redis_repo
cleanUp = False
Expand Down Expand Up @@ -96,19 +115,57 @@ def main():
)
)
repo = git.Repo(redisDirPath)
Commits = []
for commit in repo.iter_commits():
if (
args.from_date
<= datetime.datetime.utcfromtimestamp(commit.committed_datetime.timestamp())
<= args.to_date
):
print(commit.summary)
Commits.append(commit)

commits = []
if args.use_commits:
for commit in repo.iter_commits():
if (
args.from_date
<= datetime.datetime.utcfromtimestamp(
commit.committed_datetime.timestamp()
)
<= args.to_date
):
print(commit.summary)
commits.append({"git_hash": commit.hexsha, "git_branch": args.branch})
if args.use_tags:
tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime)
for tag in tags:
if (
args.from_date
<= datetime.datetime.utcfromtimestamp(
tag.commit.committed_datetime.timestamp()
)
<= args.to_date
):

try:
version.Version(tag.name)
git_version = tag.name
print(
"Commit summary: {}. Extract semver: {}".format(
tag.commit.summary, git_version
)
)
# head = repo.lookup_reference(tag.commit).resolve()
commits.append(
{"git_hash": tag.commit.hexsha, "git_version": git_version}
)
except packaging.version.InvalidVersion:
logging.info(
"Ignoring tag {} given we were not able to extract commit or version info from it.".format(
tag.name
)
)
pass

by_description = "n/a"
if args.use_commits:
by_description = "from branch {}".format(args.branch)
if args.use_tags:
by_description = "by tags"
logging.info(
"Will trigger {} distinct {} branch commit tests.".format(
len(Commits), args.branch
)
"Will trigger {} distinct tests {}.".format(len(commits), by_description)
)

if args.dry_run is False:
Expand All @@ -120,7 +177,7 @@ def main():
decode_responses=False,
)
for rep in range(0, 1):
for commit in Commits:
for cdict in commits:
(
result,
error_msg,
Expand All @@ -129,16 +186,16 @@ def main():
binary_key,
binary_value,
) = get_commit_dict_from_sha(
commit.hexsha, "redis", "redis", {}, True, args.gh_token
cdict["git_hash"], "redis", "redis", cdict, True, args.gh_token
)
binary_exp_secs = 24 * 7 * 60 * 60
if result is True:
result, reply_fields, error_msg = request_build_from_commit_info(
conn, commit_dict, {}, binary_key, binary_value, binary_exp_secs
)
logging.info(
"Successfully requested a build for commit: {}. Request stream id: {}. Commit summary: {}".format(
commit.hexsha, reply_fields["id"], commit.summary
"Successfully requested a build for commit: {}. Request stream id: {}.".format(
cdict["git_hash"], reply_fields["id"]
)
)
else:
Expand Down