Skip to content

Commit aa2fee4

Browse files
committed
Lints and checks
1 parent b84eb1d commit aa2fee4

File tree

12 files changed

+84
-139
lines changed

12 files changed

+84
-139
lines changed

.github/workflows/check.yaml

+28-50
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
13
on: [push, pull_request]
24

35
name: check
@@ -12,69 +14,45 @@ jobs:
1214
fail-fast: false
1315
matrix:
1416
config:
15-
- {os: windows-latest, r: '4.0'}
16-
- {os: macOS-latest, r: 'release'}
17-
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
17+
- {os: macOS-latest, r: 'release'}
18+
- {os: windows-latest, r: 'release'}
19+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
20+
- {os: ubuntu-latest, r: 'release'}
21+
- {os: ubuntu-latest, r: 'oldrel-1'}
1822

1923
env:
20-
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
21-
RSPM: ${{ matrix.config.rspm }}
22-
GITHUB_PAT: ${{ secrets.GITHUBPAT }}
24+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
25+
NOT_CRAN: true
26+
R_KEEP_PKG_SOURCE: yes
27+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: false
28+
TORCH_INSTALL: 1
2329

2430
steps:
2531
- uses: actions/checkout@v2
2632

27-
- uses: r-lib/actions/setup-r@master
28-
with:
29-
r-version: ${{ matrix.config.r }}
30-
31-
- uses: r-lib/actions/setup-pandoc@master
32-
33-
- name: Query dependencies
34-
run: |
35-
install.packages('remotes')
36-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
37-
shell: Rscript {0}
38-
39-
- name: Cache R packages
40-
if: runner.os != 'Windows'
41-
uses: actions/cache@v1
42-
with:
43-
path: ${{ env.R_LIBS_USER }}
44-
key: ${{ runner.os }}-r-${{ matrix.config.r }}-2-${{ hashFiles('.github/depends.Rds') }}
45-
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-2-
33+
- uses: r-lib/actions/setup-pandoc@v2
4634

4735
- name: Install Mac system dependencies
4836
if: runner.os == 'macOS'
49-
run: |
50-
brew install zeromq
37+
run: brew install zeromq
5138

52-
- name: Install system dependencies
39+
- name: Install Linux system dependencies
5340
if: runner.os == 'Linux'
54-
env:
55-
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
5641
run: |
57-
Rscript -e "remotes::install_github('r-hub/sysreqs')"
58-
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
59-
sudo -s eval "$sysreqs"
42+
sudo apt-get update
43+
sudo apt-get install libglpk-dev libglpk40
6044
61-
- name: Install dependencies
62-
run: |
63-
remotes::install_deps(dependencies = TRUE)
64-
remotes::install_cran("rcmdcheck")
65-
install.packages(".", type = "source", repos = NULL)
66-
shell: Rscript {0}
45+
- uses: r-lib/actions/setup-r@v2
46+
with:
47+
r-version: ${{ matrix.config.r }}
48+
http-user-agent: ${{ matrix.config.http-user-agent }}
49+
use-public-rspm: true
6750

68-
- name: Check
69-
env:
70-
_R_CHECK_CRAN_INCOMING_REMOTE_: false
71-
_R_CHECK_FORCE_SUGGESTS_: false
72-
run: rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check")
73-
shell: Rscript {0}
51+
- uses: r-lib/actions/setup-r-dependencies@v2
52+
with:
53+
extra-packages: any::rcmdcheck
54+
needs: check
7455

75-
- name: Upload check results
76-
if: failure()
77-
uses: actions/upload-artifact@master
56+
- uses: r-lib/actions/check-r-package@v2
7857
with:
79-
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
80-
path: check
58+
upload-snapshots: true

.github/workflows/cover.yaml

+19-41
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,36 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
13
on: [push, pull_request]
24

35
name: cover
46

