Skip to content

Commit b512737

Browse files
Add EVG Earthly tasks
1 parent a430b76 commit b512737

File tree

3 files changed

+106
-0
lines changed

3 files changed

+106
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
from shrub.v3.evg_build_variant import BuildVariant
2+
from shrub.v3.evg_task import EvgTaskRef
3+
from ..etc.utils import Task
4+
from shrub.v3.evg_command import subprocess_exec, EvgCommandType
5+
6+
_ENV_PARAM_NAME = "MONGOC_EARTHLY_ENV"
7+
8+
9+
class EarthlyTask(Task):
10+
def __init__(self, *, suffix: str, target: str) -> None:
11+
super().__init__(
12+
name=f"earthly-{suffix}",
13+
commands=[
14+
subprocess_exec(
15+
"bash",
16+
args=[
17+
"tools/earthly.sh",
18+
f"+{target}",
19+
f"--env=${{{_ENV_PARAM_NAME}}}",
20+
],
21+
working_dir="mongoc",
22+
command_type=EvgCommandType.TEST,
23+
)
24+
],
25+
tags=[f"earthly", "pr-merge-gate"],
26+
run_on=CONTAINER_RUN_DISTROS,
27+
)
28+
29+
30+
#: A mapping from environment keys to the environment name.
31+
#: These correspond to special "*-env" targets in the Earthfile.
32+
ENVS = {
33+
"u22": "Ubuntu 22.04",
34+
"alpine3.18": "Alpine 3.18",
35+
"archlinux": "Arch Linux",
36+
}
37+
38+
CONTAINER_RUN_DISTROS = [
39+
"ubuntu2204-small",
40+
"ubuntu2204-large",
41+
"ubuntu2004-small",
42+
"ubuntu2004",
43+
"ubuntu1804",
44+
"ubuntu1804-medium",
45+
"debian10",
46+
"debian11",
47+
"amazon2",
48+
]
49+
50+
51+
def tasks() -> list[Task]:
52+
return [EarthlyTask(suffix="build-and-test", target="test-example")]
53+
54+
55+
def variants() -> list[BuildVariant]:
56+
return [
57+
BuildVariant(
58+
name=f"earthly-{env_key}",
59+
tasks=[EvgTaskRef(name=".earthly")],
60+
display_name=env_name,
61+
expansions={
62+
_ENV_PARAM_NAME: env_key,
63+
},
64+
)
65+
for env_key, env_name in ENVS.items()
66+
]

.evergreen/generated_configs/tasks.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1961,6 +1961,28 @@ tasks:
19611961
- func: bootstrap-mongo-orchestration
19621962
- func: run-mock-kms-servers
19631963
- func: run-tests
1964+
- name: earthly-build-and-test
1965+
run_on:
1966+
- ubuntu2204-small
1967+
- ubuntu2204-large
1968+
- ubuntu2004-small
1969+
- ubuntu2004
1970+
- ubuntu1804
1971+
- ubuntu1804-medium
1972+
- debian10
1973+
- debian11
1974+
- amazon2
1975+
tags: [earthly, pr-merge-gate]
1976+
commands:
1977+
- command: subprocess.exec
1978+
type: test
1979+
params:
1980+
binary: bash
1981+
working_dir: mongoc
1982+
args:
1983+
- tools/earthly.sh
1984+
- +test-example
1985+
- --env=${MONGOC_EARTHLY_ENV}
19641986
- name: kms-divergence-check
19651987
commands:
19661988
- func: kms-divergence-check

.evergreen/generated_configs/variants.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,24 @@ buildvariants:
2020
DEBUG: "ON"
2121
tasks:
2222
- name: .cse-matrix-winssl
23+
- name: earthly-alpine3.18
24+
display_name: Alpine 3.18
25+
expansions:
26+
MONGOC_EARTHLY_ENV: alpine3.18
27+
tasks:
28+
- name: .earthly
29+
- name: earthly-archlinux
30+
display_name: Arch Linux
31+
expansions:
32+
MONGOC_EARTHLY_ENV: archlinux
33+
tasks:
34+
- name: .earthly
35+
- name: earthly-u22
36+
display_name: Ubuntu 22.04
37+
expansions:
38+
MONGOC_EARTHLY_ENV: u22
39+
tasks:
40+
- name: .earthly
2341
- name: mock-server-test
2442
display_name: Mock Server Test
2543
expansions:

0 commit comments

Comments
 (0)