Skip to content

Commit

Permalink
Merge branch 'llvm:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Un1q32 authored Jan 14, 2025
2 parents eab8ac2 + 63d3bd6 commit 68c9b3a
Show file tree
Hide file tree
Showing 3,632 changed files with 210,334 additions and 93,844 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
102 changes: 88 additions & 14 deletions .ci/generate_test_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ def junit_from_xml(xml):

class TestReports(unittest.TestCase):
def test_title_only(self):
self.assertEqual(_generate_report("Foo", []), ("", "success"))
self.assertEqual(_generate_report("Foo", 0, []), ("", "success"))

def test_no_tests_in_testsuite(self):
self.assertEqual(
_generate_report(
"Foo",
1,
[
junit_from_xml(
dedent(
Expand All @@ -45,6 +46,7 @@ def test_no_failures(self):
self.assertEqual(
_generate_report(
"Foo",
0,
[
junit_from_xml(
dedent(
Expand All @@ -70,10 +72,51 @@ def test_no_failures(self):
),
)

def test_no_failures_build_failed(self):
self.assertEqual(
_generate_report(
"Foo",
1,
[
junit_from_xml(
dedent(
"""\
<?xml version="1.0" encoding="UTF-8"?>
<testsuites time="0.00">
<testsuite name="Passed" tests="1" failures="0" skipped="0" time="0.00">
<testcase classname="Bar/test_1" name="test_1" time="0.00"/>
</testsuite>
</testsuites>"""
)
)
],
buildkite_info={
"BUILDKITE_ORGANIZATION_SLUG": "organization_slug",
"BUILDKITE_PIPELINE_SLUG": "pipeline_slug",
"BUILDKITE_BUILD_NUMBER": "build_number",
"BUILDKITE_JOB_ID": "job_id",
},
),
(
dedent(
"""\
# Foo
* 1 test passed
All tests passed but another part of the build **failed**.
[Download](https://buildkite.com/organizations/organization_slug/pipelines/pipeline_slug/builds/build_number/jobs/job_id/download.txt) the build's log file to see the details."""
),
"error",
),
)

def test_report_single_file_single_testsuite(self):
self.assertEqual(
_generate_report(
"Foo",
1,
[
junit_from_xml(
dedent(
Expand Down Expand Up @@ -166,6 +209,7 @@ def test_report_single_file_multiple_testsuites(self):
self.assertEqual(
_generate_report(
"ABC and DEF",
1,
[
junit_from_xml(
dedent(
Expand Down Expand Up @@ -198,6 +242,7 @@ def test_report_multiple_files_multiple_testsuites(self):
self.assertEqual(
_generate_report(
"ABC and DEF",
1,
[
junit_from_xml(
dedent(
Expand Down Expand Up @@ -238,6 +283,7 @@ def test_report_dont_list_failures(self):
self.assertEqual(
_generate_report(
"Foo",
1,
[
junit_from_xml(
dedent(
Expand Down Expand Up @@ -272,6 +318,7 @@ def test_report_dont_list_failures_link_to_log(self):
self.assertEqual(
_generate_report(
"Foo",
1,
[
junit_from_xml(
dedent(
Expand Down Expand Up @@ -312,6 +359,7 @@ def test_report_size_limit(self):
self.assertEqual(
_generate_report(
"Foo",
1,
[
junit_from_xml(
dedent(
Expand Down Expand Up @@ -351,12 +399,18 @@ def test_report_size_limit(self):
# and output will not be.
def _generate_report(
title,
return_code,
junit_objects,
size_limit=1024 * 1024,
list_failures=True,
buildkite_info=None,
):
if not junit_objects:
# Note that we do not post an empty report, therefore we can ignore a
# non-zero return code in situations like this.
#
# If we were going to post a report, then yes, it would be misleading
# to say we succeeded when the final return code was non-zero.
return ("", "success")

failures = {}
Expand Down Expand Up @@ -385,7 +439,11 @@ def _generate_report(
if not tests_run:
return ("", None)

style = "error" if tests_failed else "success"
style = "success"
# Either tests failed, or all tests passed but something failed to build.
if tests_failed or return_code != 0:
style = "error"

report = [f"# {title}", ""]

tests_passed = tests_run - tests_skipped - tests_failed
Expand All @@ -400,17 +458,17 @@ def plural(num_tests):
if tests_failed:
report.append(f"* {tests_failed} {plural(tests_failed)} failed")

if not list_failures:
if buildkite_info is not None:
log_url = (
"https://buildkite.com/organizations/{BUILDKITE_ORGANIZATION_SLUG}/"
"pipelines/{BUILDKITE_PIPELINE_SLUG}/builds/{BUILDKITE_BUILD_NUMBER}/"
"jobs/{BUILDKITE_JOB_ID}/download.txt".format(**buildkite_info)
)
download_text = f"[Download]({log_url})"
else:
download_text = "Download"
if buildkite_info is not None:
log_url = (
"https://buildkite.com/organizations/{BUILDKITE_ORGANIZATION_SLUG}/"
"pipelines/{BUILDKITE_PIPELINE_SLUG}/builds/{BUILDKITE_BUILD_NUMBER}/"
"jobs/{BUILDKITE_JOB_ID}/download.txt".format(**buildkite_info)
)
download_text = f"[Download]({log_url})"
else:
download_text = "Download"

if not list_failures:
report.extend(
[
"",
Expand All @@ -435,11 +493,23 @@ def plural(num_tests):
"</details>",
]
)
elif return_code != 0:
# No tests failed but the build was in a failed state. Bring this to the user's
# attention.
report.extend(
[
"",
"All tests passed but another part of the build **failed**.",
"",
f"{download_text} the build's log file to see the details.",
]
)

report = "\n".join(report)
if len(report.encode("utf-8")) > size_limit:
return _generate_report(
title,
return_code,
junit_objects,
size_limit,
list_failures=False,
Expand All @@ -449,9 +519,10 @@ def plural(num_tests):
return report, style


def generate_report(title, junit_files, buildkite_info):
def generate_report(title, return_code, junit_files, buildkite_info):
return _generate_report(
title,
return_code,
[JUnitXml.fromfile(p) for p in junit_files],
buildkite_info=buildkite_info,
)
Expand All @@ -463,6 +534,7 @@ def generate_report(title, junit_files, buildkite_info):
"title", help="Title of the test report, without Markdown formatting."
)
parser.add_argument("context", help="Annotation context to write to.")
parser.add_argument("return_code", help="The build's return code.", type=int)
parser.add_argument("junit_files", help="Paths to JUnit report files.", nargs="*")
args = parser.parse_args()

Expand All @@ -477,7 +549,9 @@ def generate_report(title, junit_files, buildkite_info):
if len(buildkite_info) != len(env_var_names):
buildkite_info = None

report, style = generate_report(args.title, args.junit_files, buildkite_info)
report, style = generate_report(
args.title, args.return_code, args.junit_files, buildkite_info
)

if report:
p = subprocess.Popen(
Expand Down
14 changes: 13 additions & 1 deletion .ci/metrics/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"https://influx-prod-13-prod-us-east-0.grafana.net/api/v1/push/influx/write"
)
GITHUB_PROJECT = "llvm/llvm-project"
WORKFLOWS_TO_TRACK = ["Check code formatting", "LLVM Premerge Checks"]
WORKFLOWS_TO_TRACK = ["LLVM Premerge Checks"]
SCRAPE_INTERVAL_SECONDS = 5 * 60


Expand Down Expand Up @@ -80,6 +80,18 @@ def get_metrics(github_repo: github.Repository, workflows_to_track: dict[str, in
completed_at = workflow_jobs[0].completed_at

job_result = int(workflow_jobs[0].conclusion == "success")
if job_result:
# We still might want to mark the job as a failure if one of the steps
# failed. This is required due to use setting continue-on-error in
# the premerge pipeline to prevent sending emails while we are
# testing the infrastructure.
# TODO(boomanaiden154): Remove this once the premerge pipeline is no
# longer in a testing state and we can directly assert the workflow
# result.
for step in workflow_jobs[0].steps:
if step.conclusion != "success":
job_result = 0
break

queue_time = started_at - created_at
run_time = completed_at - started_at
Expand Down
4 changes: 3 additions & 1 deletion .ci/monolithic-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ if [[ -n "${CLEAR_CACHE:-}" ]]; then
fi

function at-exit {
retcode=$?

mkdir -p artifacts
ccache --print-stats > artifacts/ccache_stats.txt

Expand All @@ -37,7 +39,7 @@ function at-exit {
if command -v buildkite-agent 2>&1 >/dev/null
then
python3 "${MONOREPO_ROOT}"/.ci/generate_test_report.py ":linux: Linux x64 Test Results" \
"linux-x64-test-results" "${BUILD_DIR}"/test-results.*.xml
"linux-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
fi
}
trap at-exit EXIT
Expand Down
4 changes: 3 additions & 1 deletion .ci/monolithic-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ fi

sccache --zero-stats
function at-exit {
retcode=$?

mkdir -p artifacts
sccache --show-stats >> artifacts/sccache_stats.txt

Expand All @@ -36,7 +38,7 @@ function at-exit {
if command -v buildkite-agent 2>&1 >/dev/null
then
python "${MONOREPO_ROOT}"/.ci/generate_test_report.py ":windows: Windows x64 Test Results" \
"windows-x64-test-results" "${BUILD_DIR}"/test-results.*.xml
"windows-x64-test-results" $retcode "${BUILD_DIR}"/test-results.*.xml
fi
}
trap at-exit EXIT
Expand Down
5 changes: 5 additions & 0 deletions .github/new-prs-labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,11 @@ backend:DirectX:

backend:SPIR-V:
- clang/lib/Driver/ToolChains/SPIRV.*
- clang/lib/Sema/SemaSPIRV.cpp
- clang/include/clang/Sema/SemaSPIRV.h
- clang/include/clang/Basic/BuiltinsSPIRV.td
- clang/test/CodeGenSPIRV/**
- clang/test/SemaSPIRV/**
- llvm/lib/Target/SPIRV/**
- llvm/test/CodeGen/SPIRV/**
- llvm/test/Frontend/HLSL/**
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/build-ci-container.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,9 @@ jobs:

- name: Test Container
run: |
for image in ${{ steps.vars.outputs.container-name-tag }} ${{ steps.vars.outputs.container-name }}; do
podman run --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
for image in ${{ steps.vars.outputs.container-name-tag }}; do
# Use --pull=never to ensure we are testing the just built image.
podman run --pull=never --rm -it $image /usr/bin/bash -x -c 'cd $HOME && printf '\''#include <iostream>\nint main(int argc, char **argv) { std::cout << "Hello\\n"; }'\'' | clang++ -x c++ - && ./a.out | grep Hello'
done
push-ci-container:
Expand Down
44 changes: 26 additions & 18 deletions .github/workflows/commit-access-review.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,39 +67,47 @@ def check_manual_requests(
) -> list[str]:
"""
Return a list of users who have been asked since ``start_date`` if they
want to keep their commit access.
want to keep their commit access or if they have applied for commit
access since ``start_date``
"""

query = """
query ($query: String!) {
search(query: $query, type: ISSUE, first: 100) {
query ($query: String!, $after: String) {
search(query: $query, type: ISSUE, first: 100, after: $after) {
nodes {
... on Issue {
body
comments (first: 100) {
nodes {
author {
login
}
}
author {
login
}
body
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
"""
formatted_start_date = start_date.strftime("%Y-%m-%dT%H:%M:%S")
variables = {
"query": f"type:issue created:>{formatted_start_date} org:llvm repo:llvm-project label:infra:commit-access"
"query": f"type:issue created:>{formatted_start_date} org:llvm repo:llvm-project label:infra:commit-access,infra:commit-access-request"
}

res_header, res_data = gh._Github__requester.graphql_query(
query=query, variables=variables
)
data = res_data["data"]
has_next_page = True
users = []
for issue in data["search"]["nodes"]:
users.extend([user[1:] for user in re.findall("@[^ ,\n]+", issue["body"])])

while has_next_page:
res_header, res_data = gh._Github__requester.graphql_query(
query=query, variables=variables
)
data = res_data["data"]
for issue in data["search"]["nodes"]:
users.extend([user[1:] for user in re.findall("@[^ ,\n]+", issue["body"])])
if issue["author"]:
users.append(issue["author"]["login"])
has_next_page = data["search"]["pageInfo"]["hasNextPage"]
if has_next_page:
variables["after"] = data["search"]["pageInfo"]["endCursor"]
return users


Expand Down
Loading

0 comments on commit 68c9b3a

Please sign in to comment.