18
18
from shrub .v3 .evg_task import EvgTaskRef
19
19
from shrub .v3 .shrub_service import ShrubService
20
20
21
- # Top level variables.
21
+ ##############
22
+ # Globals
23
+ ##############
24
+
22
25
ALL_VERSIONS = ["4.0" , "4.4" , "5.0" , "6.0" , "7.0" , "8.0" , "rapid" , "latest" ]
23
26
CPYTHONS = ["3.9" , "3.10" , "3.11" , "3.12" , "3.13" ]
24
27
PYPYS = ["pypy3.9" , "pypy3.10" ]
@@ -39,24 +42,31 @@ class Host:
39
42
HOSTS ["macos" ] = Host ("macos" , "macos-14" , "macOS" )
40
43
41
44
42
- # Helper functions.
45
+ ##############
46
+ # Helpers
47
+ ##############
48
+
49
+
43
50
def create_variant (
44
51
task_names : list [str ],
45
52
display_name : str ,
46
53
* ,
47
54
python : str | None = None ,
55
+ version : str | None = None ,
48
56
host : str | None = None ,
49
57
** kwargs : Any ,
50
58
) -> BuildVariant :
51
59
"""Create a build variant for the given inputs."""
52
60
task_refs = [EvgTaskRef (name = n ) for n in task_names ]
53
61
kwargs .setdefault ("expansions" , dict ())
54
- expansions = kwargs .pop ("expansions" )
62
+ expansions = kwargs .pop ("expansions" , dict ()). copy ( )
55
63
host = host or "rhel8"
56
64
run_on = [HOSTS [host ].run_on ]
57
65
name = display_name .replace (" " , "-" ).lower ()
58
66
if python :
59
67
expansions ["PYTHON_BINARY" ] = get_python_binary (python , host )
68
+ if version :
69
+ expansions ["VERSION" ] = version
60
70
expansions = expansions or None
61
71
return BuildVariant (
62
72
name = name ,
@@ -106,27 +116,25 @@ def zip_cycle(*iterables, empty_default=None):
106
116
107
117
108
118
##############
109
- # OCSP
119
+ # Variants
110
120
##############
111
121
112
122
113
- # Create OCSP build variants.
114
123
def create_ocsp_variants () -> list [BuildVariant ]:
115
124
variants = []
116
125
batchtime = BATCHTIME_WEEK * 2
117
- base_expansions = dict (AUTH = "noauth" , SSL = "ssl" , TOPOLOGY = "server" )
126
+ expansions = dict (AUTH = "noauth" , SSL = "ssl" , TOPOLOGY = "server" )
118
127
base_display = "OCSP test"
119
128
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.
121
130
versions = [v for v in ALL_VERSIONS if v != "4.0" ]
122
131
for version , python in zip_cycle (versions , ALL_PYTHONS ):
123
- expansions = base_expansions .copy ()
124
- expansions ["VERSION" ] = version
125
132
host = "rhel8"
126
133
variant = create_variant (
127
134
[".ocsp" ],
128
135
get_display_name (base_display , host , version , python ),
129
136
python = python ,
137
+ version = version ,
130
138
batchtime = batchtime ,
131
139
host = host ,
132
140
expansions = expansions ,
@@ -136,16 +144,10 @@ def create_ocsp_variants() -> list[BuildVariant]:
136
144
# OCSP tests on Windows and MacOS.
137
145
# MongoDB servers on these hosts do not staple OCSP responses and only support RSA.
138
146
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 ]
145
147
variant = create_variant (
146
148
[".ocsp-rsa !.ocsp-staple" ],
147
149
get_display_name (base_display , host , version , python ),
148
- python = python ,
150
+ python = CPYTHONS [ 0 ] if version == "4.4" else CPYTHONS [ - 1 ] ,
149
151
host = host ,
150
152
expansions = expansions ,
151
153
batchtime = batchtime ,
@@ -155,6 +157,9 @@ def create_ocsp_variants() -> list[BuildVariant]:
155
157
return variants
156
158
157
159
158
- # Generate OCSP config.
160
+ ##################
161
+ # Generate Config
162
+ ##################
163
+
159
164
project = EvgProject (tasks = None , buildvariants = create_ocsp_variants ())
160
165
print (ShrubService .generate_yaml (project )) # noqa: T201
0 commit comments