Skip to content

Commit 0d5145e

Browse files
Clean up Earthly task generation, add missing tasks (#1906)
A recent change in task definitions caused the sasl=off tasks to be fully excluded from the Earthly task matrix. This was also caught by pylance/pyright in the earthly.py file when it detects unreachable branches. This small changeset re-enables those tasks and makes earthly.py warning-free.
1 parent db338a0 commit 0d5145e

File tree

2 files changed

+217
-29
lines changed

2 files changed

+217
-29
lines changed

.evergreen/config_generator/components/earthly.py

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"alpine3.18",
2828
"alpine3.19",
2929
"archlinux",
30-
"centos7"
30+
"centos7",
3131
]
3232
"Identifiers for environments. These correspond to special 'env.*' targets in the Earthfile."
3333
CompilerName = Literal["gcc", "clang"]
@@ -42,7 +42,7 @@
4242
"C++ driver refs that are under CI test"
4343

4444
# A separator character, since we cannot use whitespace
45-
_SEPARATOR = "\N{no-break space}\N{bullet}\N{no-break space}"
45+
_SEPARATOR = "\N{NO-BREAK SPACE}\N{BULLET}\N{NO-BREAK SPACE}"
4646

4747

4848
def os_split(env: EnvKey) -> tuple[str, None | str]:
@@ -59,9 +59,7 @@ def os_split(env: EnvKey) -> tuple[str, None | str]:
5959
case "centos7":
6060
return "CentOS", "7.0"
6161
case _:
62-
raise ValueError(
63-
f"Failed to split OS env key {env=} into a name+version pair (unrecognized)"
64-
)
62+
raise ValueError(f"Failed to split OS env key {env=} into a name+version pair (unrecognized)")
6563

6664

6765
class EarthlyVariant(NamedTuple):
@@ -135,7 +133,7 @@ class Configuration(NamedTuple):
135133

136134
@property
137135
def suffix(self) -> str:
138-
return f"{_SEPARATOR}".join(f"{k}={v}" for k, v in self._asdict().items())
136+
return _SEPARATOR.join(f"{k}={v}" for k, v in self._asdict().items())
139137

140138