57
jobs:
68
cover:
7-
runs-on: ${{ matrix.config.os }}
8-
9-
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
10-
11-
strategy:
12-
fail-fast: false
13-
matrix:
14-
config:
15-
- {os: ubuntu-20.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/focal/latest"}
16-
9+
runs-on: ubuntu-latest
1710
env:
18-
GITHUB_PAT: ${{ secrets.GITHUBPAT }}
11+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
12+
NOT_CRAN: true
13+
R_REMOTES_NO_ERRORS_FROM_WARNINGS: false
14+
TORCH_INSTALL: 1
15+
1916
steps:
2017
- uses: actions/checkout@v2
2118

22-
- uses: r-lib/actions/setup-r@master
23-
24-
- uses: r-lib/actions/setup-pandoc@master
25-
26-
- name: Query dependencies
19+
- name: Install Linux system dependencies
20+
if: runner.os == 'Linux'
2721
run: |
28-
install.packages('remotes')
29-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
30-
shell: Rscript {0}
22+
sudo apt-get update
23+
sudo apt-get install libglpk-dev libglpk40
3124
32-
- name: Cache R packages
33-
if: runner.os != 'Windows'
34-
uses: actions/cache@v1
25+
- uses: r-lib/actions/setup-r@v2
3526
with:
36-
path: ${{ env.R_LIBS_USER }}
37-
key: ${{ runner.os }}-r-${{ matrix.config.r }}-4-${{ hashFiles('.github/depends.Rds') }}
38-
restore-keys: ${{ runner.os }}-r-${{ matrix.config.r }}-4-
39-
40-
- name: Install system dependencies
41-
if: runner.os == 'Linux'
42-
env:
43-
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
44-
run: |
45-
sudo -s apt-get install libcurl4-openssl-dev
46-
sudo -s apt-get install libzmq3-dev
47-
sudo -s apt-get install libgit2-dev
27+
use-public-rspm: true
4828

49-
- name: Install dependencies
50-
run: |
51-
install.packages(c("remotes", "covr"))
52-
remotes::install_deps(dependencies = TRUE)
53-
install.packages(".", type = "source", repos = NULL)
54-
shell: Rscript {0}
29+
- uses: r-lib/actions/setup-r-dependencies@v2
30+
with:
31+
extra-packages: any::covr
32+
needs: coverage
5533

5634
- name: Test coverage
57-
run: covr::codecov()
35+
run: covr::codecov(quiet = FALSE)
5836
shell: Rscript {0}

.github/workflows/lint.yaml

+11-29
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,26 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
13
on: [push, pull_request]
24

35
name: lint
46

57
jobs:
68
lint:
7-
runs-on: macOS-latest
9+
runs-on: ubuntu-latest
810
env:
9-
GITHUB_PAT: ${{ secrets.GITHUBPAT }}
11+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
1012
steps:
1113
- uses: actions/checkout@v2
1214

13-
- uses: r-lib/actions/setup-r@master
14-
15-
- name: Query dependencies
16-
run: |
17-
install.packages('remotes')
18-
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
19-
shell: Rscript {0}
20-
21-
- name: Cache R packages
22-
uses: actions/cache@v1
15+
- uses: r-lib/actions/setup-r@v2
2316
with:
24-
path: ${{ env.R_LIBS_USER }}
25-
key: macOS-r-4.0-3-${{ hashFiles('.github/depends.Rds') }}
26-
restore-keys: macOS-r-4.0-3-
17+
use-public-rspm: true
2718

28-
- name: Install system requirements
29-
run: |
30-
brew install zeromq
31-
32-
- name: Install dependencies
33-
run: |
34-
install.packages(c("remotes"))
35-
remotes::install_deps(dependencies = TRUE)
36-
remotes::install_cran("lintr")
37-
shell: Rscript {0}
19+
- uses: r-lib/actions/setup-r-dependencies@v2
20+
with:
21+
extra-packages: any::lintr, local::.
22+
needs: lint
3823

3924
- name: Lint
40-
run: |
41-
out <- lintr::lint_package()
42-
print(out)
43-
if (length(out)) stop("lints found")
25+
run: lintr::lint_package()
4426
shell: Rscript {0}

.lintr

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ linters: linters_with_defaults(
22
object_length_linter = NULL,
33
object_name_linter = NULL,
44
object_usage_linter = NULL)
5+
exclusions: list("inst/testing/knitr/bad.Rmd")

R/walk_code.R

+2-4
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,7 @@ make_assignment_fn_impl <- function(fun) {
460460
if (is_correctly_namespaced) {
461461
fun[[3]] <- as.name(paste0(as.character(fun[[3]]), "<-"))
462462
fun
463-
}
464-
else {
463+
} else {
465464
stop0("bad function in complex assignments: ", dsq(fun))
466465
}
467466
}
@@ -475,8 +474,7 @@ evalseq <- function(e) {
475474
v <- evalseq(e[[2]])
476475
e[[2]] <- codetools_tmp
477476
c(v, list(e))
478-
}
479-
else {
477+
} else {
480478
list(e)
481479
}
482480
}

