zendesk / setup-check-codeowners

A script to check .github/CODEOWNERS, and a GitHub Action to install it
MIT License
1 stars 2 forks source link

Avoid having to call `git` for matching if possible #31

Closed zdrve closed 1 year ago

zdrve commented 1 year ago

tbh I thought that the code already did this. Turns out I'd just thought about it, not implemented it.

Pre-PR, the tool uses the slow but thorough approach of calling git ls-files for each individual pattern to find which files match that pattern. Thus the runtime scales with the number of CODEOWNERS lines. Zendesk help-center currently has > 1000 lines of CODEOWNERS, which means > 1000 calls to git ls-files, which makes this tool slow (> 10 seconds runtime).

For the more complex patterns (e.g. those involving *), calling git ls-files is a reasonable approach. But for some patterns – the vast majority of help-center's entries – a much simpler, faster approach can be used:

Everything else, we still send to git ls-files for detailed checking.

In help-center this means that the list of calls to git drops by about a factor of 10, and the runtime drops accordingly, down to about 1.7 seconds.

No test changes, since this is a non-functional change.