Skip to content

Pre commit

Pre commit #21

Workflow file for this run

name: Pre-commit
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
pre-commit:
name: Pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
- name: Cache pre-commit
uses: actions/cache@v4
id: cache-pre-commit
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('./.pre-commit-config.yaml') }}
- name: Install pre-commit
run: pip install pre-commit
# Notice this step depends on what
# https://github.com/lorenzwalthert/precommit has as
# R version in renv.lock. GHA ubuntu-latest runner comes
# with R 4.4.1, which is the same as in renv.lock. If that
# changes, caching will not work as it will be loading a
# different version of R.
- name: Setup pre-commit
if: steps.cache-pre-commit.outputs.cache-hit != 'true'
run: |
pre-commit install --install-hooks
shell: bash
- name: Run pre-commit hooks
run: pre-commit run --all-files