Skip to content

Commit 8df7449

Browse files
authored
Pull format checking tools from main (#7403)
This updates the clang-format-checker action workflow to pull the format checker and tools from `main` instead of from the PR. Note: This PR basically can't be tested pre-merge since the pre-merge check will use the version of the action in `main`.
1 parent 556fc5b commit 8df7449

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

.github/workflows/clang-format-checker.yml

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
permissions:
1313
pull-requests: write
1414
steps:
15-
- name: Fetch LLVM sources
15+
- name: Fetch DirectXShaderCompiler sources
1616
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1717
with:
1818
ref: ${{ github.event.pull_request.head.sha }}
@@ -31,6 +31,20 @@ jobs:
3131
separator: ","
3232
skip_initial_fetch: true
3333

34+
# We need to pull the script from the main branch, so that we ensure
35+
# we get the latest version of this script.
36+
- name: Fetch code formatting utils
37+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
38+
with:
39+
repository: microsoft/DirectXShaderCompiler
40+
ref: ${{ github.base_ref }}
41+
sparse-checkout: |
42+
utils/git/requirements_formatting.txt
43+
utils/git/code-format-helper.py
44+
utils/git/code-format-save-diff.py
45+
sparse-checkout-cone-mode: false
46+
path: code-format-tools
47+
3448
- name: "Listed files"
3549
env:
3650
LISTED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
@@ -48,10 +62,10 @@ jobs:
4862
with:
4963
python-version: '3.11'
5064
cache: 'pip'
51-
cache-dependency-path: 'utils/git/requirements_formatting.txt'
65+
cache-dependency-path: 'code-format-tools/utils/git/requirements_formatting.txt'
5266

5367
- name: Install python dependencies
54-
run: pip install -r utils/git/requirements_formatting.txt
68+
run: pip install -r code-format-tools/utils/git/requirements_formatting.txt
5569

5670
- name: Run code formatter
5771
id: formatter
@@ -61,7 +75,7 @@ jobs:
6175
END_REV: ${{ github.event.pull_request.head.sha }}
6276
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
6377
run: |
64-
python utils/git/code-format-helper.py \
78+
python code-format-tools/utils/git/code-format-helper.py \
6579
--token ${{ secrets.GITHUB_TOKEN }} \
6680
--issue-number $GITHUB_PR_NUMBER \
6781
--start-rev $START_REV \
@@ -92,28 +106,37 @@ jobs:
92106
} catch (err) {
93107
core.setFailed(`Request failed with error ${err}`)
94108
}
95-
- name: Fetch LLVM sources
96-
uses: actions/checkout@v4
109+
110+
# We need to pull the script from the main branch, so that we ensure
111+
# we get the latest version of this script.
112+
- name: Fetch code formatting utils
113+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
97114
with:
98-
fetch-depth: 2
99-
path: build/main_src
115+
repository: microsoft/DirectXShaderCompiler
116+
ref: ${{ github.base_ref }}
117+
sparse-checkout: |
118+
utils/git/requirements_formatting.txt
119+
utils/git/code-format-helper.py
120+
utils/git/code-format-save-diff.py
121+
sparse-checkout-cone-mode: false
122+
path: code-format-tools
100123

101124
- name: Setup Python env
102125
uses: actions/setup-python@v4
103126
with:
104127
python-version: '3.11'
105128
cache: 'pip'
106-
cache-dependency-path: 'build/main_src/utils/git/requirements_formatting.txt'
129+
cache-dependency-path: 'code-format-tools/utils/git/requirements_formatting.txt'
107130

108131
- name: Install python dependencies
109-
run: pip install -r build/main_src/utils/git/requirements_formatting.txt
132+
run: pip install -r code-format-tools/utils/git/requirements_formatting.txt
110133

111134
- name: Apply code diff
112135
env:
113136
GITHUB_PR_NUMBER: ${{ github.event.issue.number }}
114137
COMMENT_ID: ${{ github.event.comment.id }}
115138
run: |
116-
python build/main_src/utils/git/code-format-save-diff.py \
139+
python code-format-tools/utils/git/code-format-save-diff.py \
117140
--token ${{ secrets.GITHUB_TOKEN }} \
118141
--issue-number $GITHUB_PR_NUMBER \
119142
--tmp-diff-file $TMP_DIFF_FILE \

0 commit comments

Comments
 (0)