Skip to content

Commit d91759d

Browse files
committed
cleanup
1 parent 64d8e93 commit d91759d

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

.evergreen/scripts/generate_config.py

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
from shrub.v3.evg_task import EvgTaskRef
1919
from shrub.v3.shrub_service import ShrubService
2020

21-
# Top level variables.
21+
##############
22+
# Globals
23+
##############
24+
2225
ALL_VERSIONS = ["4.0", "4.4", "5.0", "6.0", "7.0", "8.0", "rapid", "latest"]
2326
CPYTHONS = ["3.9", "3.10", "3.11", "3.12", "3.13"]
2427
PYPYS = ["pypy3.9", "pypy3.10"]
@@ -39,24 +42,31 @@ class Host:
3942
HOSTS["macos"] = Host("macos", "macos-14", "macOS")
4043

4144

42-
# Helper functions.
45+
##############
46+
# Helpers
47+
##############
48+
49+
4350
def create_variant(
4451
task_names: list[str],
4552
display_name: str,
4653
*,
4754
python: str | None = None,
55+
version: str | None = None,
4856
host: str | None = None,
4957
**kwargs: Any,
5058
) -> BuildVariant:
5159
"""Create a build variant for the given inputs."""
5260
task_refs = [EvgTaskRef(name=n) for n in task_names]
5361
kwargs.setdefault("expansions", dict())
54-
expansions = kwargs.pop("expansions")
62+
expansions = kwargs.pop("expansions", dict()).copy()
5563
host = host or "rhel8"
5664
run_on = [HOSTS[host].run_on]
5765
name = display_name.replace(" ", "-").lower()
5866
if python:
5967
expansions["PYTHON_BINARY"] = get_python_binary(python, host)
68+
if version:
69+
expansions["VERSION"] = version
6070
expansions = expansions or None
6171
return BuildVariant(
6272
name=name,
@@ -106,27 +116,25 @@ def zip_cycle(*iterables, empty_default=None):
106116

107117

108118
##############
109-
# OCSP
119+
# Variants
110120
##############
111121

112122

113-
# Create OCSP build variants.
114123
def create_ocsp_variants() -> list[BuildVariant]:
115124
variants = []
116125
batchtime = BATCHTIME_WEEK * 2
117-
base_expansions = dict(AUTH="noauth", SSL="ssl", TOPOLOGY="server")
126+
expansions = dict(AUTH="noauth", SSL="ssl", TOPOLOGY="server")
118127
base_display = "OCSP test"
119128

120-
# OCSP tests on rhel8 with all server v4.4+ and python versions.
129+
# OCSP tests on rhel8 with all server v4.4+ and all python versions.
121130
versions = [v for v in ALL_VERSIONS if v != "4.0"]
122131
for version, python in zip_cycle(versions, ALL_PYTHONS):
123-
expansions = base_expansions.copy()
124-
expansions["VERSION"] = version
125132
host = "rhel8"
126133
variant = create_variant(
127134
[".ocsp"],
128135
get_display_name(base_display, host, version, python),
129136
python=python,
137+
version=version,
130138
batchtime=batchtime,
131139
host=host,
132140
expansions=expansions,
@@ -136,16 +144,10 @@ def create_ocsp_variants() -> list[BuildVariant]:
136144
# OCSP tests on Windows and MacOS.
137145
# MongoDB servers on these hosts do not staple OCSP responses and only support RSA.
138146
for host, version in product(["win64", "macos"], ["4.4", "8.0"]):
139-
expansions = base_expansions.copy()
140-
expansions["VERSION"] = version
141-
if version == "4.4":
142-
python = CPYTHONS[0]
143-
else:
144-
python = CPYTHONS[-1]
145147
variant = create_variant(
146148
[".ocsp-rsa !.ocsp-staple"],
147149
get_display_name(base_display, host, version, python),
148-
python=python,
150+
python=CPYTHONS[0] if version == "4.4" else CPYTHONS[-1],
149151
host=host,
150152
expansions=expansions,
151153
batchtime=batchtime,
@@ -155,6 +157,9 @@ def create_ocsp_variants() -> list[BuildVariant]:
155157
return variants
156158

157159

158-
# Generate OCSP config.
160+
##################
161+
# Generate Config
162+
##################
163+
159164
project = EvgProject(tasks=None, buildvariants=create_ocsp_variants())
160165
print(ShrubService.generate_yaml(project)) # noqa: T201

0 commit comments

Comments
 (0)