Make pre-commit super fast via caching + avoiding updating miniconda #1153
+21
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
pre-commit spends most of its time setting up the hooks (=cloning their repos and installing each hook into its own virtual env).
Caching helps to give faster feedback (~30 secs vs 73 secs before) on new PRs. And it protects against rate limit issues in situations of many fast PR updates as every hook is a repo that is cloned. The cache invalidates when the python version, pre-commit version or pre-commit config changes.
Also avoiding the setup-miniconda action as that anyways uses the miniconda already present on the runners to save time.
Also adding black hook to pre-commit and limit to buildscripts.
Note: This uses https://github.com/psf/black-pre-commit-mirror and not https://github.com/psf/black to avoid cloning the entire black repo (=faster).