Skip to content

Commit aec3a4c

Browse files
committed
Rebase
Created using spr 1.3.5
2 parents 6ac764c + ef98e24 commit aec3a4c

File tree

1,409 files changed

+50015
-31369
lines changed

Some content is hidden

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

1,409 files changed

+50015
-31369
lines changed

.ci/compute_projects.py

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,23 @@
144144

145145
RUNTIMES = {"libcxx", "libcxxabi", "libunwind", "compiler-rt", "libc"}
146146

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

148165
def _add_dependencies(projects: Set[str], runtimes: Set[str]) -> Set[str]:
149166
projects_with_dependents = set(projects)
@@ -236,29 +253,34 @@ def _compute_runtimes_to_build(
236253
return _exclude_projects(runtimes_to_build, platform)
237254

238255

256+
def _path_matches(matcher: tuple[str], file_path: tuple[str]) -> bool:
257+
if len(file_path) < len(matcher):
258+
return False
259+
for match_part, file_part in zip(matcher, file_path):
260+
if match_part == "*" or file_part == "*":
261+
continue
262+
if match_part != file_part:
263+
return False
264+
return True
265+
266+
267+
def _get_modified_projects_for_file(modified_file: str) -> Set[str]:
268+
modified_projects = set()
269+
path_parts = pathlib.Path(modified_file).parts
270+
for meta_project_files in META_PROJECTS.keys():
271+
if _path_matches(meta_project_files, path_parts):
272+
meta_project = META_PROJECTS[meta_project_files]
273+
if meta_project in SKIP_PROJECTS:
274+
return set()
275+
modified_projects.add(meta_project)
276+
modified_projects.add(pathlib.Path(modified_file).parts[0])
277+
return modified_projects
278+
279+
239280
def _get_modified_projects(modified_files: list[str]) -> Set[str]:
240281
modified_projects = set()
241282
for modified_file in modified_files:
242-
path_parts = pathlib.Path(modified_file).parts
243-
# Exclude files in the docs directory. They do not impact an test
244-
# targets and there is a separate workflow used for ensuring the
245-
# documentation builds.
246-
if len(path_parts) > 2 and path_parts[1] == "docs":
247-
continue
248-
# Exclude files for the gn build. We do not test it within premerge
249-
# and changes occur often enough that they otherwise take up
250-
# capacity.
251-
if len(path_parts) > 3 and path_parts[:3] == ("llvm", "utils", "gn"):
252-
continue
253-
# If the file is in the clang/lib/CIR directory, add the CIR project.
254-
if len(path_parts) > 3 and (
255-
path_parts[:3] == ("clang", "lib", "CIR")
256-
or path_parts[:3] == ("clang", "test", "CIR")
257-
or path_parts[:4] == ("clang", "include", "clang", "CIR")
258-
):
259-
modified_projects.add("CIR")
260-
# Fall through to add clang.
261-
modified_projects.add(pathlib.Path(modified_file).parts[0])
283+
modified_projects.update(_get_modified_projects_for_file(modified_file))
262284
return modified_projects
263285

264286

.ci/compute_projects_test.py

Lines changed: 62 additions & 2 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

@@ -203,7 +203,7 @@ def test_flang(self):
203203

204204
def test_invalid_subproject(self):
205205
env_variables = compute_projects.get_env_variables(
206-
["third-party/benchmark/CMakeLists.txt"], "Linux"
206+
["llvm-libgcc/CMakeLists.txt"], "Linux"
207207
)
208208
self.assertEqual(env_variables["projects_to_build"], "")
209209
self.assertEqual(env_variables["project_check_targets"], "")
@@ -308,6 +308,66 @@ def test_clang_tools_extra(self):
308308
self.assertEqual(env_variables["runtimes_check_targets"], "check-libc")
309309
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
310310

311+
def test_premerge_workflow(self):
312+
env_variables = compute_projects.get_env_variables(
313+
[".github/workflows/premerge.yaml"], "Linux"
314+
)
315+
self.assertEqual(
316+
env_variables["projects_to_build"],
317+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
318+
)
319+
self.assertEqual(
320+
env_variables["project_check_targets"],
321+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
322+
)
323+
self.assertEqual(
324+
env_variables["runtimes_to_build"],
325+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
326+
)
327+
self.assertEqual(
328+
env_variables["runtimes_check_targets"],
329+
"check-compiler-rt check-libc",
330+
)
331+
self.assertEqual(
332+
env_variables["runtimes_check_targets_needs_reconfig"],
333+
"check-cxx check-cxxabi check-unwind",
334+
)
335+
336+
def test_other_github_workflow(self):
337+
env_variables = compute_projects.get_env_variables(
338+
[".github/workflows/docs.yml"], "Linux"
339+
)
340+
self.assertEqual(env_variables["projects_to_build"], "")
341+
self.assertEqual(env_variables["project_check_targets"], "")
342+
self.assertEqual(env_variables["runtimes_to_build"], "")
343+
self.assertEqual(env_variables["runtimes_check_targets"], "")
344+
self.assertEqual(env_variables["runtimes_check_targets_needs_reconfig"], "")
345+
346+
def test_third_party_benchmark(self):
347+
env_variables = compute_projects.get_env_variables(
348+
["third-party/benchmark/CMakeLists.txt"], "Linux"
349+
)
350+
self.assertEqual(
351+
env_variables["projects_to_build"],
352+
"bolt;clang;clang-tools-extra;flang;libclc;lld;lldb;llvm;mlir;polly",
353+
)
354+
self.assertEqual(
355+
env_variables["project_check_targets"],
356+
"check-bolt check-clang check-clang-cir check-clang-tools check-flang check-lld check-lldb check-llvm check-mlir check-polly",
357+
)
358+
self.assertEqual(
359+
env_variables["runtimes_to_build"],
360+
"compiler-rt;libc;libcxx;libcxxabi;libunwind",
361+
)
362+
self.assertEqual(
363+
env_variables["runtimes_check_targets"],
364+
"check-compiler-rt check-libc",
365+
)
366+
self.assertEqual(
367+
env_variables["runtimes_check_targets_needs_reconfig"],
368+
"check-cxx check-cxxabi check-unwind",
369+
)
370+
311371

312372
if __name__ == "__main__":
313373
unittest.main()

.ci/metrics/metrics.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Collects Github metrics and uploads them to Grafana.
5+
6+
This script contains machinery that will pull metrics periodically from Github
7+
about workflow runs. It will upload the collected metrics to the specified
8+
Grafana instance.
9+
"""
10+
111
import collections
212
import datetime
313
import github

.ci/metrics/metrics_test.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
"""Tests for metrics.py"""
5+
6+
from dataclasses import dataclass
7+
import requests
8+
import unittest
9+
import unittest.mock
10+
11+
import metrics
12+
13+
14+
class TestMetrics(unittest.TestCase):
15+
def test_upload_gauge_metric(self):
16+
"""Test that we can upload a gauge metric correctly.
17+
18+
Also verify that we pass around parameters like API keys and user IDs
19+
correctly to the HTTP POST request.
20+
"""
21+
test_metrics = [metrics.GaugeMetric("gauge_test", 5, 1000)]
22+
return_value = requests.Response()
23+
return_value.status_code = 204
24+
with unittest.mock.patch(
25+
"requests.post", return_value=return_value
26+
) as post_mock:
27+
metrics.upload_metrics(test_metrics, "test_userid", "test_api_key")
28+
self.assertSequenceEqual(post_mock.call_args.args, [metrics.GRAFANA_URL])
29+
self.assertEqual(
30+
post_mock.call_args.kwargs["data"], "gauge_test value=5 1000"
31+
)
32+
self.assertEqual(
33+
post_mock.call_args.kwargs["auth"], ("test_userid", "test_api_key")
34+
)
35+
36+
def test_upload_job_metric(self):
37+
"""Test that we can upload a job metric correctly."""
38+
test_metrics = [
39+
metrics.JobMetrics("test_job", 5, 10, 1, 1000, 7, "test_workflow")
40+
]
41+
return_value = requests.Response()
42+
return_value.status_code = 204
43+
with unittest.mock.patch(
44+
"requests.post", return_value=return_value
45+
) as post_mock:
46+
metrics.upload_metrics(test_metrics, "test_userid", "test_aoi_key")
47+
self.assertEqual(
48+
post_mock.call_args.kwargs["data"],
49+
"test_job queue_time=5,run_time=10,status=1 1000",
50+
)
51+
52+
def test_upload_unknown_metric(self):
53+
"""Test we report an error if we encounter an unknown metric type."""
54+
55+
@dataclass
56+
class FakeMetric:
57+
fake_data: str
58+
59+
test_metrics = [FakeMetric("test")]
60+
61+
with self.assertRaises(ValueError):
62+
metrics.upload_metrics(test_metrics, "test_userid", "test_api_key")
63+
64+
def test_bad_response_code(self):
65+
"""Test that we gracefully handle HTTP response errors."""
66+
test_metrics = [metrics.GaugeMetric("gauge_test", 5, 1000)]
67+
return_value = requests.Response()
68+
return_value.status_code = 403
69+
# Just assert that we continue running here and do not raise anything.
70+
with unittest.mock.patch("requests.post", return_value=return_value) as _:
71+
metrics.upload_metrics(test_metrics, "test_userid", "test_api_key")
72+
73+
74+
if __name__ == "__main__":
75+
unittest.main()

.github/CODEOWNERS

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,9 @@
120120
/mlir/**/Index* @mogball
121121

122122
# MLIR Python Bindings
123-
/mlir/test/python/ @ftynse @makslevental @stellaraccident
124-
/mlir/python/ @ftynse @makslevental @stellaraccident
123+
/mlir/test/python/ @ftynse @makslevental @stellaraccident @rolfmorel
124+
/mlir/python/ @ftynse @makslevental @stellaraccident @rolfmorel
125+
/mlir/lib/Bindings/Python @makslevental @rolfmorel
125126

126127
# MLIR Mem2Reg/SROA
127128
/mlir/**/Transforms/Mem2Reg.* @moxinilian

.github/workflows/check-ci.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Check CI Scripts
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
paths:
9+
- '.ci/**'
10+
- '.github/workflows/check-ci.yml'
11+
pull_request:
12+
paths:
13+
- '.ci/**'
14+
- '.github/workflows/check-ci.yml'
15+
16+
jobs:
17+
test-python:
18+
name: "Check Python Tests"
19+
runs-on: ubuntu-24.04
20+
if: github.repository == 'llvm/llvm-project'
21+
steps:
22+
- name: Fetch LLVM sources
23+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
24+
with:
25+
sparse-checkout: .ci
26+
- name: Setup Python
27+
uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
28+
with:
29+
python-version: 3.13
30+
cache: 'pip'
31+
- name: Install Python Dependencies
32+
run: |
33+
pip3 install -r .ci/all_requirements.txt
34+
pip3 install -r .ci/metrics/requirements.lock.txt
35+
pip3 install pytest==8.4.1
36+
- name: Run Tests
37+
working-directory: .ci
38+
run: pytest

.github/workflows/containers/github-action-ci-windows/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ RUN powershell -Command \
9090
RUN git config --system core.longpaths true & \
9191
git config --global core.autocrlf false
9292
93-
ARG RUNNER_VERSION=2.326.0
93+
ARG RUNNER_VERSION=2.327.0
9494
ENV RUNNER_VERSION=$RUNNER_VERSION
9595
9696
RUN powershell -Command \

.github/workflows/containers/github-action-ci/Dockerfile

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,8 @@ RUN apt-get update && \
5858
python3-psutil \
5959
sudo \
6060
# These are needed by the premerge pipeline. Pip is used to install
61-
# dependent python packages and ccache is used for build caching. File and
62-
# tzdata are used for tests.
61+
# dependent python packages. File and tzdata are used for tests.
6362
python3-pip \
64-
ccache \
6563
file \
6664
tzdata && \
6765
apt-get clean && \
@@ -96,7 +94,7 @@ WORKDIR /home/gha
9694

9795
FROM ci-container as ci-container-agent
9896

99-
ENV GITHUB_RUNNER_VERSION=2.326.0
97+
ENV GITHUB_RUNNER_VERSION=2.327.0
10098

10199
RUN mkdir actions-runner && \
102100
cd actions-runner && \

.github/workflows/premerge.yaml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ jobs:
6262
# why we do not hardcode it.
6363
export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET
6464
export SCCACHE_GCS_RW_MODE=READ_WRITE
65+
66+
# Set the idle timeout to zero to ensure sccache runs for the
67+
# entire duration of the job. Otherwise it might stop if we run
68+
# several test suites in a row and discard statistics that we want
69+
# to save in the end.
70+
export SCCACHE_IDLE_TIMEOUT=0
6571
sccache --start-server
6672
6773
./.ci/monolithic-linux.sh "${projects_to_build}" "${project_check_targets}" "${runtimes_to_build}" "${runtimes_check_targets}" "${runtimes_check_targets_needs_reconfig}" "${enable_cir}"
@@ -110,7 +116,9 @@ jobs:
110116
shell: cmd
111117
run: |
112118
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
113-
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
119+
# See the comments above in the Linux job for why we define each of
120+
# these environment variables.
121+
bash -c "export SCCACHE_GCS_BUCKET=$CACHE_GCS_BUCKET; export SCCACHE_GCS_RW_MODE=READ_WRITE; export SCCACHE_IDLE_TIMEOUT=0; sccache --start-server; .ci/monolithic-windows.sh \"${{ steps.vars.outputs.windows-projects }}\" \"${{ steps.vars.outputs.windows-check-targets }}\""
114122
- name: Upload Artifacts
115123
if: '!cancelled()'
116124
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0

.github/workflows/release-asset-audit.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@ jobs:
2222
runs-on: ubuntu-24.04
2323
if: github.repository == 'llvm/llvm-project'
2424
steps:
25-
- uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 #v4.1.6
25+
- name: Checkout LLVM
26+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
with:
28+
sparse-checkout: |
29+
.github/workflows/release-asset-audit.py
30+
llvm/utils/git/requirements.txt
2631
- name: "Run Audit Script"
2732
env:
2833
GITHUB_TOKEN: ${{ github.token }}

0 commit comments

Comments
 (0)