Skip to content

Commit

Permalink
Merge branch 'r-lib:main' into merge
Browse files Browse the repository at this point in the history
  • Loading branch information
olivroy authored Jun 26, 2024
2 parents 1497d10 + 83a6b5f commit 7cb633c
Show file tree
Hide file tree
Showing 13 changed files with 78 additions and 36 deletions.
22 changes: 10 additions & 12 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ on:

name: R-CMD-check

permissions: read-all

jobs:
R-CMD-check:
runs-on: ${{ matrix.config.os }}
Expand All @@ -25,17 +27,15 @@ jobs:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -54,7 +54,7 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck, magick=?ignore-before-r=4.0.0
extra-packages: any::rcmdcheck
needs: check

- name: Configure Git User
Expand All @@ -64,8 +64,6 @@ jobs:
git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
- uses: r-lib/actions/check-r-package@v2
env:
_R_CALLS_INVALID_NUMERIC_VERSION_: true
_R_CHECK_FORCE_SUGGESTS_: false
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
2 changes: 2 additions & 0 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ on:

name: pkgdown

permissions: read-all

jobs:
pkgdown:
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:

name: Commands

permissions: read-all

jobs:
document:
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
Expand Down
17 changes: 14 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ on:

name: test-coverage

permissions: read-all

jobs:
test-coverage:
runs-on: ubuntu-latest
Expand All @@ -23,7 +25,7 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::covr
extra-packages: any::covr, any::xml2
needs: coverage

