forked from foundry-rs/foundry
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatrices.py
More file actions
executable file
·139 lines (114 loc) · 3.38 KB
/
matrices.py
File metadata and controls
executable file
·139 lines (114 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env python3
import json
import os
class Target:
# GitHub runner OS
os_id: str
# Rust target triple
target: str
def __init__(self, os_id: str, target: str):
self.os_id = os_id
self.target = target
class Case:
name: str
filter: str
n_partitions: int
xplatform: bool
def __init__(self, name: str, filter: str, n_partitions: int, xplatform: bool):
self.name = name
self.filter = filter
self.n_partitions = n_partitions
self.xplatform = xplatform
class Expanded:
os: str
target: str
name: str
flags: str
partition: int
def __init__(self, os: str, target: str, name: str, flags: str, partition: int):
self.os = os
self.target = target
self.name = name
self.flags = flags
self.partition = partition
default_target = Target("ubuntu-latest", "x86_64-unknown-linux-gnu")
if os.environ.get("EVENT_NAME") == "pull_request":
targets = [default_target]
else:
targets = [
default_target,
Target("ubuntu-latest", "aarch64-unknown-linux-gnu"),
Target("macos-latest", "x86_64-apple-darwin"),
Target("macos-latest", "aarch64-apple-darwin"),
Target("windows-latest", "x86_64-pc-windows-msvc"),
]
config = [
Case(
name="unit",
filter="kind(lib) | kind(bench) | kind(proc-macro)",
n_partitions=1,
xplatform=True,
),
Case(
name="integration",
filter="kind(test) & !test(/issue|forge_std|ext_integration/)",
n_partitions=3,
xplatform=True,
),
Case(
name="integration/issue-repros",
filter="package(=forge) & test(~issue)",
n_partitions=2,
xplatform=False,
),
Case(
name="integration/forge-std",
filter="package(=forge) & test(~forge_std)",
n_partitions=1,
xplatform=False,
),
Case(
name="integration/external",
filter="package(=forge) & test(~ext_integration)",
n_partitions=2,
xplatform=False,
),
]
def build_matrix():
expanded = []
for target in targets:
expanded.append({"os": target.os_id, "target": target.target})
print_json({"include": expanded})
def test_matrix():
expanded = []
for target in targets:
for case in config:
if not case.xplatform and target != default_target:
continue
for partition in range(1, case.n_partitions + 1):
os_str = ""
if len(targets) > 1:
os_str = f" ({target.target})"
name = case.name
flags = f"-E '{case.filter}'"
if case.n_partitions > 1:
s = f"{partition}/{case.n_partitions}"
name += f" ({s})"
flags += f" --partition count:{s}"
name += os_str
obj = Expanded(
os=target.os_id,
target=target.target,
name=name,
flags=flags,
partition=partition,
)
expanded.append(vars(obj))
print_json({"include": expanded})
def print_json(obj):
print(json.dumps(obj), end="", flush=True)
if __name__ == "__main__":
if int(os.environ.get("TEST", "0")) == 0:
build_matrix()
else:
test_matrix()