Skip to content

Commit e764e19

Browse files
[Github] Remove separate tools checkout from pr-code workflows (#159967)
These separate checkouts I believe were originally carried over from when we were using pull_request_target. We needed two checkouts to ensure we were not executing user supplied code. We kept them to ensure we were using the latest version of the tools, but this was born mostly out of a misunderstanding of how Github Actions works. All PRs directly against main are executed as if merged into main, so already are using the latest version of the tools no matter the branch point. Stacked PRs still need to be rebased for changes to propagate but these files have been pretty stable for the past two years or so and I can't imagine any changes needed to keep things running on release/stacked PR branches.
1 parent 290f5b5 commit e764e19

File tree

2 files changed

+5
-30
lines changed

2 files changed

+5
-30
lines changed

.github/workflows/pr-code-format.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,6 @@ jobs:
3232
base_sha: 'HEAD~1'
3333
sha: 'HEAD'
3434

35-
# We need to pull the script from the main branch, so that we ensure
36-
# we get the latest version of this script.
37-
- name: Fetch code formatting utils
38-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
39-
with:
40-
repository: ${{ github.repository }}
41-
ref: ${{ github.base_ref }}
42-
sparse-checkout: |
43-
llvm/utils/git/requirements_formatting.txt
44-
llvm/utils/git/code-format-helper.py
45-
sparse-checkout-cone-mode: false
46-
path: code-format-tools
47-
4835
- name: "Listed files"
4936
env:
5037
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
@@ -65,10 +52,10 @@ jobs:
6552
with:
6653
python-version: '3.11'
6754
cache: 'pip'
68-
cache-dependency-path: 'code-format-tools/llvm/utils/git/requirements_formatting.txt'
55+
cache-dependency-path: 'llvm/utils/git/requirements_formatting.txt'
6956

7057
- name: Install python dependencies
71-
run: pip install -r code-format-tools/llvm/utils/git/requirements_formatting.txt
58+
run: pip install -r llvm/utils/git/requirements_formatting.txt
7259

7360
- name: Run code formatter
7461
env:
@@ -77,7 +64,7 @@ jobs:
7764
# Create an empty comments file so the pr-write job doesn't fail.
7865
run: |
7966
echo "[]" > comments &&
80-
python ./code-format-tools/llvm/utils/git/code-format-helper.py \
67+
python ./llvm/utils/git/code-format-helper.py \
8168
--write-comment-to-file \
8269
--token ${{ secrets.GITHUB_TOKEN }} \
8370
--issue-number $GITHUB_PR_NUMBER \

.github/workflows/pr-code-lint.yml

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ jobs:
4646
run: |
4747
echo "Changed files:"
4848
echo "$CHANGED_FILES"
49-
50-
- name: Fetch code linting utils
51-
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
52-
with:
53-
repository: ${{ github.repository }}
54-
ref: ${{ github.base_ref }}
55-
sparse-checkout: |
56-
llvm/utils/git/code-lint-helper.py
57-
llvm/utils/git/requirements_linting.txt
58-
clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
59-
sparse-checkout-cone-mode: false
60-
path: code-lint-tools
6149
6250
- name: Install clang-tidy
6351
uses: aminya/setup-cpp@17c11551771948abc5752bbf3183482567c7caf0 # v1.1.1
@@ -70,7 +58,7 @@ jobs:
7058
python-version: '3.12'
7159

7260
- name: Install Python dependencies
73-
run: python3 -m pip install -r code-lint-tools/llvm/utils/git/requirements_linting.txt
61+
run: python3 -m pip install -r llvm/utils/git/requirements_linting.txt
7462

7563
# TODO: create special mapping for 'codegen' targets, for now build predefined set
7664
# TODO: add entrypoint in 'compute_projects.py' that only adds a project and its direct dependencies
@@ -107,7 +95,7 @@ jobs:
10795
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
10896
run: |
10997
echo "[]" > comments &&
110-
python3 ./code-lint-tools/llvm/utils/git/code-lint-helper.py \
98+
python3 llvm/utils/git/code-lint-helper.py \
11199
--token ${{ secrets.GITHUB_TOKEN }} \
112100
--issue-number $GITHUB_PR_NUMBER \
113101
--start-rev HEAD~1 \

0 commit comments

Comments
 (0)