Make pre-commit super fast via caching + avoiding updating miniconda #6
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: lint with pre-commit | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
tags: | |
- '*' | |
jobs: | |
pre-commit: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install pre-commit | |
run: | | |
source "${CONDA}/etc/profile.d/conda.sh" | |
conda install -c conda-forge pre-commit | |
echo "versions='$(python --version)-$(pre-commit --version)'" >> $GITHUB_ENV | |
# inspired by https://github.com/pre-commit/action/blob/main/action.yml | |
- uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pre-commit | |
key: pre-commit|${{ env.versions }}|${{ hashFiles('.pre-commit-config.yaml') }} | |
- name: Lint code with pre-commit | |
run: | | |
source "${CONDA}/etc/profile.d/conda.sh" | |
conda run pre-commit run --verbose --all-files --show-diff-on-failure --color=always |