Skip to content

Commit 197a78d

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into static-resources
2 parents 17bf204 + ba4babe commit 197a78d

File tree

2,331 files changed

+61382
-34705
lines changed

Some content is hidden

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

2,331 files changed

+61382
-34705
lines changed

.ci/all_requirements.txt

Lines changed: 192 additions & 2 deletions
Large diffs are not rendered by default.

.ci/monolithic-windows.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
4747
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
4848
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
4949
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO" \
50-
-D CMAKE_CXX_FLAGS="-Wno-c++98-compat -Wno-c++14-compat -Wno-unsafe-buffer-usage -Wno-old-style-cast" \
5150
-D LLVM_ENABLE_RUNTIMES="${runtimes}"
5251

5352
start-group "ninja"

.ci/premerge_advisor_explain.py

Lines changed: 97 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,90 @@
44
"""Script for getting explanations from the premerge advisor."""
55

66
import argparse
7-
import os
87
import platform
98
import sys
9+
import json
10+
11+
# TODO(boomanaiden154): Remove the optional call once we can require Python
12+
# 3.10.
13+
from typing import Optional
1014

1115
import requests
16+
import github
17+
import github.PullRequest
1218

1319
import generate_test_report_lib
1420

1521
PREMERGE_ADVISOR_URL = (
1622
"http://premerge-advisor.premerge-advisor.svc.cluster.local:5000/explain"
1723
)
24+
COMMENT_TAG = "<!--PREMERGE ADVISOR COMMENT: {platform}-->"
25+
26+
27+
def get_comment_id(platform: str, pr: github.PullRequest.PullRequest) -> Optional[int]:
28+
platform_comment_tag = COMMENT_TAG.format(platform=platform)
29+
for comment in pr.as_issue().get_comments():
30+
if platform_comment_tag in comment.body:
31+
return comment.id
32+
return None
33+
34+
35+
def get_comment(
36+
github_token: str,
37+
pr_number: int,
38+
body: str,
39+
) -> dict[str, str]:
40+
repo = github.Github(github_token).get_repo("llvm/llvm-project")
41+
pr = repo.get_issue(pr_number).as_pull_request()
42+
comment = {"body": body}
43+
comment_id = get_comment_id(platform.system(), pr)
44+
if comment_id:
45+
comment["id"] = comment_id
46+
return comment
1847

1948

20-
def main(commit_sha: str, build_log_files: list[str]):
49+
def main(
50+
commit_sha: str,
51+
build_log_files: list[str],
52+
github_token: str,
53+
pr_number: int,
54+
return_code: int,
55+
):
56+
"""The main entrypoint for the script.
57+
58+
This function parses failures from files, requests information from the
59+
premerge advisor, and may write a Github comment depending upon the output.
60+
There are four different scenarios:
61+
1. There has never been a previous failure and the job passes - We do not
62+
create a comment. We write out an empty file to the comment path so the
63+
issue-write workflow knows not to create anything.
64+
2. There has never been a previous failure and the job fails - We create a
65+
new comment containing the failure information and any possible premerge
66+
advisor findings.
67+
3. There has been a previous failure and the job passes - We update the
68+
existing comment by passing its ID and a passed message to the
69+
issue-write workflow.
70+
4. There has been a previous failure and the job fails - We update the
71+
existing comment in the same manner as above, but generate the comment
72+
as if we have a failure.
73+
74+
Args:
75+
commit_sha: The base commit SHA for this PR run.
76+
build_log_files: The list of JUnit XML files and ninja logs.
77+
github_token: The token to use to access the Github API.
78+
pr_number: The number of the PR associated with this run.
79+
return_code: The numerical return code of ninja/CMake.
80+
"""
81+
if return_code == 0:
82+
with open("comment", "w") as comment_file_handle:
83+
comment = get_comment(
84+
github_token,
85+
pr_number,
86+
":white_check_mark: With the latest revision this PR passed "
87+
"the premerge checks.",
88+
)
89+
if "id" in comment:
90+
json.dump([comment], comment_file_handle)
2191
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
2292
build_log_files
2393
)
@@ -45,13 +115,31 @@ def main(commit_sha: str, build_log_files: list[str]):
45115
)
46116
if advisor_response.status_code == 200:
47117
print(advisor_response.json())
118+
comments = [
119+
get_comment(
120+
github_token,
121+
pr_number,
122+
generate_test_report_lib.generate_report(
123+
generate_test_report_lib.compute_platform_title(),
124+
return_code,
125+
junit_objects,
126+
ninja_logs,
127+
failure_explanations_list=advisor_response.json(),
128+
),
129+
)
130+
]
131+
with open("comment", "w") as comment_file_handle:
132+
json.dump(comments, comment_file_handle)
48133
else:
49134
print(advisor_response.reason)
50135

