Skip to content

Commit a11d4a8

Browse files
[add] Enabled git version benchmark builds/runs (#54)
1 parent 0a885b5 commit a11d4a8

File tree

4 files changed

+110
-19
lines changed

4 files changed

+110
-19
lines changed

poetry.lock

Lines changed: 28 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 3 additions & 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.15"
3+
version = "0.1.16"
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"
@@ -22,6 +22,8 @@ tox-docker = "^3.0.0"
2222
PyGithub = "^1.55"
2323
GitPython = "^3.1.20"
2424
redistimeseries = "1.4.3"
25+
semver = "^2.13.0"
26+
node-semver = "^0.8.1"
2527

2628
[tool.poetry.dev-dependencies]
2729
black = "20.8b1"

redis_benchmarks_specification/__builder__/builder.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,13 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
186186
)
187187
buffer = conn.get(binary_zip_key)
188188
git_branch = None
189+
git_version = None
189190
if b"git_branch" in testDetails:
190191
git_branch = testDetails[b"git_branch"]
191192
if b"ref_label" in testDetails:
192193
git_branch = testDetails[b"ref_label"]
194+
if b"git_version" in testDetails:
195+
git_version = testDetails[b"git_version"]
193196
git_timestamp_ms = None
194197
use_git_timestamp = False
195198
if b"use_git_timestamp" in testDetails:
@@ -279,6 +282,8 @@ def builder_process_stream(builders_folder, conn, different_build_specs, previou
279282
}
280283
if git_branch is not None:
281284
build_stream_fields["git_branch"] = git_branch
285+
if git_version is not None:
286+
build_stream_fields["git_version"] = git_version
282287
if git_timestamp_ms is not None:
283288
build_stream_fields["git_timestamp_ms"] = git_timestamp_ms
284289
for artifact in build_artifacts:

redis_benchmarks_specification/__cli__/cli.py

Lines changed: 74 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
import subprocess
1212
import tempfile
1313
import git
14+
import packaging
1415
import redis
16+
from packaging import version
1517

1618
# logging settings
1719
from redisbench_admin.cli import populate_with_poetry_data
@@ -65,7 +67,24 @@ def main():
6567
)
6668
parser.add_argument("--redis_repo", type=str, default=None)
6769
parser.add_argument("--trigger-unstable-commits", type=bool, default=True)
68-
parser.add_argument("--dry-run", type=bool, default=False)
70+
parser.add_argument(
71+
"--use-tags",
72+
default=False,
73+
action="store_true",
74+
help="Iterate over the git tags.",
75+
)
76+
parser.add_argument(
77+
"--use-commits",
78+
default=False,
79+
action="store_true",
80+
help="Iterate over the git commits.",
81+
)
82+
parser.add_argument(
83+
"--dry-run",
84+
default=False,
85+
action="store_true",
86+
help="Only check how many benchmarks we would trigger. Don't request benchmark runs at the end.",
87+
)
6988
args = parser.parse_args()
7089
redisDirPath = args.redis_repo
7190
cleanUp = False
@@ -96,19 +115,57 @@ def main():
96115
)
97116
)
98117
repo = git.Repo(redisDirPath)
99-
Commits = []
100-
for commit in repo.iter_commits():
101-
if (
102-
args.from_date
103-
<= datetime.datetime.utcfromtimestamp(commit.committed_datetime.timestamp())
104-
<= args.to_date
105-
):
106-
print(commit.summary)
107-
Commits.append(commit)
118+
119+
commits = []
120+
if args.use_commits:
121+
for commit in repo.iter_commits():
122+
if (
123+
args.from_date
124+
<= datetime.datetime.utcfromtimestamp(
125+
commit.committed_datetime.timestamp()
126+
)
127+
<= args.to_date
128+
):
129+
print(commit.summary)
130+
commits.append({"git_hash": commit.hexsha, "git_branch": args.branch})
131+
if args.use_tags:
132+
tags = sorted(repo.tags, key=lambda t: t.commit.committed_datetime)
133+
for tag in tags:
134+
if (
135+
args.from_date
136+
<= datetime.datetime.utcfromtimestamp(
137+
tag.commit.committed_datetime.timestamp()
138+
)
139+
<= args.to_date
140+
):
141+
142+
try:
143+
version.Version(tag.name)
144+
git_version = tag.name
145+
print(
146+
"Commit summary: {}. Extract semver: {}".format(
147+
tag.commit.summary, git_version
148+
)
149+
)
150+
# head = repo.lookup_reference(tag.commit).resolve()
151+
commits.append(
152+
{"git_hash": tag.commit.hexsha, "git_version": git_version}
153+
)
154+
except packaging.version.InvalidVersion:
155+
logging.info(
156+
"Ignoring tag {} given we were not able to extract commit or version info from it.".format(
157+
tag.name
158+
)
159+
)
160+
pass
161+
162+
by_description = "n/a"
163+
if args.use_commits:
164+
by_description = "from branch {}".format(args.branch)
165+
if args.use_tags:
166+
by_description = "by tags"
108167
logging.info(
109-
"Will trigger {} distinct {} branch commit tests.".format(
110-
len(Commits), args.branch
111-
)
168+
"Will trigger {} distinct tests {}.".format(len(commits), by_description)
112169
)
113170

114171
if args.dry_run is False:
@@ -120,7 +177,7 @@ def main():
120177
decode_responses=False,
121178
)
122179
for rep in range(0, 1):
123-
for commit in Commits:
180+
for cdict in commits:
124181
(
125182
result,
126183
error_msg,
@@ -129,16 +186,16 @@ def main():
129186
binary_key,
130187
binary_value,
131188
) = get_commit_dict_from_sha(
132-
commit.hexsha, "redis", "redis", {}, True, args.gh_token
189+
cdict["git_hash"], "redis", "redis", cdict, True, args.gh_token
133190
)
134191
binary_exp_secs = 24 * 7 * 60 * 60
135192
if result is True:
136193
result, reply_fields, error_msg = request_build_from_commit_info(
137194
conn, commit_dict, {}, binary_key, binary_value, binary_exp_secs
138195
)
139196
logging.info(
140-
"Successfully requested a build for commit: {}. Request stream id: {}. Commit summary: {}".format(
141-
commit.hexsha, reply_fields["id"], commit.summary
197+
"Successfully requested a build for commit: {}. Request stream id: {}.".format(
198+
cdict["git_hash"], reply_fields["id"]
142199
)
143200
)
144201
else:

0 commit comments

Comments
 (0)