Skip to content

Commit 01c7419

Browse files
committed
Merge remote-tracking branch 'origin/main' into perry/pragma-export-only
2 parents 8582eef + 1e467e4 commit 01c7419

File tree

1,029 files changed

+54173
-33174
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,029 files changed

+54173
-33174
lines changed

.ci/all_requirements.txt

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

.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-*,

.github/workflows/bazel-checks.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,6 @@ jobs:
5252
working-directory: utils/bazel
5353
run: |
5454
bazelisk test --config=ci --sandbox_base="" \
55+
--remote_cache=https://storage.googleapis.com/$CACHE_GCS_BUCKET-bazel \
56+
--google_default_credentials \
5557
@llvm-project//llvm/unittests:adt_tests

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ RUN apt-get update && \
108108
abi-compliance-checker \
109109
abi-dumper \
110110
autoconf \
111+
parallel \
111112
pkg-config && \
112113
apt-get clean && \
113114
rm -rf /var/lib/apt/lists/*

.github/workflows/llvm-abi-tests.yml

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ on:
1010
- 'release/**'
1111
paths:
1212
- 'llvm/**'
13-
- '.github/workflows/llvm-tests.yml'
13+
- '.github/workflows/llvm-abi-tests.yml'
1414
pull_request:
1515
branches:
1616
- 'release/**'
1717
paths:
1818
- 'llvm/**'
19-
- '.github/workflows/llvm-tests.yml'
19+
- '.github/workflows/llvm-abi-tests.yml'
2020

2121
concurrency:
2222
# Skip intermediate builds: always.
@@ -72,6 +72,8 @@ jobs:
7272
if: github.repository_owner == 'llvm'
7373
needs: abi-dump-setup
7474
runs-on: ubuntu-24.04
75+
container:
76+
image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:01e66b0847c1e9c88f0bd0492ed7c3374550a0730b48040f63888393f1ff6c13" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:bb0bd382ab2b"
7577
strategy:
7678
matrix:
7779
name:
@@ -87,19 +89,6 @@ jobs:
8789
ref: ${{ github.sha }}
8890
repo: ${{ github.repository }}
8991
steps:
90-
- name: Install Ninja
91-
uses: llvm/actions/install-ninja@42d80571b13f4599bbefbc7189728b64723c7f78 # main
92-
- name: Install abi-compliance-checker
93-
run: |
94-
sudo apt-get update
95-
sudo apt-get -y install abi-dumper autoconf pkg-config
96-
- name: Install universal-ctags
97-
run: |
98-
git clone https://github.com/universal-ctags/ctags.git
99-
cd ctags
100-
./autogen.sh
101-
./configure
102-
sudo make install
10392
- name: Download source code
10493
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
10594
with:
@@ -143,6 +132,8 @@ jobs:
143132
abi-compare:
144133
if: github.repository_owner == 'llvm'
145134
runs-on: ubuntu-24.04
135+
container:
136+
image: "ghcr.io/llvm/ci-ubuntu-24.04-abi-tests@sha256:01e66b0847c1e9c88f0bd0492ed7c3374550a0730b48040f63888393f1ff6c13" #ghcr.io/llvm/ci-ubuntu-24.04-abi-tests:bb0bd382ab2b
146137
needs:
147138
- abi-dump-setup
148139
- abi-dump
@@ -163,10 +154,6 @@ jobs:
163154
name: symbol-list
164155
path: symbol-list
165156

166-
- name: Install abi-compliance-checker
167-
run: |
168-
sudo apt-get update
169-
sudo apt-get -y install abi-compliance-checker
170157
- name: Compare ABI
171158
run: |
172159
if [ -s symbol-list/llvm.symbols ]; then

.github/workflows/premerge.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ jobs:
6464
- name: Build and Test
6565
timeout-minutes: 120
6666
continue-on-error: ${{ runner.arch == 'ARM64' }}
67+
env:
68+
GITHUB_TOKEN: ${{ github.token }}
69+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
6770
run: |
6871
git config --global --add safe.directory '*'
6972
@@ -153,6 +156,9 @@ jobs:
153156
timeout-minutes: 180
154157
if: ${{ steps.vars.outputs.windows-projects != '' }}
155158
shell: cmd
159+
env:
160+
GITHUB_TOKEN: ${{ github.token }}
161+
GITHUB_PR_NUMBER: ${{ github.event.pull_request.number }}
156162
run: |
157163
call C:\\BuildTools\\Common7\\Tools\\VsDevCmd.bat -arch=amd64 -host_arch=amd64
158164
# See the comments above in the Linux job for why we define each of
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Test Unprivileged Download Artifact Action
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- .github/workflows/test-unprivileged-download-artifact.yml
12+
- '.github/workflows/unprivileged-download-artifact/**'
13+
pull_request:
14+
paths:
15+
- .github/workflows/test-unprivileged-download-artifact.yml
16+
- '.github/workflows/unprivileged-download-artifact/**'
17+
18+
jobs:
19+
upload-test-artifact:
20+
name: Upload Test Artifact
21+
if: github.repository_owner == 'llvm'
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- name: Create Test File
25+
run: |
26+
echo "test" > comment
27+
- name: Upload Test File
28+
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
29+
with:
30+
name: workflow-args
31+
path: |
32+
comment
33+
34+
test-download:
35+
name: Test Unprivileged Download Artifact
36+
if: github.repository_owner == 'llvm'
37+
runs-on: ubuntu-24.04
38+
needs: [ upload-test-artifact ]
39+
steps:
40+
- name: Chekcout LLVM
41+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
42+
with:
43+
sparse-checkout: |
44+
.github/workflows/unprivileged-download-artifact/action.yml
45+
- name: Download Artifact
46+
uses: ./.github/workflows/unprivileged-download-artifact
47+
id: download-artifact
48+
with:
49+
run-id: ${{ github.run_id }}
50+
artifact-name: workflow-args
51+
- name: Assert That Contents are the Same
52+
run: |
53+
cat comment
54+
[[ "$(cat comment)" == "test" ]]

0 commit comments

Comments
 (0)