mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-10 03:28:53 +00:00
fix(ci): scope UI lint to the files a PR actually changed
`UI Lint / frontend-lint` collected its file list from `"$BASE_SHA"...HEAD`, where `BASE_SHA` is the base branch tip captured when the PR was opened and `HEAD` is the merge of the PR into the *current* base tip that actions/checkout leaves behind. The three-dot merge base of those two is `BASE_SHA` itself, so the diff spans every base-branch commit landed since the PR was opened. Any PR opened before an eslint violation landed on the base branch therefore fails on files it never touched. PR #34192 changes two Python files and no UI file at all, and the job still linted 283 dashboard files and failed on three `no-restricted-imports` antd errors from unrelated commits. Diffing the PR head against its own merge base gives exactly the files the PR changed, whether the checkout leaves HEAD on a merge commit or on the head commit.
This commit is contained in:
parent
7b019cf152
commit
bac17a9248
1 changed files with 9 additions and 1 deletions
10
.github/workflows/test-litellm-ui-lint.yml
vendored
10
.github/workflows/test-litellm-ui-lint.yml
vendored
|
|
@ -29,7 +29,15 @@ jobs:
|
|||
id: changed
|
||||
env:
|
||||
BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
||||
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
|
||||
run: |
|
||||
# base.sha is the base branch tip from when the PR was opened, while
|
||||
# actions/checkout leaves HEAD on a merge of the PR into the *current*
|
||||
# base tip. "$BASE_SHA"...HEAD therefore spans every base-branch commit
|
||||
# landed since, so a PR that touches no UI file still gets linted
|
||||
# against hundreds of other people's files. Diff the PR head against its
|
||||
# own merge base instead, which is exactly what this PR changed.
|
||||
merge_base=$(git merge-base "$BASE_SHA" "$HEAD_SHA")
|
||||
: > "$RUNNER_TEMP/prettier_files.txt"
|
||||
: > "$RUNNER_TEMP/eslint_files.txt"
|
||||
while IFS= read -r f; do
|
||||
|
|
@ -41,7 +49,7 @@ jobs:
|
|||
*.json | *.css | *.scss | *.md | *.mdx | *.yml | *.yaml | *.html)
|
||||
printf '%s\n' "$f" >> "$RUNNER_TEMP/prettier_files.txt" ;;
|
||||
esac
|
||||
done < <(git diff --name-only --diff-filter=ACMR --relative "$BASE_SHA"...HEAD -- .)
|
||||
done < <(git diff --name-only --diff-filter=ACMR --relative "$merge_base" "$HEAD_SHA" -- .)
|
||||
if [ -s "$RUNNER_TEMP/prettier_files.txt" ] || [ -s "$RUNNER_TEMP/eslint_files.txt" ]; then
|
||||
echo "has_files=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue