fix(ci): improve changed file detection in linter script - #8968
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the linter script to fetch the base branch when running in a GitHub Actions environment and refactors the list of Git references used to determine changed files. The reviewer suggested using an explicit refspec in the git fetch command to ensure the remote-tracking branch is correctly created and updated in shallow-clone CI environments.
a449965 to
2a57889
Compare
|
/gemini |
|
Hello! It looks like you've invoked me to help with this pull request. Since you didn't specify a command, I've provided a summary of your changes below. Pull Request Summary:
|
88c3e97 to
ee44be0
Compare
76b0942 to
480b5d0
Compare
0c3abfe to
fd5e150
Compare
fd5e150 to
3c88044
Compare
15bc305 to
56e9aea
Compare
ba2276d to
21bad2f
Compare
Reverts #8968 until we can get the linter working correctly for handwritten libraries.
Fixes an issue where `./bin/linter.mjs` skipped TypeScript checks in CI pull request workflows because it's incorrectly detecting no TS file changes. Updates linter logic to be hermetic. It looks like the CI was comparing "head" to "head". It was running `git diff FETCH_HEAD -- *.ts`, but we need to fetch from origin before doing that. Previously, the linter was going in order of the `refsToTry` array to check which reference existed in order to diff against it: 1. `main`, `upstream/main`, and `origin/main` failed 2. `'FETCH_HEAD'`, existed and pointed to the checked-out PR commit (`HEAD`). 3. Running `git diff --name-only FETCH_HEAD -- *.ts` compared `HEAD` against itself, which succeeded with an exit code of `0` and returned an empty file list (`""`) Fixes: - Removed git fetch calls so the script relies solely on local Git history provided by actions/checkout. - Added `STRICT` mode to ./bin/linter.mjs, configured in presubmit.yaml - Uses git merge-base to accurately identify changed files when both main and the branch have moved. - Fails explicitly in CI if GITHUB_BASE_REF is missing or invalid, or if the GIT_DIFF_ARG is missing in STRICT mode - Streamlined reference resolution for local development and added logging for the chosen base reference.
Reverts #8968 until we can get the linter working correctly for handwritten libraries.
Fixes an issue where
./bin/linter.mjsskipped TypeScript checks in CI pull request workflows because it's incorrectly detecting no TS file changes. Updates linter logic to be hermetic.It looks like the CI was comparing "head" to "head". It was running
git diff FETCH_HEAD -- *.ts, but we need to fetch from origin before doing that. Previously, the linter was going in order of therefsToTryarray to check which reference existed in order to diff against it:main,upstream/main, andorigin/mainfailed'FETCH_HEAD', existed and pointed to the checked-out PR commit (HEAD).git diff --name-only FETCH_HEAD -- *.tscomparedHEADagainst itself, which succeeded with an exit code of0and returned an empty file list ("")Fixes:
STRICTmode to ./bin/linter.mjs, configured in presubmit.yaml