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
·146 lines (122 loc) · 3.97 KB
/
matrices.py
File metadata and controls
executable file
·146 lines (122 loc) · 3.97 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
140
141
142
143
144
145
146
#!/usr/bin/env python3
import json
import os
# A runner target
class Target:
# GHA runner
runner_label: str
# Rust target triple
target: str
# SVM Solc target
svm_target_platform: str
def __init__(self, runner_label: str, target: str, svm_target_platform: str):
self.runner_label = runner_label
self.target = target
self.svm_target_platform = svm_target_platform
# A single test suite to run.
class Case:
# Name of the test suite.
name: str
# Nextest filter expression.
filter: str
# Number of partitions to split the test suite into.
n_partitions: int
# Whether to run on non-Linux platforms for PRs. All platforms and tests are run on pushes.
pr_cross_platform: bool
def __init__(
self, name: str, filter: str, n_partitions: int, pr_cross_platform: bool
):
self.name = name
self.filter = filter
self.n_partitions = n_partitions
self.pr_cross_platform = pr_cross_platform
# GHA matrix entry
class Expanded:
name: str
runner_label: str
target: str
svm_target_platform: str
flags: str
partition: int
def __init__(
self,
name: str,
runner_label: str,
target: str,
svm_target_platform: str,
flags: str,
partition: int,
):
self.name = name
self.runner_label = runner_label
self.target = target
self.svm_target_platform = svm_target_platform
self.flags = flags
self.partition = partition
profile = os.environ.get("PROFILE")
is_pr = os.environ.get("EVENT_NAME") == "pull_request"
t_linux_x86 = Target("ubuntu-latest", "x86_64-unknown-linux-gnu", "linux-amd64")
# TODO: Figure out how to make this work
# t_linux_arm = Target("ubuntu-latest", "aarch64-unknown-linux-gnu", "linux-aarch64")
t_macos = Target("macos-latest", "aarch64-apple-darwin", "macosx-aarch64")
t_windows = Target("windows-latest", "x86_64-pc-windows-msvc", "windows-amd64")
targets = [t_linux_x86, t_windows] if is_pr else [t_linux_x86, t_macos, t_windows]
config = [
Case(
name="unit",
filter="!kind(test)",
n_partitions=1,
pr_cross_platform=True,
),
Case(
name="integration",
filter="kind(test) & !test(/\\b(issue|ext_integration)/)",
n_partitions=3,
pr_cross_platform=True,
),
Case(
name="integration / issue-repros",
filter="package(=forge) & test(/\\bissue/)",
n_partitions=2,
pr_cross_platform=False,
),
Case(
name="integration / external",
filter="package(=forge) & test(/\\bext_integration/)",
n_partitions=2,
pr_cross_platform=False,
),
]
def main():
expanded = []
for target in targets:
for case in config:
if is_pr and (not case.pr_cross_platform and target != t_linux_x86):
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}"
if profile == "isolate":
flags += " --features=isolate-by-default"
name += os_str
obj = Expanded(
name=name,
runner_label=target.runner_label,
target=target.target,
svm_target_platform=target.svm_target_platform,
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__":
main()