- name: git config
Expand All @@ -33,18 +35,27 @@ jobs:
- name: Test coverage
run: |
covr::codecov(
cov <- covr::package_coverage(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
covr::to_cobertura(cov)
shell: Rscript {0}

- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: ${{ github.event_name != 'pull_request' && true || false }}
file: ./cobertura.xml
plugin: noop
disable_search: true
token: ${{ secrets.CODECOV_TOKEN }}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
find '${{ runner.temp }}/package' -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Description: Automate package and project setup tasks that are otherwise
License: MIT + file LICENSE
URL: https://usethis.r-lib.org, https://github.com/r-lib/usethis
BugReports: https://github.com/r-lib/usethis/issues
Depends:
Depends:
R (>= 3.6)
Imports:
Imports:
cli (>= 3.0.1),
clipr (>= 0.3.0),
crayon,
Expand All @@ -43,7 +43,7 @@ Imports:
whisker,
withr (>= 2.3.0),
yaml
Suggests:
Suggests:
covr,
knitr,
magick,
Expand Down
5 changes: 3 additions & 2 deletions R/logo.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,14 @@
use_logo <- function(img, geometry = "240x278", retina = TRUE) {
check_is_package("use_logo()")

logo_path <- proj_path("man", "figures", "logo", ext = path_ext(img))
ext <- tolower(path_ext(img))
logo_path <- proj_path("man", "figures", "logo", ext = ext)
create_directory(path_dir(logo_path))
if (!can_overwrite(logo_path)) {
return(invisible(FALSE))
}

if (path_ext(img) == "svg") {
if (ext == "svg") {
logo_path <- path("man", "figures", "logo.svg")
file_copy(img, proj_path(logo_path), overwrite = TRUE)
ui_bullets(c("v" = "Copied {.path {pth(img)}} to {.path {logo_path}}."))
Expand Down
3 changes: 2 additions & 1 deletion R/roxygen.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ check_uses_roxygen <- function(whos_asking) {
return(invisible())
}

whos_asking_fn <- sub("()", "", whos_asking, fixed = TRUE)
ui_abort(c(
"Package {.pkg {project_name()}} does not use roxygen2.",
"{.fun {whos_asking}} can not work without it.",
"{.fun {whos_asking_fn}} can not work without it.",
"You might just need to run {.run devtools::document()} once, then try again."
))
}
5 changes: 3 additions & 2 deletions R/use_import_from.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,16 @@ check_has_package_doc <- function(whos_asking) {
return(invisible(TRUE))
}

whos_asking_fn <- sub("()", "", whos_asking, fixed = TRUE)
msg <- c(
"!" = "{.fun {whos_asking}} requires package-level documentation.",
"!" = "{.fun {whos_asking_fn}} requires package-level documentation.",
" " = "Would you like to add it now?"
)
if (is_interactive() && ui_yep(msg)) {
use_package_doc()
} else {
ui_abort(c(
"{.fun {whos_asking}} requires package-level documentation.",
"{.fun {whos_asking_fn}} requires package-level documentation.",
"You can add it by running {.run usethis::use_package_doc()}."
))
}
Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/_snaps/logo.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,13 @@
[ ] Add logo to 'README.md' with the following html:
# {TESTPKG} <img src="man/figures/logo.png" align="right" height="90" alt="" />

# use_logo() writes a file in lowercase and it knows that

Code
use_logo("LoGo.PNG")
Message
v Creating 'man/figures/'.
v Resized 'LoGo.PNG' to 240x278.
[ ] Add logo to your README with the following html:
# {TESTPKG} <img src="man/figures/logo.png" align="right" height="90" alt="" />

2 changes: 1 addition & 1 deletion tests/testthat/_snaps/tibble.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# use_tibble() Imports tibble
# use_tibble() Imports tibble and imports tibble::tibble()

Code
use_tibble()
Expand Down
22 changes: 11 additions & 11 deletions tests/testthat/_snaps/utils-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,10 @@
ui_code_snippet(
"\n options(\n warnPartialMatchArgs = TRUE,\n warnPartialMatchDollar = TRUE,\n warnPartialMatchAttr = TRUE\n )")
Message
[36moptions[39m[33m([39m
warnPartialMatchArgs = [34mTRUE[39m,
warnPartialMatchDollar = [34mTRUE[39m,
warnPartialMatchAttr = [34mTRUE[39m
[1moptions[22m[33m([39m
warnPartialMatchArgs = [35mTRUE[39m,
warnPartialMatchDollar = [35mTRUE[39m,
warnPartialMatchAttr = [35mTRUE[39m
)

# ui_code_snippet() with vector input [plain]
Expand All @@ -167,10 +167,10 @@
ui_code_snippet(c("options(", " warnPartialMatchArgs = TRUE,",
" warnPartialMatchDollar = TRUE,", " warnPartialMatchAttr = TRUE", ")"))
Message
[36moptions[39m[33m([39m
warnPartialMatchArgs = [34mTRUE[39m,
warnPartialMatchDollar = [34mTRUE[39m,
warnPartialMatchAttr = [34mTRUE[39m
[1moptions[22m[33m([39m
warnPartialMatchArgs = [35mTRUE[39m,
warnPartialMatchDollar = [35mTRUE[39m,
warnPartialMatchAttr = [35mTRUE[39m
)

# ui_code_snippet() when language is not R [plain]
Expand Down Expand Up @@ -199,7 +199,7 @@
Code
ui_code_snippet("if (1) {true_val} else {false_val}")
Message
[31mif[39m [33m([39m[34m1[39m[33m)[39m [34mTRUE[39m [31melse[39m [33m'FALSE'[39m
[33mif[39m [33m([39m[35m1[39m[33m)[39m [35mTRUE[39m [33melse[39m [36m'FALSE'[39m

# ui_code_snippet() can NOT interpolate [plain]

Expand All @@ -217,11 +217,11 @@
Code
ui_code_snippet("foo <- function(x){x}", interpolate = FALSE)
Message
foo [32m<-[39m [31mfunction[39m[33m([39mx[33m)[39m[33m{[39mx[33m}[39m
foo [33m<-[39m [33mfunction[39m[33m([39mx[33m)[39m[33m{[39mx[33m}[39m
Code
ui_code_snippet("foo <- function(x){{x}}", interpolate = TRUE)
Message
foo [32m<-[39m [31mfunction[39m[33m([39mx[33m)[39m[33m{[39mx[33m}[39m
foo [33m<-[39m [33mfunction[39m[33m([39mx[33m)[39m[33m{[39mx[33m}[39m

# bulletize() works

Expand Down
13 changes: 13 additions & 0 deletions tests/testthat/test-logo.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,16 @@ test_that("use_logo() shows a clickable path with README", {
withr::local_options(usethis.quiet = FALSE)
expect_snapshot(use_logo("logo.png"), transform = scrub_testpkg)
})

# https://github.com/r-lib/usethis/issues/1999
test_that("use_logo() writes a file in lowercase and it knows that", {
skip_if_not_installed("magick")
skip_on_os("solaris")

create_local_package()
img <- magick::image_write(magick::image_read("logo:"), "LoGo.PNG")

withr::local_options(list(usethis.quiet = FALSE))
expect_snapshot(use_logo("LoGo.PNG"), transform = scrub_testpkg)
expect_proj_file("man", "figures", "logo.png")
})
5 changes: 4 additions & 1 deletion tests/testthat/test-tibble.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ test_that("use_tibble() requires a package", {
expect_usethis_error(use_tibble(), "not an R package")
})

test_that("use_tibble() Imports tibble", {
test_that("use_tibble() Imports tibble and imports tibble::tibble()", {
create_local_package()

withr::local_options(list(usethis.quiet = FALSE))
Expand All @@ -18,4 +18,7 @@ test_that("use_tibble() Imports tibble", {
)

expect_match(proj_desc()$get("Imports"), "tibble")

pkg_doc <- readLines(package_doc_path())
expect_match(pkg_doc, "#' @importFrom tibble tibble", all = FALSE)
})

0 comments on commit 7cb633c

Please sign in to comment.