Skip to content

simple pkgdown check #393

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2

- uses: actions/checkout@v2
Expand Down Expand Up @@ -69,6 +71,15 @@ jobs:
pre-commit run --files DESCRIPTION
git add README*
pre-commit run --files README.Rmd
cp tests/testthat/in/_pkgdown-index-articles.yml _pkgdown.yml
rm -rf vignettes
mkdir vignettes
cp tests/testthat/in/pkgdown.Rmd vignettes/
rm -rf man/
mkdir -p man
cp tests/testthat/in/autoupdate.Rd man/
pre-commit run --files _pkgdown.yml
pre-commit run --files man/autoupdate.Rd
git reset HEAD --hard # restore initial state
env:
SKIP: consistent-release-tag
8 changes: 4 additions & 4 deletions .github/workflows/hook-dependencies-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ jobs:
deps <- desc$get_deps()
dont <- c(
"yaml", "usethis", "withr", "rstudioapi", "precommit",
"httr" # lintr -> httr -> curl -> libcurl, but seems to give no erorr on
# loading lintr, plus https://github.com/jimhester/lintr/issues/861
"pkgdown", "mockery",
"httr"
)
out <- c(out, "roxygen2", "spelling", "styler", "pkgload", "lintr", "knitr", "git2r", "desc")
out <- c(out, "roxygen2", "spelling", "styler", "pkgload", "lintr", "knitr", "git2r", "desc", "mockery")
out <- setdiff(c(unique(c(out, deps[deps$type == "Imports", ]$package))), dont)
out <- names(renv:::renv_package_dependencies(out))
return(out)
return(sort(out))
}
options(repos = c(CRAN = "https://packagemanager.rstudio.com/all/latest"))
options(renv.snapshot.filter = hook_deps)
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/hook-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: r-lib/actions/setup-pandoc@v2
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v2
with:
Expand Down Expand Up @@ -67,6 +68,9 @@ jobs:
run: |
source('renv/activate.R')
renv::restore()
options(install.packages.compile.from.source = "never", pkgType = "binary")
# install hook-specific additional_dependencies from .pre-commit-config.yaml
renv::install(c('pkgdown', 'mockery'))
renv::install(getwd(), dependencies = FALSE)
# needed to make sure renv is activated in run_test()
activate <- c(
Expand Down
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ repos:
(?x)^(
tests/testthat/in/.*|
inst/renv-update\.R|
inst/hooks/exported/pkgdown.R|
renv/activate.R|
vignettes/FAQ\.Rmd|
)$
# - id: pkgdown
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
Expand Down
23 changes: 15 additions & 8 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
- id: roxygenize
name: roxygenize
description: run roxygen2::roxygenize()
description: run `roxygen2::roxygenize()`
entry: Rscript inst/hooks/exported/roxygenize.R
language: r
files: '^(R|man)/'
require_serial: true
minimum_pre_commit_version: "2.13.0"
- id: use-tidy-description
name: use-tidy-description
description: run usethis::use_tidy_description()
description: run `usethis::use_tidy_description()`
entry: Rscript inst/hooks/exported/use-tidy-description.R
language: r
files: '^DESCRIPTION$'
minimum_pre_commit_version: "2.13.0"
- id: style-files
name: style-files
description: style files with styler
description: style files with {styler}
entry: Rscript inst/hooks/exported/style-files.R
language: r
files: '(\.[rR]profile|\.[rR]|\.[rR]md|\.[rR]nw|\.[qQ]md)$'
Expand Down Expand Up @@ -44,21 +44,21 @@
minimum_pre_commit_version: "2.13.0"
- id: readme-rmd-rendered
name: readme-rmd-rendered
description: make sure README.Rmd hasn't been edited more recently than README.md
description: make sure README.Rmd hasn't been edited more recently than `README.md`
entry: Rscript inst/hooks/exported/readme-rmd-rendered.R
language: r
files: 'README\.[Rr]?md$'
minimum_pre_commit_version: "2.13.0"
- id: codemeta-description-updated
name: codemeta-description-updated
description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description.
description: make sure `codemeta.json` is in sync with `DESCRIPTION`. It should be run after use-tidy-description
entry: Rscript inst/hooks/exported/codemeta-description-updated.R
language: r
files: '^DESCRIPTION$'
minimum_pre_commit_version: "2.13.0"
- id: spell-check
name: spell-check
description: perform a spell check with spelling::spell_check_files()
description: perform a spell check with `spelling::spell_check_files()`
entry: Rscript inst/hooks/exported/spell-check.R
language: r
exclude: >
Expand Down Expand Up @@ -92,17 +92,24 @@
minimum_pre_commit_version: "2.13.0"
- id: deps-in-desc
name: deps-in-desc
description: Check if dependencies that can be parsed from code are in DESCRIPTION.
description: Check if dependencies that can be parsed from code are in `DESCRIPTION`
entry: Rscript inst/hooks/exported/deps-in-desc.R
language: r
files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
exclude: 'renv/activate\.R'
minimum_pre_commit_version: "2.13.0"
- id: lintr
name: lintr
description: check if a .R file is lint free (using lintr)
description: check if a `.R` file is lint free (using {lintr})
entry: Rscript inst/hooks/exported/lintr.R
language: r
files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
exclude: 'renv/activate\.R'
minimum_pre_commit_version: "2.13.0"
- id: pkgdown
name: pkgdown
description: check if your {pkgdown} config file has the correct entries for references and articles
entry: inst/hooks/exported/pkgdown.R
language: script
minimum_pre_commit_version: "2.13.0"
files: '^man/|_pkgdown\.yml'
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: precommit
Title: Pre-Commit Hooks
Version: 0.3.2.9003
Version: 0.3.2.9004
Author: Lorenz Walthert
Maintainer: Lorenz Walthert <[email protected]>
Description: Useful git hooks for R building on top of the multi-language
Expand Down Expand Up @@ -33,6 +33,7 @@ Suggests:
lintr,
mockery,
pkgload,
pkgdown,
reticulate (>= 1.16),
rmarkdown,
roxygen2,
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ editor_options:
wrap: 72
---

# precommit v0.3.2.9001 (Development version)
# precommit v0.3.2.9003 (Development version)

- new hook `pkgdown` to emulate a {pkgdown} build for reference and
articles (#393).
- `codemeta-description-updated`, `roxygenize`, and
`use-tidy-description` now all support a `root` argument that
specifies the directory in the git repo that contains the R package.
Expand Down
18 changes: 18 additions & 0 deletions inst/hooks/exported/pkgdown.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env Rscript

if (is.null(pkgdown:::pkgdown_config_path("."))) {
rlang::inform(paste0(
"{pkgdown} seems not configured, the remainder of the check is skipped. ",
"For this hook to not even be invoked, remove `id: pkgdown` from ",
"`.pre-commit-config.yaml`."
))
quit()
}

if (!require(pkgdown, quietly = TRUE)) {
stop("{pkgdown} could not be loaded, please install it.")
}
if (packageVersion("pkgdown") < package_version("2.0.4")) {
rlang::abort("You need at least version 2.0.4 of {pkgdown} to run this hook.")
}
check_pkgdown()
23 changes: 15 additions & 8 deletions inst/pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
- id: roxygenize
name: roxygenize
description: run roxygen2::roxygenize()
description: run `roxygen2::roxygenize()`
entry: Rscript inst/hooks/exported/roxygenize.R
language: r
files: '^(R|man)/'
require_serial: true
minimum_pre_commit_version: "2.13.0"
- id: use-tidy-description
name: use-tidy-description
description: run usethis::use_tidy_description()
description: run `usethis::use_tidy_description()`
entry: Rscript inst/hooks/exported/use-tidy-description.R
language: r
files: '^DESCRIPTION$'
minimum_pre_commit_version: "2.13.0"
- id: style-files
name: style-files
description: style files with styler
description: style files with {styler}
entry: Rscript inst/hooks/exported/style-files.R
language: r
files: '(\.[rR]profile|\.[rR]|\.[rR]md|\.[rR]nw|\.[qQ]md)$'
Expand Down Expand Up @@ -44,21 +44,21 @@
minimum_pre_commit_version: "2.13.0"
- id: readme-rmd-rendered
name: readme-rmd-rendered
description: make sure README.Rmd hasn't been edited more recently than README.md
description: make sure README.Rmd hasn't been edited more recently than `README.md`
entry: Rscript inst/hooks/exported/readme-rmd-rendered.R
language: r
files: 'README\.[Rr]?md$'
minimum_pre_commit_version: "2.13.0"
- id: codemeta-description-updated
name: codemeta-description-updated
description: make sure codemeta.json is in sync with DESCRIPTION. It should be run after use-tidy-description.
description: make sure `codemeta.json` is in sync with `DESCRIPTION`. It should be run after use-tidy-description
entry: Rscript inst/hooks/exported/codemeta-description-updated.R
language: r
files: '^DESCRIPTION$'
minimum_pre_commit_version: "2.13.0"
- id: spell-check
name: spell-check
description: perform a spell check with spelling::spell_check_files()
description: perform a spell check with `spelling::spell_check_files()`
entry: Rscript inst/hooks/exported/spell-check.R
language: r
exclude: >
Expand Down Expand Up @@ -92,17 +92,24 @@
minimum_pre_commit_version: "2.13.0"
- id: deps-in-desc
name: deps-in-desc
description: Check if dependencies that can be parsed from code are in DESCRIPTION.
description: Check if dependencies that can be parsed from code are in `DESCRIPTION`
entry: Rscript inst/hooks/exported/deps-in-desc.R
language: r
files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
exclude: 'renv/activate\.R'
minimum_pre_commit_version: "2.13.0"
- id: lintr
name: lintr
description: check if a .R file is lint free (using lintr)
description: check if a `.R` file is lint free (using {lintr})
entry: Rscript inst/hooks/exported/lintr.R
language: r
files: '(\.[rR]profile|\.R|\.Rmd|\.Rnw|\.r|\.rmd|\.rnw)$'
exclude: 'renv/activate\.R'
minimum_pre_commit_version: "2.13.0"
- id: pkgdown
name: pkgdown
description: check if your {pkgdown} config file has the correct entries for references and articles
entry: inst/hooks/exported/pkgdown.R
language: script
minimum_pre_commit_version: "2.13.0"
files: '^man/|_pkgdown\.yml'
Loading