paths-filter icon indicating copy to clipboard operation
paths-filter copied to clipboard

Compare base and ref when token is empty

Open frouioui opened this issue 3 years ago • 1 comments

Description

After we started using paths-filter on all our +80 workflows, we quickly saw API rate limit errors. The exact issue is detailed in both #108 and #73. In our case, this issue would arise pretty quickly considering that each workflow uses paths-filter and thus executes at least one API call. The 1000 requests/hour limit can quickly be met after a dozen of commits.

To alleviate this issue, we considered not using the GitHub API at all. In fact, a simple git diff should be sufficient. The documentation says we can set token to an empty string to force the use of the git command. Doing so resulted in paths-filter executing the git command below. That command would return an excessively large number of modified files (even though they were not modified by PR/commit). The screenshot below exhibits this large number of modified files.

git log --format= --no-renames --name-status -z -n 1 

image

This PR fixes this issue by using getChanges instead of getChangesInLastCommit. Turns out that getChanges is more accurate since we can provide a range that starts at the base and ends at the head/current commit.

We started using this fix in https://github.com/vitessio/vitess/pull/10106. The fix seems to have alleviated all of the issues we were previously seeing.

Related Issues

  • https://github.com/dorny/paths-filter/issues/108
  • https://github.com/dorny/paths-filter/issues/73

frouioui avatar Apr 20 '22 07:04 frouioui

Would love to help moving this forward. Any ideas how @dorny? @frouioui?

taschetto avatar Jul 05 '22 20:07 taschetto

@dorny Can this be merged in? Without it we're effectively blocked from using the action on PRs.

astorrs avatar Feb 14 '24 16:02 astorrs

I am happy to fix the conflict @dorny if we're good to merge.

frouioui avatar Feb 14 '24 16:02 frouioui

@astorrs @frouioui Thanks guys, the PR seems reasonable. I'm sorry that I've overlooked it for so long. I will resolve the conflicts and merge the PR tomorrow.

dorny avatar Feb 14 '24 19:02 dorny

Released as v3.0.1

dorny avatar Feb 15 '24 08:02 dorny

Thanks @dorny ! 🙏🏻

frouioui avatar Feb 15 '24 15:02 frouioui