Skip to content

Commit bccbe1b

Browse files
really use language: r
1 parent a7a5810 commit bccbe1b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1826
-368
lines changed

.Rbuildignore

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
^README\.Rmd$
21
^.*\.Rproj$
3-
^\.Rproj\.user$
4-
^LICENSE\.md$
2+
^\.github$
3+
^\.pre-commit-config\.yaml$
54
^\.pre-commit-hooks\.yaml$
6-
^\.travis\.yml$
5+
^\.Rproj\.user$
6+
^API$
77
^CONTRIBUTING\.md$
8-
^appveyor\.yml$
9-
^tic\.R$
10-
^_pkgdown\.yml$
8+
^cran-comments\.md$
119
^docs$
12-
^pkgdown$
13-
^\.pre-commit-config\.yaml$
14-
^API$
15-
^inst/consistent-release-tag$
10+
^inst/hooks/local$
11+
^inst/renv-update\.R$
1612
^inst/WORDLIST$
17-
^inst/hooks-config-to-inst$
18-
^cran-comments\.md$
19-
^\.github$
13+
^LICENSE\.md$
14+
^pkgdown$
15+
^_pkgdown\.yml$
16+
^README\.Rmd$
17+
^renv$
18+
^renv\.lock$
19+
^scratch$

.github/workflows/R-CMD-check.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@
77
on:
88
push:
99
branches:
10-
- master
10+
- '*'
1111
pull_request:
1212
branches:
1313
- master
14+
- main
1415

1516
name: R-CMD-check
1617