inst/rmarkdown/templates/drake/skeleton/skeleton.Rmd

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ tryCatch({
1313
print(fit)
1414
readd(hist)
1515
},
16-
error = function(e){
16+
error = function(e) {
1717
stop("please read the instructions in the R Markdown file.")
1818
})
1919
```

inst/testing/knitr/test.Rmd

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ f(readd(target14) + var)
4545
f(readd(target15) + var) # deliberate repeat
4646
f(g(drake::readd(target16) + var))
4747
f(readd(target = "target17", character_only = TRUE) + var)
48-
g <- function(){
48+
g <- function() {
4949
f(drake:::loadd(target18, character_only = IGNORE_THIS) + var)
5050
}
51-
function(){
51+
function() {
5252
f(drake:::loadd(target18, character_only = IGNORE_THIS) + var)
5353
}
5454
readd("\"file1\"")

tests/testthat/test-4-flow.R

+7-3
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,13 @@ test_with_dir("failed targets do not become up to date", {
237237

238238
test_with_dir("true targets can be functions", {
239239
skip_on_cran() # CRAN gets essential tests only (check time limits).
240-
generator <- function() return(function(x) {
241-
x + 1
242-
})
240+
generator <- function() {
241+
return(
242+
function(x) {
243+
x + 1
244+
}
245+
)
246+
}
243247
plan <- drake_plan(myfunction = generator(), output = myfunction(1))
244248
make(plan, verbose = 0L, session_info = FALSE)
245249
config <- drake_config(plan, verbose = 0L, session_info = FALSE)

tests/testthat/test-6-analysis.R

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
drake_context("analysis")
22

3+
# nolint start
34
test_with_dir("busy function", {
45
f <- function(a = 1, b = k(i), nineteen, string_args = c("sa1", "sa2")) {
56
for (iter in 1:10) {
@@ -49,6 +50,7 @@ test_with_dir("busy function", {
4950
str <- sort(c(str, "w", "x", "y", "z"))
5051
expect_equal(sort(analyze_strings(f)), str)
5152
})
53+
# nolint end
5254

5355
test_with_dir("equals analysis", {
5456
for (text in c("z = g(a * b)", "function(x) {z = g(a * b)}")) {
@@ -143,7 +145,7 @@ test_with_dir("solitary codetools globals tests", {
143145
}
144146
expect_equivalent(drake_deps(f), new_drake_deps())
145147
f <- function() {
146-
x <- 1; y <- 2
148+
x <- 1; y <- 2 # nolint
147149
}
148150
out <- as.character(drake_deps(f)$globals)
149151
expect_equal(out, character(0))
@@ -398,9 +400,11 @@ test_with_dir("bad target names", {
398400
test_with_dir("file_in() and file_out() and knitr_in(): commands vs imports", {
399401
skip_on_cran() # CRAN gets essential tests only (check time limits).
400402
skip_if_not_installed("knitr")
403+
# nolint start
401404
cmd <- quote({
402405
file_in("x"); file_out("y"); knitr_in("report.Rmd")
403406
})
407+
# nolint end
404408
f <- function() {
405409
file_in("x")
406410
}

tests/testthat/test-6-plans.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ test_with_dir("warn about <- and -> in drake_plan()", {
4848
)
4949
expect_silent(
5050
tmp <- drake_plan(
51-
a = 1 -> x,
51+
a = 1 -> x, # nolint
5252
b = 2
5353
)
5454
)
@@ -57,11 +57,11 @@ test_with_dir("warn about <- and -> in drake_plan()", {
5757
regexp = "to assign targets to commands"
5858
)
5959
expect_warning(
60-
tmp <- drake_plan(a = 1, b -> 2),
60+
tmp <- drake_plan(a = 1, b -> 2), # nolint
6161
regexp = "to assign targets to commands"
6262
)
6363
expect_warning(
64-
tmp <- drake_plan(a <- 1, b -> 2),
64+
tmp <- drake_plan(a <- 1, b -> 2), # nolint
6565
regexp = "to assign targets to commands"
6666
)
6767
})

tests/testthat/test-7-dsl.R

+4-4
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ test_with_dir("single tag_in", {
119119
.tag_in = single
120120
)
121121
),
122-
trace = T
122+
trace = TRUE
123123
)
124124
exp <- drake_plan(
125125
x_1 = target(
@@ -146,7 +146,7 @@ test_with_dir("multiple tag_in", {
146146
.tag_in = c(one, second)
147147
)
148148
),
149-
trace = T
149+
trace = TRUE
150150
)
151151
exp <- drake_plan(
152152
x_1 = target(
@@ -175,7 +175,7 @@ test_with_dir("single tag_out", {
175175
.tag_out = single
176176
)
177177
),
178-
trace = T
178+
trace = TRUE
179179
)
180180
exp <- drake_plan(
181181
x_1 = target(
@@ -202,7 +202,7 @@ test_with_dir("multiple tag_out", {
202202
.tag_out = c(one, second)
203203
)
204204
),
205-
trace = T
205+
trace = TRUE
206206
)
207207
exp <- drake_plan(
208208
x_1 = target(

0 commit comments

Comments
 (0)