141139
def task_filter(env: EarthlyVariant, conf: Configuration) -> bool:
@@ -144,26 +142,16 @@ def task_filter(env: EarthlyVariant, conf: Configuration) -> bool:
144142
configuration values.
145143
"""
146144
match env, conf:
147-
# We only need one task with "sasl=off"
148-
case ["u22", "gcc"], ("off", "OpenSSL", "r3.8.0"):
149-
return True
150-
# The Ubuntu 18.04 GCC has a bug that fails to build the 3.8.0 C++ driver
151-
case ["u18", "gcc"], [_, _, "r3.8.0"]:
152-
return False
153-
# Other sasl=off tasks we'll just ignore:
154-
case _, ("off", _tls, _cxx):
155-
return False
156145
# Ubuntu and CentOS do not ship with a LibreSSL package:
157-
case e, (_sasl, "LibreSSL", _cxx) if e.display_name.startswith("Ubuntu") or e.display_name.startswith("CentOS"):
146+
case e, (_sasl, "LibreSSL", _cxx) if re.match(r"^Ubuntu|^CentOS", e.display_name):
158147
return False
159-
# u16 is not capable of building mongocxx
160-
case e, (_, _, "none") if e.display_name.startswith("Ubuntu 16") or e.display_name.startswith("CentOS 7"):
161-
return True
162-
# Exclude u16 for all other configurations
163-
case e, _ if e.display_name.startswith("Ubuntu 16") or e.display_name.startswith("CentOS 7"):
164-
return False
165-
# Exclude all other envs
166-
case _, (_, _, "none"):
148+
# u16/centos7 are not capable of building mongocxx
149+
case e, (_sasl, _tls, cxx) if re.match(r"^Ubuntu 16|^CentOS 7", e.display_name):
150+
# Only build if C++ driver is test is disabled
151+
return cxx == "none"
152+
# Skip other platforms where the C++ driver test is disabled, since they would be
153+
# redundant
154+
case _, (_sasl, _tls, "none"):
167155
return False
168156
# Anything else: Allow it to run:
169157
case _:
@@ -230,11 +218,11 @@ def earthly_task(
230218
commands=[
231219
# Ensure subsequent Docker commands are authenticated.
232220
subprocess_exec(
233-
binary='bash',
234-
command_type="setup",
221+
binary="bash",
222+
command_type=EvgCommandType.SETUP,
235223
args=[
236224
"-c",
237-
'docker login -u "${artifactory_username}" --password-stdin artifactory.corp.mongodb.com <<<"${artifactory_password}"'
225+
r'docker login -u "${artifactory_username}" --password-stdin artifactory.corp.mongodb.com <<<"${artifactory_password}"',
238226
],
239227
),
240228
# First, just build the "env-warmup" which will prepare the build environment.
@@ -253,8 +241,8 @@ def earthly_task(
253241
# The "targets" arg is for +run to specify which targets to run
254242
args={"targets": " ".join(targets)} | earthly_args,
255243
),
256-
],
257-
tags=[f"earthly", "pr-merge-gate", *env_tags],
244+
], # type: ignore (The type annots on `commands` is wrong)
245+
tags=["earthly", "pr-merge-gate", *env_tags],
258246
run_on=CONTAINER_RUN_DISTROS,
259247
)
260248

.evergreen/generated_configs/tasks.yml

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,206 @@ tasks:
12971297
- --test_mongocxx_ref=r3.9.0
12981298
- --env=${MONGOC_EARTHLY_ENV}
12991299
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1300+
- name: "check:sasl=off\_\u2022\_tls=LibreSSL\_\u2022\_test_mongocxx_ref=r3.9.0"
1301+
run_on:
1302+
- ubuntu2204-large
1303+
- debian10-large
1304+
- debian11-large
1305+
- amazon2
1306+
tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc]
1307+
commands:
1308+
- command: subprocess.exec
1309+
type: setup
1310+
params:
1311+
binary: bash
1312+
args:
1313+
- -c
1314+
- docker login -u "${artifactory_username}" --password-stdin artifactory.corp.mongodb.com <<<"${artifactory_password}"
1315+
- command: subprocess.exec
1316+
type: setup
1317+
params:
1318+
binary: ./tools/earthly.sh
1319+
working_dir: mongoc
1320+
args:
1321+
- +env-warmup
1322+
- --sasl=off
1323+
- --tls=LibreSSL
1324+
- --test_mongocxx_ref=r3.9.0
1325+
- --env=${MONGOC_EARTHLY_ENV}
1326+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1327+
- command: subprocess.exec
1328+
type: test
1329+
params:
1330+
binary: ./tools/earthly.sh
1331+
working_dir: mongoc
1332+
args:
1333+
- +run
1334+
- --targets=test-example test-cxx-driver
1335+
- --sasl=off
1336+
- --tls=LibreSSL
1337+
- --test_mongocxx_ref=r3.9.0
1338+
- --env=${MONGOC_EARTHLY_ENV}
1339+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1340+
- name: "check:sasl=off\_\u2022\_tls=OpenSSL\_\u2022\_test_mongocxx_ref=none"
1341+
run_on:
1342+
- ubuntu2204-large
1343+
- debian10-large
1344+
- debian11-large
1345+
- amazon2
1346+
tags: [earthly, pr-merge-gate, centos7-clang, centos7-gcc, u16-clang, u16-gcc]
1347+
commands:
1348+
- command: subprocess.exec
1349+
type: setup
1350+
params:
1351+
binary: bash
1352+
args:
1353+
- -c
1354+
- docker login -u "${artifactory_username}" --password-stdin artifactory.corp.mongodb.com <<<"${artifactory_password}"
1355+
- command: subprocess.exec
1356+
type: setup
1357+
params:
1358+
binary: ./tools/earthly.sh
1359+
working_dir: mongoc
1360+
args:
1361+
- +env-warmup
1362+
- --sasl=off
1363+
- --tls=OpenSSL
1364+
- --test_mongocxx_ref=none
1365+
- --env=${MONGOC_EARTHLY_ENV}
1366+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1367+
- command: subprocess.exec
1368+
type: test
1369+
params:
1370+
binary: ./tools/earthly.sh
1371+
working_dir: mongoc
1372+
args:
1373+
- +run
1374+
- --targets=test-example
1375+
- --sasl=off
1376+
- --tls=OpenSSL
1377+
- --test_mongocxx_ref=none
1378+
- --env=${MONGOC_EARTHLY_ENV}
1379+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1380+
- name: "check:sasl=off\_\u2022\_tls=OpenSSL\_\u2022\_test_mongocxx_ref=r3.9.0"
1381+
run_on:
1382+
- ubuntu2204-large
1383+
- debian10-large
1384+
- debian11-large
1385+
- amazon2
1386+
tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u18-clang, u18-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc]
1387+
commands:
1388+
- command: subprocess.exec
1389+
type: setup
1390+
params:
1391+
binary: bash
1392+
args:
1393+
- -c
1394+
- docker login -u "${artifactory_username}" --password-stdin artifactory.corp.mongodb.com <<<"${artifactory_password}"
1395+
- command: subprocess.exec
1396+
type: setup
1397+
params:
1398+
binary: ./tools/earthly.sh
1399+
working_dir: mongoc
1400+
args:
1401+
- +env-warmup
1402+
- --sasl=off
1403+
- --tls=OpenSSL
1404+
- --test_mongocxx_ref=r3.9.0
1405+
- --env=${MONGOC_EARTHLY_ENV}
1406+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1407+
- command: subprocess.exec
1408+
type: test
1409+
params:
1410+
binary: ./tools/earthly.sh
1411+
working_dir: mongoc
1412+
args:
1413+
- +run
1414+
- --targets=test-example test-cxx-driver
1415+
- --sasl=off
1416+
- --tls=OpenSSL
1417+
- --test_mongocxx_ref=r3.9.0
1418+
- --env=${MONGOC_EARTHLY_ENV}
1419+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1420+
- name: "check:sasl=off\_\u2022\_tls=off\_\u2022\_test_mongocxx_ref=none"
1421+
run_on:
1422+
- ubuntu2204-large
1423+
- debian10-large
1424+
- debian11-large
1425+
- amazon2
1426+
tags: [earthly, pr-merge-gate, centos7-clang, centos7-gcc, u16-clang, u16-gcc]
1427+
commands:
1428+
- command: subprocess.exec
1429+
type: setup
1430+
params:
1431+
binary: bash
1432+
args:
1433+
- -c
1434+
- docker login -u "${artifactory_username}" --password-stdin artifactory.corp.mongodb.com <<<"${artifactory_password}"
1435+
- command: subprocess.exec
1436+
type: setup
1437+
params:
1438+
binary: ./tools/earthly.sh
1439+
working_dir: mongoc
1440+
args:
1441+
- +env-warmup
1442+
- --sasl=off
1443+
- --tls=off
1444+
- --test_mongocxx_ref=none
1445+
- --env=${MONGOC_EARTHLY_ENV}
1446+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1447+
- command: subprocess.exec
1448+
type: test
1449+
params:
1450+
binary: ./tools/earthly.sh
1451+
working_dir: mongoc
1452+
args:
1453+
- +run
1454+
- --targets=test-example
1455+
- --sasl=off
1456+
- --tls=off
1457+
- --test_mongocxx_ref=none
1458+
- --env=${MONGOC_EARTHLY_ENV}
1459+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1460+
- name: "check:sasl=off\_\u2022\_tls=off\_\u2022\_test_mongocxx_ref=r3.9.0"
1461+
run_on:
1462+
- ubuntu2204-large
1463+
- debian10-large
1464+
- debian11-large
1465+
- amazon2
1466+
tags: [earthly, pr-merge-gate, alpine3.16-clang, alpine3.16-gcc, alpine3.17-clang, alpine3.17-gcc, alpine3.18-clang, alpine3.18-gcc, alpine3.19-clang, alpine3.19-gcc, archlinux-clang, archlinux-gcc, u18-clang, u18-gcc, u20-clang, u20-gcc, u22-clang, u22-gcc]
1467+
commands:
1468+
- command: subprocess.exec
1469+
type: setup
1470+
params:
1471+
binary: bash
1472+
args:
1473+
- -c
1474+
- docker login -u "${artifactory_username}" --password-stdin artifactory.corp.mongodb.com <<<"${artifactory_password}"
1475+
- command: subprocess.exec
1476+
type: setup
1477+
params:
1478+
binary: ./tools/earthly.sh
1479+
working_dir: mongoc
1480+
args:
1481+
- +env-warmup
1482+
- --sasl=off
1483+
- --tls=off
1484+
- --test_mongocxx_ref=r3.9.0
1485+
- --env=${MONGOC_EARTHLY_ENV}
1486+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
1487+
- command: subprocess.exec
1488+
type: test
1489+
params:
1490+
binary: ./tools/earthly.sh
1491+
working_dir: mongoc
1492+
args:
1493+
- +run
1494+
- --targets=test-example test-cxx-driver
1495+
- --sasl=off
1496+
- --tls=off
1497+
- --test_mongocxx_ref=r3.9.0
1498+
- --env=${MONGOC_EARTHLY_ENV}
1499+
- --c_compiler=${MONGOC_EARTHLY_C_COMPILER}
13001500
- name: clang-format
13011501
tags: [clang-format]
13021502
commands:

0 commit comments

Comments
 (0)