@@ -34,11 +35,6 @@ jobs:
3435
# Linux
3536
- {os: ubuntu-18.04, r: 'release', installation_method: 'pip', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
3637
- {os: ubuntu-18.04, r: 'release', installation_method: 'conda', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
37-
# - {os: ubuntu-16.04, r: 'devel', installation_method: 'conda', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest", http-user-agent: "R/4.0.0 (ubuntu-16.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
38-
# - {os: ubuntu-16.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
39-
# - {os: ubuntu-16.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
40-
# - {os: ubuntu-16.04, r: '3.4', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
41-
# - {os: ubuntu-16.04, r: '3.3', rspm: "https://packagemanager.rstudio.com/cran/__linux__/xenial/latest"}
4238

4339
env:
4440
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
@@ -49,12 +45,12 @@ jobs:
4945
steps:
5046
- uses: actions/checkout@v2
5147

52-
- uses: r-lib/actions/setup-r@master
48+
- uses: r-lib/actions/setup-r@v1
5349
with:
5450
r-version: ${{ matrix.config.r }}
5551
http-user-agent: ${{ matrix.config.http-user-agent }}
5652

57-
- uses: r-lib/actions/setup-pandoc@master
53+
- uses: r-lib/actions/setup-pandoc@v1
5854

5955
- name: Query dependencies
6056
run: |
@@ -63,20 +59,20 @@ jobs:
6359
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
6460
shell: Rscript {0}
6561

66-
- name: Cache R packages
67-
if: runner.os != 'Windows'
68-
uses: actions/cache@v1
62+
- name: Restore R package cache
63+
uses: actions/cache@v2
6964
with:
7065
path: ${{ env.R_LIBS_USER }}
7166
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
7267
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
68+
7369
- name: Install system dependencies (Linux)
7470
if: runner.os == 'Linux'
7571
run: |
7672
while read -r cmd
7773
do
7874
eval sudo $cmd
79-
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
75+
done < <(Rscript -e 'writeLines(remotes::system_requirements("ubuntu", "18.04"))')
8076
8177
- name: Install system dependencies (brew)
8278
if: matrix.config.installation_method == 'brew'
@@ -111,6 +107,7 @@ jobs:
111107
env:
112108
_R_CHECK_CRAN_INCOMING_: false
113109
run: |
110+
options(crayon.enabled = TRUE)
114111
if (Sys.getenv("PRECOMMIT_INSTALLATION_METHOD") != 'conda') {
115112
Sys.setenv("_R_CHECK_FORCE_SUGGESTS_" = "False")
116113
}
@@ -129,3 +126,8 @@ jobs:
129126
with:
130127
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
131128
path: check
129+
130+
- name: Don't use tar from old Rtools to store the cache
131+
if: ${{ runner.os == 'Windows' && startsWith(steps.install-r.outputs.installed-r-version, '3.6' ) }}
132+
shell: bash
133+
run: echo "C:/Program Files/Git/usr/bin" >> $GITHUB_PATH

.github/workflows/end-to-end.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
on:
22
push:
33
branches:
4-
- master
4+
- '*'
55
pull_request:
66
branches:
77
- master
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
on:
2+
schedule:
3+
- cron: '50 08 18 * *'
4+
push:
5+
branches:
6+
- '*'
7+
8+
name: Hook dependency updates
9+
10+
jobs:
11+
hook-dependencies-update:
12+
runs-on: ubuntu-latest
13+
env:
14+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
15+
RENV_PATHS_ROOT: ~/.local/share/renv
16+
RSPM: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"
17+
steps:
18+
- uses: actions/checkout@v2
19+
20+
- uses: r-lib/actions/setup-r@v1
21+
22+
- name: Cache packages
23+
uses: actions/cache@v1
24+
with:
25+
path: ${{ env.RENV_PATHS_ROOT }}
26+
key: renv-${{ hashFiles('**/renv.lock') }}
27+
restore-keys: |
28+
renv-
29+
- name: Install system dependencies
30+
if: runner.os == 'Linux'
31+
env:
32+
RHUB_PLATFORM: linux-x86_64-ubuntu-gcc
33+
run: |
34+
Rscript -e "install.packages('remotes'); remotes::install_github('r-hub/sysreqs')"
35+
sysreqs=$(Rscript -e "cat(sysreqs::sysreq_commands('DESCRIPTION'))")
36+
sudo -s eval "$sysreqs"
37+
- name: update existing packages
38+
run: |
39+
install.packages('renv')
40+
install.packages('jsonlite')
41+
renv_deps <- names(jsonlite::read_json('renv.lock')$Packages)
42+
renv::load()
43+
renv::restore()
44+
can_be_updated <- renv::update(renv_deps)
45+
renv::snapshot(packages = renv_deps)
46+
shell: Rscript {0}
47+
- name: update dependency graph among packages
48+
run: |
49+
# also see corresponding files to update
50+
hook_deps <- function(root) {
51+
out <- renv::dependencies("inst/hooks/exported/")$Package
52+
desc <- desc::desc()
53+
deps <- desc$get_deps()
54+
dont <- c(
55+
"yaml", "usethis", "withr", "rstudioapi", "precommit",
56+
"httr" # lintr -> httr -> curl -> libcurl, but seems to give no erorr on
57+
# loading lintr, plus https://github.com/jimhester/lintr/issues/861
58+
)
59+
out <- c(out, "roxygen2", "spelling", "styler", "pkgload", "lintr", "knitr", "git2r", "digest", "desc")
60+
out <- setdiff(c(unique(c(out, deps[deps$type == "Imports", ]$package))), dont)
61+
out <- names(renv:::renv_package_dependencies(out))
62+
return(out)
63+
}
64+
65+
options(renv.snapshot.filter = hook_deps)
66+
67+
renv::snapshot(type = "custom", prompt = FALSE)
68+
# or renv::snapshot(packages = hook_deps(), prompt = FALSE)
69+
shell: Rscript {0}
70+
- name: Create Pull Request
71+
uses: peter-evans/[email protected]
72+
with:
73+
commit-message: Update renv dependencies
74+
branch: hook-dependencies-update
75+
delete-branch: true
76+
assignees: lorenzwalthert
77+
title: 'Hook dependencies update'
78+
body: |
79+
This PR updates the hook dependencies in `renv.lock`, auto-generated by [create-pull-request][1]. Close and re-open this to trigger `on: pull_request` events to circumvent [limitation of GitHub actions](https://github.com/peter-evans/create-pull-request/blob/master/docs/concepts-guidelines.md#push-pull-request-branches-to-a-fork).
80+
81+
[1]: https://github.com/peter-evans/create-pull-request
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
on:
2+
push:
3+
branches:
4+
- '*'
5+
pull_request:
6+
branches:
7+
- master
8+
9+
name: Legacy hook tests
10+
jobs:
11+
hook-test:
12+
runs-on: ${{ matrix.config.os }}
13+
14+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
15+
16+
strategy:
17+
fail-fast: false
18+
matrix:
19+
config:
20+
- {os: macOS-latest, r: 'release'}
21+
- {os: windows-latest, r: 'release'}
22+
- {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.0.0 (ubuntu-18.04) R (4.0.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" }
23+
env:
24+
RSPM: ${{ matrix.config.rspm }}
25+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
26+
27+
steps:
28+
- uses: actions/checkout@v2
29+
- uses: r-lib/actions/setup-r@master
30+
with:
31+
r-version: ${{ matrix.config.r }}
32+
http-user-agent: ${{ matrix.config.http-user-agent }}
33+
- name: checkout old hook scripts
34+
run: |
35+
git fetch origin refs/tags/v0.1.3:refs/tags/v0.1.3
36+
git checkout v0.1.3 -- inst/bin
37+
git checkout v0.1.3 -- tests/testthat/test-all.R
38+
git checkout v0.1.3 -- R/testing.R
39+
- name: Query dependencies
40+
run: |
41+
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version")
42+
shell: Rscript {0}
43+
- name: Cache R packages (macOs)
44+
if: startsWith(runner.os, 'macOS')
45+
uses: actions/cache@v2
46+
with:
47+
path: ~/Library/Application Support/renv
48+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }}
49+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
50+
- name: Cache R packages (Linux)
51+
if: startsWith(runner.os, 'Linux')
52+
uses: actions/cache@v2
53+
with:
54+
path: ~/.local/share/renv
55+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }}
56+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
57+
- name: Cache R packages (Windows)
58+
if: startsWith(runner.os, 'Windows')
59+
uses: actions/cache@v2
60+
with:
61+
path: ~\AppData\Local\renv
62+
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('renv.lock') }}
63+
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
64+
65+
- name: Install system dependencies (Linux)
66+
if: runner.os == 'Linux'
67+
run: |
68+
Rscript -e "install.packages('remotes', repos = Sys.getenv('RSPM'))"
69+
while read -r cmd
70+
do
71+
eval sudo $cmd
72+
done < <(Rscript -e 'cat(remotes::system_requirements("ubuntu", "18.04"), sep = "\n")')
73+
- name: Perpare testing environment
74+
run: |
75+
# testing dependencies (incl. {precommit}) live in global R library,
76+
# hook dependencies in renv, which is only activated when child R
77+
# process is invoked, e.g. as in run_test()
78+
if (!requireNamespace("renv", quietly = TRUE)) {
79+
install.packages("renv", repos = c(CRAN = "https://cloud.r-project.org"))
80+
}
81+
renv::install(c('testthat', 'devtools', 'desc', 'git2r'))
82+
renv::install(desc::desc_get_deps()$package) # install all deps
83+
renv::install(getwd())
84+
shell: Rscript {0}
85+
- name: Session info (testing environment)
86+
run: |
87+
renv::install('sessioninfo', repos = 'cloud.r-project.org')
88+
options(width = 100)
89+
pkgs <- installed.packages()[, "Package"]
90+
sessioninfo::session_info(pkgs, include_base = TRUE)
91+
shell: Rscript {0}
92+
- name: Test
93+
run: |
94+
devtools::load_all()
95+
testthat::test_file(
96+
"tests/testthat/test-all.R",
97+
reporter = testthat::MultiReporter$new(list(
98+
testthat::CheckReporter$new(), testthat::FailReporter$new()
99+
))
100+
)
101+
shell: Rscript {0}
102+
- name: Show testthat output
103+
if: always()
104+
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
105+
shell: bash
106+
- name: Upload check results
107+
if: failure()
108+
uses: actions/upload-artifact@main
109+
with:
110+
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
111+
path: check

0 commit comments

Comments
 (0)