Skip to content

Commit 7672b31

Browse files
author
kr-2003
committed
Custom lambda for launchExecutor and PID retrieval
1 parent 79849c3 commit 7672b31

File tree

13,678 files changed

+941182
-459321
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

13,678 files changed

+941182
-459321
lines changed

.ci/compute_projects.py

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
PROJECT_DEPENDENCIES = {
2020
"llvm": set(),
2121
"clang": {"llvm"},
22+
"CIR": {"clang", "mlir"},
2223
"bolt": {"clang", "lld", "llvm"},
2324
"clang-tools-extra": {"clang", "llvm"},
2425
"compiler-rt": {"clang", "lld"},
@@ -55,6 +56,7 @@
5556
".ci": {
5657
"llvm",
5758
"clang",
59+
"CIR",
5860
"lld",
5961
"lldb",
6062
"bolt",
@@ -98,6 +100,9 @@
98100
"libc", # No Windows Support.
99101
"lldb", # TODO(issues/132800): Needs environment setup.
100102
"bolt", # No Windows Support.
103+
"libcxx",
104+
"libcxxabi",
105+
"libunwind",
101106
}
102107

103108
# These are projects that we should test if the project itself is changed but
@@ -116,6 +121,9 @@
116121
"lldb",
117122
"openmp",
118123
"polly",
124+
"libcxx",
125+
"libcxxabi",
126+
"libunwind",
119127
}
120128

121129
PROJECT_CHECK_TARGETS = {
@@ -128,6 +136,7 @@
128136
"lldb": "check-lldb",
129137
"llvm": "check-llvm",
130138
"clang": "check-clang",
139+
"CIR": "check-clang-cir",
131140
"bolt": "check-bolt",
132141
"lld": "check-lld",
133142
"flang": "check-flang",
@@ -141,6 +150,23 @@
141150

142151
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
143152

153+
# Meta projects are projects that need explicit handling but do not reside
154+
# in their own top level folder. To add a meta project, the start of the path
155+
# for the metaproject should be mapped to the name of the project below.
156+
# Multiple paths can map to the same metaproject.
157+
META_PROJECTS = {
158+
("clang", "lib", "CIR"): "CIR",
159+
("clang", "test", "CIR"): "CIR",
160+
("clang", "include", "clang", "CIR"): "CIR",
161+
("*", "docs"): "docs",
162+
("llvm", "utils", "gn"): "gn",
163+
(".github", "workflows", "premerge.yaml"): ".ci",
164+
("third-party",): ".ci",
165+
}
166+
167+
# Projects that should not run any tests. These need to be metaprojects.
168+
SKIP_PROJECTS = ["docs", "gn"]
169+
144170

145171
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
146172
projects_with_dependents = set(projects)
@@ -233,21 +259,34 @@ def _compute_runtimes_to_build(
233259
return _exclude_projects(runtimes_to_build, platform)
234260

235261

262+
def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
263+
if len(file_path) < len(matcher):
264+
return False
265+
for match_part, file_part in zip(matcher, file_path):
266+
if match_part == "*" or file_part == "*":
267+
continue
268+
if match_part != file_part:
269+
return False
270+
return True
271+
272+
273+
def _get_modified_projects_for_file(modified_file: str) -> Set[str]:
274+
modified_projects = set()
275+
path_parts = pathlib.Path(modified_file).parts
276+
for meta_project_files in META_PROJECTS.keys():
277+
if _path_matches(meta_project_files, path_parts):
278+
meta_project = META_PROJECTS[meta_project_files]
279+
if meta_project in SKIP_PROJECTS:
280+
return set()
281+
modified_projects.add(meta_project)
282+
modified_projects.add(pathlib.Path(modified_file).parts[0])
283+
return modified_projects
284+
285+
236286
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
237287
modified_projects = set()
238288
for modified_file in modified_files:
239-
path_parts = pathlib.Path(modified_file).parts
240-
# Exclude files in the docs directory. They do not impact an test
241-
# targets and there is a separate workflow used for ensuring the
242-
# documentation builds.
243-
if len(path_parts) > 2 and path_parts[1] == "docs":
244-
continue
245-
# Exclude files for the gn build. We do not test it within premerge
246-
# and changes occur often enough that they otherwise take up
247-
# capacity.
248-
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
249-
continue
250-
modified_projects.add(pathlib.Path(modified_file).parts[0])
289+
modified_projects.update(_get_modified_projects_for_file(modified_file))
251290
return modified_projects
252291

253292

@@ -267,6 +306,13 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
267306
runtimes_check_targets_needs_reconfig = _compute_project_check_targets(
268307
runtimes_to_test_needs_reconfig
269308
)
309+
310+
# CIR is used as a pseudo-project in this script. It is built as part of the
311+
# clang build, but it requires an explicit option to enable. We set that
312+
# option here, and remove it from the projects_to_build list.
313+
enable_cir = "ON" if "CIR" in projects_to_build else "OFF"
314+
projects_to_build.discard("CIR")
315+
270316
# We use a semicolon to separate the projects/runtimes as they get passed
271317
# to the CMake invocation and thus we need to use the CMake list separator
272318
# (;). We use spaces to separate the check targets as they end up getting
@@ -279,6 +325,7 @@ def get_env_variables(modified_files: list[str], platform: str) -> Set[str]:
279325
"runtimes_check_targets_needs_reconfig": " ".join(
280326
sorted(runtimes_check_targets_needs_reconfig)
281327
),
328+
"enable_cir": enable_cir,
282329
}
283330

284331

.ci/compute_projects_test.py

Lines changed: 124 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
22
# See https://llvm.org/LICENSE.txt for license information.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4-
"""Does some stuff."""
4+
"""Tests for compute_projects.py"""
55

66
import unittest
77

@@ -45,16 +45,14 @@ def test_llvm_windows(self):
4545
env_variables["project_check_targets"],
4646
"check-clang check-clang-tools check-lld check-llvm check-mlir check-polly",
4747
)
48-
self.assertEqual(
49-
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
50-
)
48+
self.assertEqual(env_variables["runtimes_to_build"], "")
5149
self.assertEqual(
5250
env_variables["runtimes_check_targets"],
5351
"",
5452
)
5553
self.assertEqual(
5654
env_variables["runtimes_check_targets_needs_reconfig"],
57-
"check-cxx check-cxxabi check-unwind",
55+
"",
5856
)
5957

