Skip to content

Commit

Permalink
Pre commit (#23)
Browse files Browse the repository at this point in the history
* Adding the pre-commit hook

* Removing adding README.md back to pre-commit

* Adding pre-commit to Rbuildignore

* Adding pre-commit as dependency

* Passing Rscript differently

* Get to get the library

* Setting up R in pre-commit

* Setting up where to install the package and from where

* Both can only be used in mac and windows

* Adding jammy to the repo

* Removing dangling pre-commit file

* Setting no cache root

* Reverting root cache pre-commit

* Running pre-commit alternatively

* Update pre-commit.yaml

* Correct hooks

* Forgot to install it:

* Dealing with styler

* Revising how to deal with pre-commit

* Forcing the R version to be 4.4.1 in precommit R

* Adding some contextual information

* Reverting how pre-commit works

* Adding pre-commit Renv

* Need a cache-root maybe
  • Loading branch information
gvegayon authored Oct 7, 2024
1 parent fd77145 commit b9a29fc
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 25 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ README\.html

# Adding gitattributes
\.gitattributes
\.pre-commit-config.yaml

paper\..+
docker
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/pre-commit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ on:

jobs:
pre-commit:

name: Pre-commit

runs-on: ubuntu-latest

steps:
Expand All @@ -19,5 +22,18 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v3

- name: Cache R packages for pre-commit (live in renv)
uses: actions/cache@v4
with:
path: |
~/.cache/R/renv
key: r-precommit-cache|${{ env.pythonLocation }}|${{ hashFiles('.pre-commit-config.yaml') }}

# 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: Run pre-commit hooks
uses: pre-commit/action@v3.0.1
7 changes: 5 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ repos:
exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)

- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.2
# This version of precommit uses R 4.4.1 (renv.lock)
# See the pre-commit.yaml workflow file for more details.
rev: v0.4.3
hooks:
- id: style-files
args:
[
'--ignore-start="^# styler: off$"',
'--ignore-stop="^# styler: on$"',
'--strict=FALSE'
'--strict=FALSE',
'--cache-root=styler-perm'
]
exclude: ^(inst/|man/|src/cpp11.cpp|playgroud/|R/cpp11.R)
- id: readme-rmd-rendered
Expand Down
23 changes: 0 additions & 23 deletions pre-commit.yaml

This file was deleted.

0 comments on commit b9a29fc

Please sign in to comment.