-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pre-commit config and associated workflow
- Loading branch information
1 parent
788479f
commit 54a6dd9
Showing
3 changed files
with
110 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
^rmcmc\.Rproj$ | ||
^\.Rproj\.user$ | ||
^.lintr$ | ||
^LICENSE\.md$ | ||
^README\.Rmd$ | ||
^\.Rproj\.user$ | ||
^\.github$ | ||
^\.pre-commit-config\.yaml$ | ||
^_pkgdown\.yml$ | ||
^docs$ | ||
^pkgdown$ | ||
^.lintr$ | ||
^rmcmc\.Rproj$ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
name: pre-commit | ||
on: | ||
push: | ||
branches-ignore: | ||
- 'master' | ||
- 'main' | ||
pull_request: | ||
types: [opened, synchronize, reopened, ready_for_review] | ||
|
||
jobs: | ||
pre-commit: | ||
runs-on: ubuntu-18.04 | ||
if: >- | ||
!contains(github.event.head_commit.message, 'ci skip') && | ||
( | ||
startsWith(github.ref, 'refs/heads') || | ||
github.event.pull_request.draft == false | ||
) | ||
steps: | ||
- name: Cancel Previous Runs | ||
uses: styfle/[email protected] | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Install system dependencies | ||
if: runner.os == 'Linux' | ||
run: | | ||
# your system installation code here | ||
# sudo apt-get install -y libcurl4-openssl-dev | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: "3.8" | ||
architecture: "x64" | ||
- name: Run pre-commit | ||
uses: pre-commit/[email protected] | ||
- name: Commit files | ||
if: failure() && startsWith(github.ref, 'refs/heads') | ||
run: | | ||
if [[ `git status --porcelain --untracked-files=no` ]]; then | ||
git config --local user.email "github-actions[bot]@users.noreply.github.com" | ||
git config --local user.name "github-actions[bot]" | ||
git checkout -- .github/workflows | ||
git commit -m "pre-commit" -a | ||
fi | ||
- name: Push changes | ||
if: failure() && startsWith(github.ref, 'refs/heads') | ||
uses: ad-m/github-push-action@master | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
branch: ${{ github.ref }} | ||
env: | ||
RENV_CONFIG_CACHE_ENABLED: FALSE |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# 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] | ||
- id: roxygenize | ||
# roxygen requires loading pkg -> add dependencies from DESCRIPTION | ||
additional_dependencies: | ||
- Matrix | ||
- rlang | ||
- withr | ||
- id: use-tidy-description | ||
# disable lintr hook pending resolution of | ||
# https://github.com/lorenzwalthert/precommit/issues/440 | ||
# - id: lintr | ||
- id: readme-rmd-rendered | ||
- id: parsable-R | ||
- id: no-browser-statement | ||
- id: no-print-statement | ||
- id: no-debug-statement | ||
- 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 | ||
args: ['--maxkb=200'] | ||
- id: file-contents-sorter | ||
files: '^\.Rbuildignore$' | ||
- id: end-of-file-fixer | ||
exclude: '\.Rd' | ||
- 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: local | ||
hooks: | ||
- id: forbid-to-commit | ||
name: Don't commit common R artifacts | ||
entry: Cannot commit .Rhistory, .RData, .Rds or .rds. | ||
language: fail | ||
files: '\.(Rhistory|RData|Rds|rds)$' | ||
# `exclude: <regex>` to allow committing specific files | ||
|
||
ci: | ||
autoupdate_schedule: monthly | ||
skip: [pkgdown] |