Skip to content

Commit

Permalink
check pre-commit code checks and formatters via precommit-ci-lite bot
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-baumann committed Sep 12, 2024
1 parent a0367da commit 108b61b
Show file tree
Hide file tree
Showing 2 changed files with 180 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/format-code.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check code
on:
pull_request:
branches: [main]

permissions:
contents: write
pull-requests: write

jobs:
main:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.x
- uses: pre-commit/[email protected]
- uses: pre-commit-ci/[email protected]
name: pre-commit-ci-lite
if: always()
with:
msg: apply code formatting
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
155 changes: 155 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# All available hooks: https://pre-commit.com/hooks.html
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.3
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style, --cache-root=styler-perm]
exclude: >
(?x)^(
tests/testthat/in/.*|
renv/.*
)$
- id: roxygenize
additional_dependencies:
- cli
- fs
- here
- magrittr
- purrr
- R.cache
- rlang
- rprojroot
- rstudioapi
- withr
- yaml
- r-lib/pkgapi
# codemeta must be above use-tidy-description when both are used
# - id: codemeta-description-updated
- id: use-tidy-description
- id: spell-check
exclude: >
(?x)^(
.*\.[rR]|
.*\.feather|
.*\.jpeg|
.*\.pdf|
.*\.png|
.*\.py|
.*\.RData|
.*\.rds|
.*\.Rds|
.*\.Rproj|
.*\.sh|
(.*/|)\.gitignore|
(.*/|)\.pre-commit-.*|
(.*/|)\.Rbuildignore|
(.*/|)\.Renviron|
(.*/|)\.Rprofile|
(.*/|)\.travis\.yml|
(.*/|)appveyor\.yml|
(.*/|)NAMESPACE|
(.*/|)renv/settings\.dcf|
(.*/|)renv\.lock|
(.*/|)WORDLIST|
\.github/workflows/.*|
LICENSE|
revdep/.*|
tests/testthat/in/.*|
)$
- id: readme-rmd-rendered
- id: parsable-R
exclude: >
(?x)^(
tests/testthat/in/.*|
)$
- id: no-browser-statement
exclude: >
(?x)^(
tests/testthat/in/.*|
)$
- id: no-debug-statement
exclude: >
(?x)^(
tests/testthat/in/.*|
)$
- id: deps-in-desc
- id: pkgdown
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: end-of-file-fixer
exclude: '\.Rd' # sometimes roxygen fails to generate EOF blank line.
- id: file-contents-sorter
files: '^\.Rbuildignore$'
- repo: https://github.com/pre-commit-ci/pre-commit-ci-config
rev: v1.6.1
hooks:
# Only required when https://pre-commit.ci is used for config validation
- id: check-pre-commit-ci-config
- repo: https://github.com/lorenzwalthert/gitignore-tidy
rev: 0.1.2
hooks:
- id: tidy-gitignore
- repo: local
hooks:
- id: consistent-release-tag
name: consistent-release-tag
entry: Rscript inst/hooks/local/consistent-release-tag.R
language: r
additional_dependencies:
- docopt
- fs
- yaml
- purrr
- glue
- rlang
- git2r
- desc
- lorenzwalthert/precommit
stages: [commit, push]
- id: hooks-config-to-inst
name: hooks-config-to-inst
entry: Rscript inst/hooks/local/hooks-config-to-inst.R
language: r
stages: [commit, push]
additional_dependencies:
- fs
require_serial: True
- id: spell-check-exclude-identical
name: spell-check-exclude-identical
entry: Rscript inst/hooks/local/spell-check-exclude-identical.R
language: r
stages: [commit, push]
additional_dependencies:
- magrittr
- purrr
- yaml
- here
- rlang
require_serial: True
- id: forbid-to-commit
name: Don't commit common R artifacts
entry: Cannot commit .Rhistory, .Rdata, .csv and similar.
language: fail
files: '\.(Rhistory|csv|RData|Rds|rds)$'
# `exclude: <regex>` to allow committing specific files.
- id: spell-check-ordered-exclude
name: Ordered regex pattern for spell-check exclusion
description: Ensure alphabetical order in `exclude:` key of spell check.
entry: Rscript inst/hooks/local/spell-check-ordered-exclude.R
language: r
files: '^(.*/|)\.?pre-commit-config.*\.yaml$'
additional_dependencies:
- magrittr
- yaml
- purrr
- rlang

default_stages: ["commit"]

ci:
skip: [consistent-release-tag, spell-check-ordered-exclude, pkgdown]
autoupdate_schedule: monthly

0 comments on commit 108b61b

Please sign in to comment.