Skip to content

Commit 9f890a9

Browse files
suofacebook-github-bot
authored andcommitted
make sure clang-tidy is diffing against the right thing (#28788)
Summary: Pull Request resolved: #28788 Okay, my last fix was wrong because it turns out that the base SHA is computed at PR time using the actual repo's view of the base ref, not the user's. So if the user doesn't rebase on top of the latest master before putting up the PR, the diff thing is wrong anyway. This PR fixes the issue by not relying on any of these API details and just getting the merge-base of the base and head refs, which should guarantee we are diffing against the right thing. This solution taken from github/VisualStudio#1008 Test Plan: Imported from OSS Differential Revision: D18172391 Pulled By: suo fbshipit-source-id: 491a50119194508b2eefa5bd39fe813ca85f27b1
1 parent 5804e54 commit 9f890a9

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

.github/workflows/lint.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,10 @@ jobs:
209209
run: |
210210
set -eux
211211
git remote add upstream https://github.com/pytorch/pytorch
212-
git fetch upstream "${{ github.base_ref}}"
212+
git fetch upstream "$GITHUB_BASE_REF"
213+
BASE_SHA=${{ github.event.pull_request.base.sha }}
214+
HEAD_SHA=${{ github.event.pull_request.head.sha }}
215+
MERGE_BASE=$(git merge-base $BASE_SHA $HEAD_SHA)
213216
214217
if [[ ! -d build ]]; then
215218
git submodule update --init --recursive
@@ -238,8 +241,9 @@ jobs:
238241
# The negative filters below are to exclude files that include onnx_pb.h or
239242
# caffe2_pb.h, otherwise we'd have to build protos as part of this CI job.
240243
python tools/clang_tidy.py \
244+
--verbose \
241245
--paths torch/csrc/ \
242-
--diff "${{ github.event.pull_request.base.sha}}" \
246+
--diff "$MERGE_BASE" \
243247
-g"-torch/csrc/jit/export.cpp" \
244248
-g"-torch/csrc/jit/import.cpp" \
245249
-g"-torch/csrc/jit/netdef_converter.cpp" \
@@ -252,6 +256,6 @@ jobs:
252256
check_name: 'clang-tidy'
253257
linter_output_path: 'clang-tidy-output.txt'
254258
commit_sha: ${{ steps.get_pr_tip.outputs.commit_sha }}
255-
regex: '^(?<filename>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+): (?<errorDesc>.*?) (?<errorCode>\[.*\])'
259+
regex: '^(?<filename>.*?):(?<lineNumber>\d+):(?<columnNumber>\d+): (?<errorDesc>.*?) \[(?<errorCode>.*)\]'
256260
env:
257261
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)