Skip to content

Commit b3dfcea

Browse files
Merge pull request #582 from lorenzwalthert/rc-v0.4.3
Release {precommit} 0.4.3
2 parents f11add0 + d37dccb commit b3dfcea

15 files changed

+321
-291
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: precommit
22
Title: Pre-Commit Hooks
3-
Version: 0.4.2.9000
3+
Version: 0.4.3
44
Author: Lorenz Walthert
55
Maintainer: Lorenz Walthert <[email protected]>
66
Description: Useful git hooks for R building on top of the multi-language

NEWS.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
# precommit 0.4.3
2+
3+
* Drop legacy hook tests (#578).
4+
* Extend pkgdown hook tests for latest release where URLs are checked too (#577).
5+
* Fix test to pass with new pkgdown error message (#564).
6+
* fix path resolution for conda (#564).
7+
* Lint .qmd docs also (#570).
8+
* Update hook dependencies (#581).
9+
10+
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).
11+
112
# precommit 0.4.2
213

314
Release relax the dependency on third-party error messages in our unit tests (#555).
@@ -175,7 +186,7 @@ Thanks to all people who contributed to this release:
175186
[\@hadley](https://github.com/hadley),
176187
[\@KyleDCox](https://github.com/KyleDCox),
177188
[\@lorenzwalthert](https://github.com/lorenzwalthert),
178-
[\@lukasfeick-sw](https://github.com/lukasfeick-sw),
189+
@lukasfeick-sw,
179190
[\@MarkMc1089](https://github.com/MarkMc1089),
180191
[\@pat-s](https://github.com/pat-s),
181192
[\@RoyalTS](https://github.com/RoyalTS), and
@@ -345,7 +356,7 @@ A big hand to all the contributors of this release:
345356
[\@joelnitta](https://github.com/joelnitta),
346357
[\@jucor](https://github.com/jucor),
347358
[\@lorenzwalthert](https://github.com/lorenzwalthert),
348-
[\@lukasfeick-sw](https://github.com/lukasfeick-sw),
359+
@lukasfeick-sw,
349360
[\@MarkMc1089](https://github.com/MarkMc1089),
350361
[\@njtierney](https://github.com/njtierney),
351362
[\@pat-s](https://github.com/pat-s),

R/testing.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,10 @@ on_cran <- function() {
266266
!identical(Sys.getenv("NOT_CRAN"), "true")
267267
}
268268

269+
on_windows_on_cran <- function() {
270+
on_cran() && is_windows()
271+
}
272+
269273
#' The testing environment does not use a conda environment if the env variable
270274
#' PRECOMMIT_INSTALLATION_METHOD is not 'conda'.
271275
#' @keywords internal

cran-comments.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
This is a submission due to enable the pkgdown release since their error
1+
This is a submission due to enable the pkgdown release since they now check
2+
URL consistency between `DESCRIPTION` and `_pkgdown.yml`.
23
message changes.
34

45
## Test environments
56

6-
- ubuntu 18.04 (on GitHub Actions): R 4.3
7-
- Windows (on GitHub Actions): R 4.3
8-
- macOS (on GitHub Actions): R 4.3
7+
- ubuntu 18.04 (on GitHub Actions): R 4.4
8+
- Windows (on GitHub Actions): R 4.4
9+
- macOS (on GitHub Actions): R 4.4
910
- win-builder: R devel
1011

1112
## R CMD check results

inst/WORDLIST

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ precommithooks
142142
proj
143143
purrr
144144
py
145+
qmd
145146
Rbuildignore
146147
rc
147148
RData

inst/pre-commit-config-pkg.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# R specific hooks: https://github.com/lorenzwalthert/precommit
33
repos:
44
- repo: https://github.com/lorenzwalthert/precommit
5-
rev: v0.4.2
5+
rev: v0.4.3
66
hooks:
77
- id: style-files
88
args: [--style_pkg=styler, --style_fun=tidyverse_style]

inst/pre-commit-config-proj.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# R specific hooks: https://github.com/lorenzwalthert/precommit
33
repos:
44
- repo: https://github.com/lorenzwalthert/precommit
5-
rev: v0.4.2
5+
rev: v0.4.3
66
hooks:
77
- id: style-files
88
args: [--style_pkg=styler, --style_fun=tidyverse_style]

tests/testthat/test-hook-codemeta-description-updated.R

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5,31 +5,6 @@ run_test("codemeta-description-update",
55
std_out = NULL,
66
)
77

8-
run_test("codemeta-description-update",
9-
file_name = c("DESCRIPTION"),
10-
suffix = "",
11-
std_err = "No `codemeta.json` found in repository.",
12-
std_out = NULL,
13-
)
14-
15-
16-
# outdated
17-
run_test("codemeta-description-update",
18-
file_name = c("DESCRIPTION", "codemeta.json"),
19-
suffix = "",
20-
std_err = "out of date",
21-
std_out = NULL,
22-
file_transformer = function(files) {
23-
if (length(files) > 1) {
24-
# transformer is called once on all files and once per file
25-
content_2 <- readLines(files[1])
26-
Sys.sleep(2)
27-
writeLines(content_2, files[1])
28-
}
29-
files
30-
}
31-
)
32-
338
# succeed
349
run_test("codemeta-description-update",
3510
file_name = c("DESCRIPTION", "codemeta.json"),
@@ -86,3 +61,30 @@ if (!on_cran()) {
8661
}
8762
)
8863
}
64+
65+
if (!on_windows_on_cran()) {
66+
run_test("codemeta-description-update",
67+
file_name = c("DESCRIPTION"),
68+
suffix = "",
69+
std_err = "No `codemeta.json` found in repository.",
70+
std_out = NULL,
71+
)
72+
73+
74+
# outdated
75+
run_test("codemeta-description-update",
76+
file_name = c("DESCRIPTION", "codemeta.json"),
77+
suffix = "",
78+
std_err = "out of date",
79+
std_out = NULL,
80+
file_transformer = function(files) {
81+
if (length(files) > 1) {
82+
# transformer is called once on all files and once per file
83+
content_2 <- readLines(files[1])
84+
Sys.sleep(2)
85+
writeLines(content_2, files[1])
86+
}
87+
files
88+
}
89+
)
90+
}

tests/testthat/test-hook-deps-in-desc-R.R

Lines changed: 87 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ run_test("deps-in-desc",
1010
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
1111
)
1212

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

22-
# in sub directory with correct root
2314
if (!on_cran()) {
15+
# in sub directory with wrong root
16+
run_test("deps-in-desc",
17+
suffix = "-fail.R", std_err = "Could not find R package",
18+
file_transformer = function(files) {
19+
fs::path_abs(fs::file_move(files, "rpkg"))
20+
},
21+
artifacts = c("rpkg/DESCRIPTION" = test_path("in/DESCRIPTION"))
22+
)
23+
# in sub directory with correct root
2424
run_test("deps-in-desc",
2525
cmd_args = "--root=rpkg",
2626
suffix = "-fail.R", std_err = "Dependency check failed",
@@ -41,93 +41,95 @@ if (!on_cran()) {
4141
}
4242

4343

44-
# with :::
45-
run_test("deps-in-desc",
46-
"deps-in-desc-dot3",
47-
suffix = "-fail.R", std_err = "Dependency check failed",
48-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
49-
)
50-
51-
run_test("deps-in-desc",
52-
"deps-in-desc-dot3",
53-
suffix = "-success.R", std_err = NULL,
54-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
55-
)
56-
57-
run_test("deps-in-desc",
58-
"deps-in-desc-dot3",
59-
suffix = "-fail.R", std_err = NULL,
60-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
61-
cmd_args = "--allow_private_imports"
62-
)
44+
if (!on_windows_on_cran()) {
45+
# with :::
46+
run_test("deps-in-desc",
47+
"deps-in-desc-dot3",
48+
suffix = "-fail.R", std_err = "Dependency check failed",
49+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
50+
)
6351

64-
# Rmd
65-
run_test("deps-in-desc",
66-
"deps-in-desc",
67-
suffix = "-fail.Rmd", std_err = "Dependency check failed",
68-
std_out = "deps-in-desc-fail.Rmd`: ttyzp",
69-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
70-
)
52+
run_test("deps-in-desc",
53+
"deps-in-desc-dot3",
54+
suffix = "-success.R", std_err = NULL,
55+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
56+
)
7157

72-
run_test("deps-in-desc",
73-
"deps-in-desc",
74-
suffix = "-success.Rmd", std_err = NULL,
75-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
76-
)
58+
run_test("deps-in-desc",
59+
"deps-in-desc-dot3",
60+
suffix = "-fail.R", std_err = NULL,
61+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
62+
cmd_args = "--allow_private_imports"
63+
)
7764

78-
# README.Rmd is excluded
79-
run_test("deps-in-desc",
80-
"README.Rmd",
81-
suffix = "", std_err = NULL,
82-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"))
83-
)
65+
# Rmd
66+
run_test("deps-in-desc",
67+
"deps-in-desc",
68+
suffix = "-fail.Rmd", std_err = "Dependency check failed",
69+
std_out = "deps-in-desc-fail.Rmd`: ttyzp",
70+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
71+
)
8472

73+
run_test("deps-in-desc",
74+
"deps-in-desc",
75+
suffix = "-success.Rmd", std_err = NULL,
76+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
77+
)
8578

79+
# README.Rmd is excluded
80+
run_test("deps-in-desc",
81+
"README.Rmd",
82+
suffix = "", std_err = NULL,
83+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION-no-deps.dcf"))
84+
)
8685

87-
# Rnw
88-
run_test("deps-in-desc",
89-
"deps-in-desc",
90-
suffix = "-fail.Rnw", std_err = "Dependency check failed",
91-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
92-
)
9386

94-
run_test("deps-in-desc",
95-
"deps-in-desc",
96-
suffix = "-success.Rnw", std_err = NULL,
97-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
98-
)
9987

100-
# Rprofile
101-
# because .Rprofile is executed on startup, this must be an installed
102-
# package (to not give an error staight away) not listed in
103-
# test_path("in/DESCRIPTION")
104-
if (Sys.getenv("GITHUB_WORKFLOW") != "Hook tests") {
105-
# seems like .Rprofile with renv activation does not get executed when
106-
# argument to Rscript contains Rprofile ?! Skip this
107-
expect_true(rlang::is_installed("R.cache"))
88+
# Rnw
10889
run_test("deps-in-desc",
109-
"Rprofile",
110-
suffix = "", std_err = "Dependency check failed",
111-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
112-
file_transformer = function(files) {
113-
writeLines("R.cache::findCache", files)
114-
fs::file_move(
115-
files,
116-
fs::path(fs::path_dir(files), paste0(".", fs::path_file(files)))
117-
)
118-
}
90+
"deps-in-desc",
91+
suffix = "-fail.Rnw", std_err = "Dependency check failed",
92+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
11993
)
12094

12195
run_test("deps-in-desc",
122-
"Rprofile",
123-
suffix = "", std_err = NULL,
124-
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
125-
file_transformer = function(files) {
126-
writeLines("utils::head", files)
127-
fs::file_move(
128-
files,
129-
fs::path(fs::path_dir(files), paste0(".", fs::path_file(files)))
130-
)
131-
}
96+
"deps-in-desc",
97+
suffix = "-success.Rnw", std_err = NULL,
98+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION"))
13299
)
100+
101+
# Rprofile
102+
# because .Rprofile is executed on startup, this must be an installed
103+
# package (to not give an error staight away) not listed in
104+
# test_path("in/DESCRIPTION")
105+
if (Sys.getenv("GITHUB_WORKFLOW") != "Hook tests") {
106+
# seems like .Rprofile with renv activation does not get executed when
107+
# argument to Rscript contains Rprofile ?! Skip this
108+
expect_true(rlang::is_installed("R.cache"))
109+
run_test("deps-in-desc",
110+
"Rprofile",
111+
suffix = "", std_err = "Dependency check failed",
112+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
113+
file_transformer = function(files) {
114+
writeLines("R.cache::findCache", files)
115+
fs::file_move(
116+
files,
117+
fs::path(fs::path_dir(files), paste0(".", fs::path_file(files)))
118+
)
119+
}
120+
)
121+
122+
run_test("deps-in-desc",
123+
"Rprofile",
124+
suffix = "", std_err = NULL,
125+
artifacts = c("DESCRIPTION" = test_path("in/DESCRIPTION")),
126+
file_transformer = function(files) {
127+
writeLines("utils::head", files)
128+
fs::file_move(
129+
files,
130+
fs::path(fs::path_dir(files), paste0(".", fs::path_file(files)))
131+
)
132+
}
133+
)
134+
}
133135
}

tests/testthat/test-hook-lintr.R

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ run_test("lintr",
99
# failure
1010
run_test("lintr", suffix = "-fail.R", std_err = "not lint free")
1111

12-
# warning
13-
run_test(
14-
"lintr",
15-
suffix = "-fail.R", cmd_args = "--warn_only", std_err = NULL
16-
)
12+
if (!on_windows_on_cran()) {
13+
# warning
14+
run_test(
15+
"lintr",
16+
suffix = "-fail.R", cmd_args = "--warn_only", std_err = NULL
17+
)
1718

18-
# .qmd ----
19+
# .qmd ----
1920

20-
# success
21-
run_test("lintr", suffix = "-success.qmd", std_err = NULL)
21+
# success
22+
run_test("lintr", suffix = "-success.qmd", std_err = NULL)
2223

23-
# failure
24-
run_test("lintr", suffix = "-fail.qmd", std_err = "not lint free")
24+
# failure
25+
run_test("lintr", suffix = "-fail.qmd", std_err = "not lint free")
26+
}

0 commit comments

Comments
 (0)