6058
def test_llvm_mac(self):
@@ -69,16 +67,14 @@ def test_llvm_mac(self):
6967
env_variables["project_check_targets"],
7068
"check-clang check-clang-tools check-lld check-llvm check-mlir",
7169
)
72-
self.assertEqual(
73-
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
74-
)
70+
self.assertEqual(env_variables["runtimes_to_build"], "")
7571
self.assertEqual(
7672
env_variables["runtimes_check_targets"],
7773
"",
7874
)
7975
self.assertEqual(
8076
env_variables["runtimes_check_targets_needs_reconfig"],
81-
"check-cxx check-cxxabi check-unwind",
77+
"",
8278
)
8379

8480
def test_clang(self):
@@ -104,6 +100,10 @@ def test_clang(self):
104100
env_variables["runtimes_check_targets_needs_reconfig"],
105101
"check-cxx check-cxxabi check-unwind",
106102
)
103+
self.assertEqual(
104+
env_variables["enable_cir"],
105+
"OFF",
106+
)
107107

108108
def test_clang_windows(self):
109109
env_variables = compute_projects.get_env_variables(
@@ -115,17 +115,41 @@ def test_clang_windows(self):
115115
self.assertEqual(
116116
env_variables["project_check_targets"], "check-clang check-clang-tools"
117117
)
118+
self.assertEqual(env_variables["runtimes_to_build"], "")
118119
self.assertEqual(
119-
env_variables["runtimes_to_build"], "libcxx;libcxxabi;libunwind"
120+
env_variables["runtimes_check_targets"],
121+
"",
120122
)
121123
self.assertEqual(
122-
env_variables["runtimes_check_targets"],
124+
env_variables["runtimes_check_targets_needs_reconfig"],
123125
"",
124126
)
127+
self.assertEqual(env_variables["enable_cir"], "OFF")
128+
129+
def test_cir(self):
130+
env_variables = compute_projects.get_env_variables(
131+
["clang/lib/CIR/CMakeLists.txt"], "Linux"
132+
)
133+
self.assertEqual(
134+
env_variables["projects_to_build"],
135+
"clang;clang-tools-extra;lld;llvm;mlir",
136+
)
137+
self.assertEqual(
138+
env_variables["project_check_targets"],
139+
"check-clang check-clang-cir check-clang-tools",
140+
)
141+
self.assertEqual(
142+
env_variables["runtimes_to_build"], "compiler-rt;libcxx;libcxxabi;libunwind"
143+
)
144+
self.assertEqual(
145+
env_variables["runtimes_check_targets"],
146+
"check-compiler-rt",
147+
)
125148
self.assertEqual(
126149
env_variables["runtimes_check_targets_needs_reconfig"],
127150
"check-cxx check-cxxabi check-unwind",
128151
)
152+
self.assertEqual(env_variables["enable_cir"], "ON")
129153

130154
def test_bolt(self):
131155
env_variables = compute_projects.get_env_variables(
@@ -158,6 +182,7 @@ def test_mlir(self):
158182
self.assertEqual(env_variables["runtimes_to_build"], "")
159183
self.assertEqual(env_variables["runtimes_check_targets"], "")
160184
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
185+
self.assertEqual(env_variables["enable_cir"], "OFF")
161186

162187
def test_flang(self):
163188
env_variables = compute_projects.get_env_variables(
@@ -168,10 +193,11 @@ def test_flang(self):
168193
self.assertEqual(env_variables["runtimes_to_build"], "")
169194
self.assertEqual(env_variables["runtimes_check_targets"], "")
170195
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
196+
self.assertEqual(env_variables["enable_cir"], "OFF")
171197

172198
def test_invalid_subproject(self):
173199
env_variables = compute_projects.get_env_variables(
174-
["third-party/benchmark/CMakeLists.txt"], "Linux"
200+
["llvm-libgcc/CMakeLists.txt"], "Linux"
175201
)
176202
self.assertEqual(env_variables["projects_to_build"], "")
177203
self.assertEqual(env_variables["project_check_targets"], "")
@@ -237,7 +263,7 @@ def test_ci(self):
237263
)
238264
self.assertEqual(
239265
env_variables["project_check_targets"],
240-
"check-bolt check-clang check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
266+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
241267
)
242268
self.assertEqual(
243269
env_variables["runtimes_to_build"],
@@ -252,6 +278,31 @@ def test_ci(self):
252278
"check-cxx check-cxxabi check-unwind",
253279
)
254280

281+
def test_windows_ci(self):
282+
env_variables = compute_projects.get_env_variables(
283+
[".ci/compute_projects.py"], "Windows"
284+
)
285+
self.assertEqual(
286+
env_variables["projects_to_build"],
287+
"clang;clang-tools-extra;libclc;lld;llvm;mlir;polly",
288+
)
289+
self.assertEqual(
290+
env_variables["project_check_targets"],
291+
"check-clang check-clang-cir check-clang-tools check-lld check-llvm check-mlir check-polly",
292+
)
293+
self.assertEqual(
294+
env_variables["runtimes_to_build"],
295+
"",
296+
)
297+
self.assertEqual(
298+
env_variables["runtimes_check_targets"],
299+
"",
300+
)
301+
self.assertEqual(
302+
env_variables["runtimes_check_targets_needs_reconfig"],
303+
"",
304+
)
305+
255306
def test_lldb(self):
256307
env_variables = compute_projects.get_env_variables(
257308
["lldb/CMakeLists.txt"], "Linux"
@@ -276,6 +327,66 @@ def test_clang_tools_extra(self):
276327
self.assertEqual(env_variables["runtimes_check_targets"], "check-libc")
277328
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
278329

330+
def test_premerge_workflow(self):
331+
env_variables = compute_projects.get_env_variables(
332+
[".github/workflows/premerge.yaml"], "Linux"
333+
)
334+
self.assertEqual(
335+
env_variables["projects_to_build"],
336+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
337+
)
338+
self.assertEqual(
339+
env_variables["project_check_targets"],
340+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
341+
)
342+
self.assertEqual(
343+
env_variables["runtimes_to_build"],
344+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
345+
)
346+
self.assertEqual(
347+
env_variables["runtimes_check_targets"],
348+
"check-compiler-rt check-libc",
349+
)
350+
self.assertEqual(
351+
env_variables["runtimes_check_targets_needs_reconfig"],
352+
"check-cxx check-cxxabi check-unwind",
353+
)
354+
355+
def test_other_github_workflow(self):
356+
env_variables = compute_projects.get_env_variables(
357+
[".github/workflows/docs.yml"], "Linux"
358+
)
359+
self.assertEqual(env_variables["projects_to_build"], "")
360+
self.assertEqual(env_variables["project_check_targets"], "")
361+
self.assertEqual(env_variables["runtimes_to_build"], "")
362+
self.assertEqual(env_variables["runtimes_check_targets"], "")
363+
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
364+
365+
def test_third_party_benchmark(self):
366+
env_variables = compute_projects.get_env_variables(
367+
["third-party/benchmark/CMakeLists.txt"], "Linux"
368+
)
369+
self.assertEqual(
370+
env_variables["projects_to_build"],
371+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
372+
)
373+
self.assertEqual(
374+
env_variables["project_check_targets"],
375+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
376+
)
377+
self.assertEqual(
378+
env_variables["runtimes_to_build"],
379+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
380+
)
381+
self.assertEqual(
382+
env_variables["runtimes_check_targets"],
383+
"check-compiler-rt check-libc",
384+
)
385+
self.assertEqual(
386+
env_variables["runtimes_check_targets_needs_reconfig"],
387+
"check-cxx check-cxxabi check-unwind",
388+
)
389+
279390

280391
if __name__ == "__main__":
281392
unittest.main()

.ci/generate_test_report_github.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,23 @@
44
"""Script to generate a build report for Github."""
55

66
import argparse
7+
import platform
78

89
import generate_test_report_lib
910

11+
PLATFORM_TITLES = {
12+
"Windows": ":window: Windows x64 Test Results",
13+
"Linux": ":penguin: Linux x64 Test Results",
14+
}
15+
1016
if __name__ == "__main__":
1117
parser = argparse.ArgumentParser()
12-
parser.add_argument(
13-
"title", help="Title of the test report, without Markdown formatting."
14-
)
1518
parser.add_argument("return_code", help="The build's return code.", type=int)
1619
parser.add_argument("junit_files", help="Paths to JUnit report files.", nargs="*")
1720
args = parser.parse_args()
1821

19-
report, _ = generate_test_report_lib.generate_report_from_files(
20-
args.title, args.return_code, args.junit_files, None
22+
report = generate_test_report_lib.generate_report_from_files(
23+
PLATFORM_TITLES[platform.system()], args.return_code, args.junit_files
2124
)
2225

2326
print(report)

0 commit comments

Comments
 (0)