mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
better local command for clang-format check (#37127)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/37127 Wrap what we're running in CI in a small script so we can exactly reproduce it locally if ncessary. Test Plan: Imported from OSS Reviewed By: malfet Differential Revision: D21196804 Pulled By: suo fbshipit-source-id: 45497daae4bafd236a0d1bb1480841f0d9f39262
This commit is contained in:
parent
5a27ec09b8
commit
af08334c63
3 changed files with 22 additions and 12 deletions
21
.github/workflows/clang_format.yml
vendored
21
.github/workflows/clang_format.yml
vendored
|
|
@ -26,23 +26,20 @@ jobs:
|
|||
id: get_pr_tip
|
||||
- name: Run clang-format
|
||||
run: |
|
||||
set -eux
|
||||
set -eu
|
||||
# only run clang-format on whitelisted files
|
||||
find . -type f \
|
||||
-path './torch/csrc/jit/*' -or \
|
||||
-path './test/cpp/jit/*' -or \
|
||||
-path './test/cpp/tensorexpr/*' \
|
||||
| xargs tools/git-clang-format --verbose ${{ github.event.pull_request.base.sha }} --
|
||||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||
echo "| clang-format failures found! Run: "
|
||||
echo "| tools/clang_format_ci.sh ${{ github.event.pull_request.base.sha }} "
|
||||
echo "| to fix this error. "
|
||||
echo "| For more info, see: https://github.com/pytorch/pytorch/wiki/clang-format "
|
||||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||
|
||||
tools/clang_format_ci.sh ${{ github.event.pull_request.base.sha }}
|
||||
|
||||
GIT_DIFF=$(git diff)
|
||||
if [[ -z $GIT_DIFF ]]; then
|
||||
exit 0
|
||||
fi
|
||||
echo $GIT_DIFF
|
||||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||
echo "| Run: "
|
||||
echo "| tools/git-clang-format ${{ github.event.pull_request.base.sha }} "
|
||||
echo "| to fix this error. "
|
||||
echo "| For more info, see: https://github.com/pytorch/pytorch/wiki/clang-format "
|
||||
echo "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
|
||||
exit 1
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ from clang_format_utils import get_and_check_clang_format, CLANG_FORMAT_PATH
|
|||
|
||||
# Whitelist of directories to check. All files that in that directory
|
||||
# (recursively) will be checked.
|
||||
# If you edit this, please edit the whitelist in clang_format_ci.sh as well.
|
||||
CLANG_FORMAT_WHITELIST = ["torch/csrc/jit/", "test/cpp/jit/", "test/cpp/tensorexpr/"]
|
||||
|
||||
# Only files with names matching this regex will be formatted.
|
||||
|
|
|
|||
12
tools/clang_format_ci.sh
Executable file
12
tools/clang_format_ci.sh
Executable file
|
|
@ -0,0 +1,12 @@
|
|||
#!/bin/sh
|
||||
set -eux
|
||||
|
||||
# Runs clang-format on whitelisted files.
|
||||
# Requires a single argument, which is the <commit> argument to git-clang-format
|
||||
|
||||
# If you edit this whitelist, please edit the one in clang_format_all.py as well
|
||||
find . -type f -print0 \
|
||||
-path './torch/csrc/jit/*' -or \
|
||||
-path './test/cpp/jit/*' -or \
|
||||
-path './test/cpp/tensorexpr/*' \
|
||||
| xargs tools/git-clang-format --verbose "$1" --
|
||||
Loading…
Reference in a new issue