51136

52137
if __name__ == "__main__":
53138
parser = argparse.ArgumentParser()
54139
parser.add_argument("commit_sha", help="The base commit SHA for the test.")
140+
parser.add_argument("return_code", help="The build's return code", type=int)
141+
parser.add_argument("github_token", help="Github authentication token", type=str)
142+
parser.add_argument("pr_number", help="The PR number", type=int)
55143
parser.add_argument(
56144
"build_log_files", help="Paths to JUnit report files and ninja logs.", nargs="*"
57145
)
@@ -62,4 +150,10 @@ def main(commit_sha: str, build_log_files: list[str]):
62150
if platform.machine() == "arm64":
63151
sys.exit(0)
64152

65-
main(args.commit_sha, args.build_log_files)
153+
main(
154+
args.commit_sha,
155+
args.build_log_files,
156+
args.github_token,
157+
args.pr_number,
158+
args.return_code,
159+
)

.ci/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
junitparser==3.2.0
22
google-cloud-storage==3.3.0
3+
PyGithub==2.8.1

.ci/utils.sh

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,18 @@ function at-exit {
3333
# If building fails there will be no results files.
3434
shopt -s nullglob
3535

36-
if [[ "$GITHUB_STEP_SUMMARY" != "" ]]; then
36+
if [[ "$GITHUB_ACTIONS" != "" ]]; then
3737
python "${MONOREPO_ROOT}"/.ci/generate_test_report_github.py \
3838
$retcode "${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log \
3939
>> $GITHUB_STEP_SUMMARY
40+
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_explain.py \
41+
$(git rev-parse HEAD~1) $retcode "${GITHUB_TOKEN}" \
42+
$GITHUB_PR_NUMBER "${BUILD_DIR}"/test-results.*.xml \
43+
"${MONOREPO_ROOT}"/ninja*.log
4044
fi
4145

4246
if [[ "$retcode" != "0" ]]; then
4347
if [[ "$GITHUB_ACTIONS" != "" ]]; then
44-
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_explain.py \
45-
$(git rev-parse HEAD~1) "${BUILD_DIR}"/test-results.*.xml \
46-
"${MONOREPO_ROOT}"/ninja*.log
4748
python "${MONOREPO_ROOT}"/.ci/premerge_advisor_upload.py \
4849
$(git rev-parse HEAD~1) $GITHUB_RUN_NUMBER \
4950
"${BUILD_DIR}"/test-results.*.xml "${MONOREPO_ROOT}"/ninja*.log

.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
HeaderFilterRegex: ''
12
Checks: >
23
-*,
34
clang-diagnostic-*,
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Build Container
2+
description: >-
3+
Build and test a container using the standard llvm naming scheme for containers.
4+
5+
inputs:
6+
tag:
7+
description: >-
8+
The tag to use for this container.
9+
required: false
10+
container-name:
11+
description: >-
12+
The name for the container.
13+
required: true
14+
dockerfile:
15+
description: >-
16+
Path to docker file.
17+
required: false
18+
target:
19+
description: >-
20+
The container target to build 'passed to podman via ---target option'
21+
required: false
22+
context:
23+
description: >-
24+
Path to context for the container build.
25+
required: false
26+
test-command:
27+
description: >-
28+
Test command to run to ensure the container is working correctly.
29+
required: false
30+
31+
runs:
32+
using: "composite"
33+
steps:
34+
# podman is not installed by default on the ARM64 images.
35+
- name: Install Podman
36+
if: runner.arch == 'ARM64'
37+
shell: bash
38+
run: |
39+
sudo apt-get install podman
40+
41+
- name: Build Container
42+
shell: bash
43+
env:
44+
INPUT_TAG: ${{inputs.tag }}
45+
INPUT_CONTAINER_NAME: ${{ inputs.container-name }}
46+
INPUT_TARGET: ${{ inputs.target }}
47+
INPUT_DOCKERFILE: ${{ inputs.dockerfile }}
48+
INPUT_CONTEXT: ${{ inputs.context }}
49+
id: build
50+
run: |
51+
env
52+
tag="${INPUT_TAG:-$(git rev-parse --short=12 HEAD)}"
53+
54+
case "$RUNNER_ARCH" in
55+
ARM64)
56+
container_arch="arm64v8"
57+
;;
58+
*)
59+
container_arch="amd64"
60+
;;
61+
esac
62+
63+
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/$container_arch/$INPUT_CONTAINER_NAME:$tag"
64+
container_filename="$(echo $container_name | sed -e 's/\//-/g' -e 's/:/-/g').tar"
65+
if [ -n "$INPUT_TARGET" ]; then
66+
podman_options="$podman_options --target $INPUT_TARGET"
67+
fi
68+
if [ -n "$INPUT_DOCKERFILE" ]; then
69+
podman_options="$podman_options -f $INPUT_DOCKERFILE"
70+
fi
71+
podman_options="$podman_options ${INPUT_CONTEXT:-.}"
72+
echo "Podman Options: $podman_options"
73+
74+
podman build -t $container_name $podman_options
75+
76+
podman save $container_name > $container_filename
77+
78+
echo "container-full-name=$container_name" >> $GITHUB_OUTPUT
79+
80+
- name: Create container artifact
81+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
82+
with:
83+
name: ${{ inputs.container-name }}-${{ runner.arch }}
84+
path: "*.tar"
85+
retention-days: 14
86+
87+
- name: Test container
88+
shell: bash
89+
if: inputs.test-command
90+
env:
91+
INPUT_TEST_COMMAND: ${{ inputs.test-command }}
92+
CONTAINER_FULL_NAME: ${{ steps.build.outputs.container-full-name }}
93+
run: |
94+
podman run --pull=never --rm -it $CONTAINER_FULL_NAME /usr/bin/bash -x -c "$INPUT_TEST_COMMAND"
95+
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: Push Container
2+
description: >-
3+
Download all container artifacts for this job and push them to the GitHub registry.
4+
5+
inputs:
6+
token:
7+
description: >-
8+
Token to use to authenticate with the container registry.
9+
required: true
10+
11+
runs:
12+
using: "composite"
13+
steps:
14+
- name: Download container
15+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
16+
17+
- name: Push Container
18+
env:
19+
GITHUB_TOKEN: ${{ inputs.token }}
20+
shell: bash
21+
run: |
22+
function push_container {
23+
image_name=$1
24+
latest_name=$(echo $image_name | sed 's/:[a-f0-9]\+$/:latest/g')
25+
podman tag $image_name $latest_name
26+
echo "Pushing $image_name ..."
27+
podman push --compression-format=zstd $image_name
28+
echo "Pushing $latest_name ..."
29+
podman push --compression-format=zstd $latest_name
30+
}
31+
32+
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
33+
for f in $(find . -iname '*.tar'); do
34+
image_name=$(podman load -q -i $f | sed 's/Loaded image: //g')
35+
push_container $image_name
36+
37+
if echo $image_name | grep '/amd64/'; then
38+
# For amd64, create an alias with the arch component removed.
39+
# This matches the convention used on dockerhub.
40+
default_image_name=$(echo $(dirname $(dirname $image_name))/$(basename $image_name))
41+
podman tag $image_name $default_image_name
42+
push_container $default_image_name
43+
fi
44+
done

.github/workflows/bazel-checks.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,26 @@ jobs:
3030
- name: Run Buildifier
3131
run: |
3232
buildifier --mode=check $(find ./utils/bazel -name *BUILD*)
33+
34+
bazel-build:
35+
name: "Bazel Build/Test"
36+
runs-on: llvm-premerge-linux-runners
37+
if: github.repository == 'llvm/llvm-project'
38+
steps:
39+
- name: Fetch LLVM sources
40+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
41+
# TODO(boomanaiden154): We should use a purpose built container for this. Move
42+
# over when we have fixed the issues with using custom containers with Github
43+
# ARC in GKE.
44+
- name: Setup System Dependencies
45+
run: |
46+
sudo apt-get update
47+
sudo apt-get install -y libmpfr-dev libpfm4-dev
48+
sudo curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.27.0/bazelisk-amd64.deb > /tmp/bazelisk.deb
49+
sudo apt-get install -y /tmp/bazelisk.deb
50+
rm /tmp/bazelisk.deb
51+
- name: Build/Test
52+
working-directory: utils/bazel
53+
run: |
54+
bazelisk test --config=ci --sandbox_base="" \
55+
@llvm-project//llvm/unittests:adt_tests

0 commit comments

Comments
 (0)