Skip to content

Commit

Permalink
Merge pull request #582 from lorenzwalthert/rc-v0.4.3
Browse files Browse the repository at this point in the history
Release {precommit} 0.4.3
  • Loading branch information
lorenzwalthert authored Jul 23, 2024
2 parents f11add0 + d37dccb commit b3dfcea
Show file tree
Hide file tree
Showing 15 changed files with 321 additions and 291 deletions.
2 changes: 1 addition & 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.4.2.9000
Version: 0.4.3
Author: Lorenz Walthert
Maintainer: Lorenz Walthert <lorenz.walthert@icloud.com>
Description: Useful git hooks for R building on top of the multi-language
Expand Down
15 changes: 13 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# precommit 0.4.3

* Drop legacy hook tests (#578).
* Extend pkgdown hook tests for latest release where URLs are checked too (#577).
* Fix test to pass with new pkgdown error message (#564).
* fix path resolution for conda (#564).
* Lint .qmd docs also (#570).
* Update hook dependencies (#581).

Thanks to all who contributed to this release: [&#x0040;boxydog](https://github.com/boxydog), [&#x0040;hadley](https://github.com/hadley), [&#x0040;IndrajeetPatil](https://github.com/IndrajeetPatil), [&#x0040;jcken95](https://github.com/jcken95), [&#x0040;jeancochrane](https://github.com/jeancochrane), [&#x0040;jrdnbradford](https://github.com/jrdnbradford), [&#x0040;lorenzwalthert](https://github.com/lorenzwalthert), [&#x0040;owenjonesuob](https://github.com/owenjonesuob), and [&#x0040;TymekDev](https://github.com/TymekDev).

# precommit 0.4.2

Release relax the dependency on third-party error messages in our unit tests (#555).
Expand Down Expand Up @@ -175,7 +186,7 @@ Thanks to all people who contributed to this release:
[\@hadley](https://github.com/hadley),
[\@KyleDCox](https://github.com/KyleDCox),
[\@lorenzwalthert](https://github.com/lorenzwalthert),
[\@lukasfeick-sw](https://github.com/lukasfeick-sw),
@lukasfeick-sw,
[\@MarkMc1089](https://github.com/MarkMc1089),
[\@pat-s](https://github.com/pat-s),
[\@RoyalTS](https://github.com/RoyalTS), and
Expand Down Expand Up @@ -345,7 +356,7 @@ A big hand to all the contributors of this release:
[\@joelnitta](https://github.com/joelnitta),
[\@jucor](https://github.com/jucor),
[\@lorenzwalthert](https://github.com/lorenzwalthert),
[\@lukasfeick-sw](https://github.com/lukasfeick-sw),
@lukasfeick-sw,
[\@MarkMc1089](https://github.com/MarkMc1089),
[\@njtierney](https://github.com/njtierney),
[\@pat-s](https://github.com/pat-s),
Expand Down
4 changes: 4 additions & 0 deletions R/testing.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,10 @@ on_cran <- function() {
!identical(Sys.getenv("NOT_CRAN"), "true")
}

on_windows_on_cran <- function() {
on_cran() && is_windows()
}

#' The testing environment does not use a conda environment if the env variable
#' PRECOMMIT_INSTALLATION_METHOD is not 'conda'.
#' @keywords internal
Expand Down
9 changes: 5 additions & 4 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
This is a submission due to enable the pkgdown release since their error
This is a submission due to enable the pkgdown release since they now check
URL consistency between `DESCRIPTION` and `_pkgdown.yml`.
message changes.

## Test environments

- ubuntu 18.04 (on GitHub Actions): R 4.3
- Windows (on GitHub Actions): R 4.3
- macOS (on GitHub Actions): R 4.3
- ubuntu 18.04 (on GitHub Actions): R 4.4
- Windows (on GitHub Actions): R 4.4
- macOS (on GitHub Actions): R 4.4
- win-builder: R devel

## R CMD check results
Expand Down
1 change: 1 addition & 0 deletions inst/WORDLIST
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ precommithooks
proj
purrr
py
qmd
Rbuildignore
rc
RData
Expand Down
2 changes: 1 addition & 1 deletion inst/pre-commit-config-pkg.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.2
rev: v0.4.3
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
Expand Down
2 changes: 1 addition & 1 deletion inst/pre-commit-config-proj.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.2
rev: v0.4.3
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
Expand Down
52 changes: 27 additions & 25 deletions tests/testthat/test-hook-codemeta-description-updated.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,6 @@ run_test("codemeta-description-update",
std_out = NULL,
)

run_test("codemeta-description-update",
file_name = c("DESCRIPTION"),
suffix = "",
std_err = "No `codemeta.json` found in repository.",
std_out = NULL,
)


# outdated
run_test("codemeta-description-update",
file_name = c("DESCRIPTION", "codemeta.json"),
suffix = "",
std_err = "out of date",
std_out = NULL,
file_transformer = function(files) {
if (length(files) > 1) {
# transformer is called once on all files and once per file
content_2 <- readLines(files[1])
Sys.sleep(2)
writeLines(content_2, files[1])
}
files
}
)

# succeed
run_test("codemeta-description-update",
file_name = c("DESCRIPTION", "codemeta.json"),
Expand Down Expand Up @@ -86,3 +61,30 @@ if (!on_cran()) {
}
)
}

if (!on_windows_on_cran()) {
run_test("codemeta-description-update",
file_name = c("DESCRIPTION"),
suffix = "",
std_err = "No `codemeta.json` found in repository.",
std_out = NULL,
)


# outdated
run_test("codemeta-description-update",
file_name = c("DESCRIPTION", "codemeta.json"),
suffix = "",
std_err = "out of date",
std_out = NULL,
file_transformer = function(files) {
if (length(files) > 1) {
# transformer is called once on all files and once per file
content_2 <- readLines(files[1])
Sys.sleep(2)
writeLines(content_2, files[1])
}
files
}
)
}
172 changes: 87 additions & 85 deletions tests/testthat/test-hook-deps-in-desc-R.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ run_test("deps-in-desc",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

# in sub directory with wrong root
run_test("deps-in-desc",
suffix = "-fail.R", std_err = "Could not find R package",
file_transformer = function(files) {
fs::path_abs(fs::file_move(files, "rpkg"))
},
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
)

# in sub directory with correct root
if (!on_cran()) {
# in sub directory with wrong root
run_test("deps-in-desc",
suffix = "-fail.R", std_err = "Could not find R package",
file_transformer = function(files) {
fs::path_abs(fs::file_move(files, "rpkg"))
},
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
)
# in sub directory with correct root
run_test("deps-in-desc",
cmd_args = "--root=rpkg",
suffix = "-fail.R", std_err = "Dependency check failed",
Expand All @@ -41,93 +41,95 @@ if (!on_cran()) {
}


# with :::
run_test("deps-in-desc",
"deps-in-desc-dot3",
suffix = "-fail.R", std_err = "Dependency check failed",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

run_test("deps-in-desc",
"deps-in-desc-dot3",
suffix = "-success.R", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

run_test("deps-in-desc",
"deps-in-desc-dot3",
suffix = "-fail.R", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
cmd_args = "--allow_private_imports"
)
if (!on_windows_on_cran()) {
# with :::
run_test("deps-in-desc",
"deps-in-desc-dot3",
suffix = "-fail.R", std_err = "Dependency check failed",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

# Rmd
run_test("deps-in-desc",
"deps-in-desc",
suffix = "-fail.Rmd", std_err = "Dependency check failed",
std_out = "deps-in-desc-fail.Rmd`: ttyzp",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)
run_test("deps-in-desc",
"deps-in-desc-dot3",
suffix = "-success.R", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

run_test("deps-in-desc",
"deps-in-desc",
suffix = "-success.Rmd", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)
run_test("deps-in-desc",
"deps-in-desc-dot3",
suffix = "-fail.R", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
cmd_args = "--allow_private_imports"
)

# README.Rmd is excluded
run_test("deps-in-desc",
"README.Rmd",
suffix = "", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"))
)
# Rmd
run_test("deps-in-desc",
"deps-in-desc",
suffix = "-fail.Rmd", std_err = "Dependency check failed",
std_out = "deps-in-desc-fail.Rmd`: ttyzp",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

run_test("deps-in-desc",
"deps-in-desc",
suffix = "-success.Rmd", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

# README.Rmd is excluded
run_test("deps-in-desc",
"README.Rmd",
suffix = "", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"))
)

# Rnw
run_test("deps-in-desc",
"deps-in-desc",
suffix = "-fail.Rnw", std_err = "Dependency check failed",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

run_test("deps-in-desc",
"deps-in-desc",
suffix = "-success.Rnw", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

# Rprofile
# because .Rprofile is executed on startup, this must be an installed
# package (to not give an error staight away) not listed in
# test_path("in/DESCRIPTION")
if (Sys.getenv("GITHUB_WORKFLOW") != "Hook tests") {
# seems like .Rprofile with renv activation does not get executed when
# argument to Rscript contains Rprofile ?! Skip this
expect_true(rlang::is_installed("R.cache"))
# Rnw
run_test("deps-in-desc",
"Rprofile",
suffix = "", std_err = "Dependency check failed",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
file_transformer = function(files) {
writeLines("R.cache::findCache", files)
fs::file_move(
files,
fs::path(fs::path_dir(files), paste0(".", fs::path_file(files)))
)
}
"deps-in-desc",
suffix = "-fail.Rnw", std_err = "Dependency check failed",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

run_test("deps-in-desc",
"Rprofile",
suffix = "", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
file_transformer = function(files) {
writeLines("utils::head", files)
fs::file_move(
files,
fs::path(fs::path_dir(files), paste0(".", fs::path_file(files)))
)
}
"deps-in-desc",
suffix = "-success.Rnw", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
)

# Rprofile
# because .Rprofile is executed on startup, this must be an installed
# package (to not give an error staight away) not listed in
# test_path("in/DESCRIPTION")
if (Sys.getenv("GITHUB_WORKFLOW") != "Hook tests") {
# seems like .Rprofile with renv activation does not get executed when
# argument to Rscript contains Rprofile ?! Skip this
expect_true(rlang::is_installed("R.cache"))
run_test("deps-in-desc",
"Rprofile",
suffix = "", std_err = "Dependency check failed",
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
file_transformer = function(files) {
writeLines("R.cache::findCache", files)
fs::file_move(
files,
fs::path(fs::path_dir(files), paste0(".", fs::path_file(files)))
)
}
)

run_test("deps-in-desc",
"Rprofile",
suffix = "", std_err = NULL,
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
file_transformer = function(files) {
writeLines("utils::head", files)
fs::file_move(
files,
fs::path(fs::path_dir(files), paste0(".", fs::path_file(files)))
)
}
)
}
}
22 changes: 12 additions & 10 deletions tests/testthat/test-hook-lintr.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@ run_test("lintr",
# failure
run_test("lintr", suffix = "-fail.R", std_err = "not lint free")

# warning
run_test(
"lintr",
suffix = "-fail.R", cmd_args = "--warn_only", std_err = NULL
)
if (!on_windows_on_cran()) {
# warning
run_test(
"lintr",
suffix = "-fail.R", cmd_args = "--warn_only", std_err = NULL
)

# .qmd ----
# .qmd ----

# success
run_test("lintr", suffix = "-success.qmd", std_err = NULL)
# success
run_test("lintr", suffix = "-success.qmd", std_err = NULL)

# failure
run_test("lintr", suffix = "-fail.qmd", std_err = "not lint free")
# failure
run_test("lintr", suffix = "-fail.qmd", std_err = "not lint free")
}
Loading

0 comments on commit b3dfcea

Please sign in to comment.