Skip to content

Commit

Permalink
Merge pull request #63 from ThinkR-open/att-rebase-0.3
Browse files Browse the repository at this point in the history
Att rebase 0.3
  • Loading branch information
statnmap authored Sep 19, 2022
2 parents 5893625 + 622da15 commit 4772336
Show file tree
Hide file tree
Showing 18 changed files with 294 additions and 59 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/R-CMD-check-HTML5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check-HTML5

jobs:
R-CMD-check:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
_R_CHECK_RD_VALIDATE_RD2HTML_: TRUE
steps:
- uses: actions/checkout@v2

- name: Install pdflatex
run: sudo apt-get install texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra

- name: Install tidy
run: sudo apt install tidy

- uses: r-lib/actions/setup-r@v2
with:
r-version: 'devel'
http-user-agent: 'release'
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
args: '"--as-cran"'
build_args: 'character()'
error-on: '"note"'
17 changes: 8 additions & 9 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: attachment
Title: Deal with Dependencies
Version: 0.2.5.9000
Version: 0.3.0
Authors@R:
c(person(given = "Sébastien",
family = "Rochette",
Expand All @@ -15,18 +15,17 @@ Authors@R:
"previous maintainer")),
person(given = "ThinkR",
role = c("cph", "fnd")))
Description: Tools to help manage dependencies during package
development. This can retrieve all dependencies that are used in R
files in the "R" directory, in Rmd files in "vignettes" directory and
Description: Manage dependencies during package
development. This can retrieve all dependencies that are used in ".R"
files in the "R/" directory, in ".Rmd" files in "vignettes/" directory and
in 'roxygen2' documentation of functions. There is a function to
update the Description file of your package and a function to create a
file with the R commands to install all dependencies of your package.
All functions to retrieve dependencies of R scripts and Rmd files can
update the "DESCRIPTION" file of your package with 'CRAN' packages or any other remote package.
All functions to retrieve dependencies of ".R" scripts and ".Rmd" or ".qmd" files can
be used independently of a package development.
License: GPL-3
URL: https://thinkr-open.github.io/attachment/,
https://github.com/Thinkr-open/attachment
BugReports: https://github.com/Thinkr-open/attachment/issues
https://github.com/ThinkR-open/attachment
BugReports: https://github.com/ThinkR-open/attachment/issues
VignetteBuilder:
knitr
Encoding: UTF-8
Expand Down
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ export("%>%")
export(att_amend_desc)
export(att_from_description)
export(att_from_namespace)
export(att_from_qmd)
export(att_from_qmds)
export(att_from_rmd)
export(att_from_rmds)
export(att_from_rscript)
Expand Down
6 changes: 3 additions & 3 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# attachment (development version)
# attachment 0.3.0

## New features

- `set_remotes_to_desc()` now detects github, gitlab, git, local installations (@MurielleDelmotte)
- `find_remotes()` and `set_remotes_to_desc()` now detects github, gitlab, git, bitbucket, local installations to add to the "Remotes:" part of the DESCRIPTION file (@MurielleDelmotte)
- Quarto documents can be parsed with `att_from_qmds()` as an alias of `att_from_rmds()`.

## Minor changes

- Quarto documents can be parsed with `att_from_rmds()`.
- Documentation for bookdown and quarto dependencies extraction updated

## Bug fixes
Expand Down
9 changes: 9 additions & 0 deletions R/att_from_rmds.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,12 @@ att_from_rmds <- function(path = "vignettes",
res
}
}

#' @rdname att_from_rmds
#' @export
att_from_qmds <- att_from_rmds

#' @rdname att_from_rmd
#' @export
att_from_qmd <- att_from_rmd

8 changes: 7 additions & 1 deletion R/attachment-deprecated.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
#' Deprecated functions
#'
#' @name attachment-deprecated
#' @description
#' List of functions deprecated. They will be removed in a future release.
#'
#'
#' @name attachment-deprecated
#' @keywords internal
#' @return List of functions used for deprecation side effects.
#' Output depends on the deprecated function.
#' @section Details:
#' \tabular{rl}{
#' `att_to_description` \tab is now called `att_amend_desc`
Expand Down
52 changes: 38 additions & 14 deletions R/set_remotes.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#' @param pkg Character. Packages to test for potential non-CRAN installation
#'
#' @return
#' List of non-CRAN packages and code to add in Remotes field in DESCRIPTION
#' List of all non-CRAN packages and code to add in Remotes field in DESCRIPTION.
#' NULL otherwise.
#' @importFrom utils packageDescription
#' @export
#'
#' @examples
Expand All @@ -15,10 +17,16 @@
#' path = file.path(dummypackage, "DESCRIPTION")) %>%
#' find_remotes()
#' \dontrun{
#' # For your current directory
#' # For the current package directory
#' att_from_description() %>% find_remotes()
#' # Find from all installed packages
#' head(find_remotes(installed.packages()[,1]))
#' }
#'
#' \donttest{
#' # For a specific package name
#' find_remotes("attachment")
#'
#' # Find remotes from all installed packages
#' find_remotes(list.dirs(.libPaths(), full.names = FALSE, recursive = FALSE))
#' }
find_remotes <- function(pkg) {

Expand All @@ -27,6 +35,19 @@ find_remotes <- function(pkg) {
}) %>%
setNames(pkg)

# Keep only thos that are packages
w.notpkg <- which(unlist(lapply(pkgdesc, function(x) all(is.na(x)))))
if (length(w.notpkg) != 0) {
message(glue::glue_collapse(names(pkgdesc)[w.notpkg], sep = ", ", last = " & "),
ifelse(length(w.notpkg) == 1,
" does not seem to be a package. It is removed from exploration.",
" do not seem to be packages. They are removed from exploration."
)
)
pkgdesc <- pkgdesc[-w.notpkg]
if (length(pkgdesc) == 0) {return(NULL)}
}

extract_pkg_info(pkgdesc)
}

Expand Down Expand Up @@ -112,6 +133,7 @@ internal_remotes_to_desc <- function(remotes, path.d = "DESCRIPTION",

w.unique <- !duplicated(names(new_remotes))
new_remotes <- unlist(new_remotes)[w.unique]
new_remotes <- new_remotes[sort(names(new_remotes))]

if (length(new_remotes) != 0) {
desc$set_remotes(new_remotes)
Expand Down Expand Up @@ -146,22 +168,24 @@ extract_pkg_info <- function(pkgdesc) {
guess_repo <- lapply(pkg_not_cran, function(x) {
desc <- pkgdesc[[x]]
if (!is.null(desc$RemoteType) && desc$RemoteType == "github") {
tolower(paste(desc$RemoteUsername, desc$RemoteRepo, sep = "/"))
paste(desc$RemoteUsername, desc$RemoteRepo, sep = "/")
} else if (!is.null(desc$RemoteType) && desc$RemoteType %in% c("gitlab", "bitbucket")) {
tolower(paste0(desc$RemoteType, "::",
paste(desc$RemoteUsername, desc$RemoteRepo, sep = "/")))
paste0(desc$RemoteType, "::",
paste(desc$RemoteUsername, desc$RemoteRepo, sep = "/"))
} else if (desc$RemoteType == "local" && !is.null(desc$RemoteUrl) && is.null(desc$RemoteHost)) {
tolower(paste0(desc$RemoteType, "::", desc$RemoteUrl))
} else if (!is.null(desc$RemoteType) && !(desc$RemoteType %in% c("github","gitlab","bitbucket","local")) && grepl(".git",x = desc$RemoteUrl) ){
tolower(paste0("git::",desc$RemoteUrl))
paste0(desc$RemoteType, "::", desc$RemoteUrl)
} else if (!is.null(desc$RemoteType) &&
!(desc$RemoteType %in% c("github","gitlab","bitbucket","local")) &&
grepl("git",x = desc$RemoteType) ){
paste0("git::",desc$RemoteUrl)
} else if (is.null(desc$RemoteType) && isTRUE(grepl("bioconductor",x = desc$URL))) {
biocversion <- desc$git_branch %>%
gsub(pattern = "RELEASE_", replacement = "") %>%
gsub(pattern = "_", replacement = ".")
tolower(paste0("bioc::",biocversion,"/",desc$Package))
} else if (!is.null(desc$RemoteType) && is.null(desc$RemoteHost)) {
c("Maybe ?" = tolower(paste0(desc$RemoteType, "::", desc$RemoteHost, ":",
paste(desc$RemoteUsername, desc$RemoteRepo, sep = "/"))))
paste0("bioc::",biocversion,"/",desc$Package)
} else if (!is.null(desc$RemoteType) && !is.null(desc$RemoteHost)) {
c("Maybe ?" = paste0(desc$RemoteType, "::", desc$RemoteHost, ":",
paste(desc$RemoteUsername, desc$RemoteRepo, sep = "/")))
} else {
c("local maybe ?" = NA)
}
Expand Down
17 changes: 13 additions & 4 deletions dev/dev_history.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ usethis::use_appveyor()
usethis::use_github_action_check_standard()
usethis::use_github_action("pkgdown")
usethis::use_github_action("test-coverage")
usethis::use_github_action(url = "https://github.com/DavisVaughan/extrachecks-html5/blob/main/R-CMD-check-HTML5.yaml")

usethis::use_vignette("use_renv")
usethis::use_build_ignore("_pkgdown.yml")
Expand All @@ -79,7 +80,8 @@ usethis::use_roxygen_md()
roxygen2md::roxygen2md()
roxygen2::roxygenise()
attachment::att_amend_desc(
pkg_ignore = c("remotes", "i", "usethis", "rstudioapi", "renv"), #i
pkg_ignore = c("remotes", "i", "usethis", "rstudioapi", "renv",
"gitlab", "git", "local", "find.rscript", "bioc"), #i
extra.suggests = c("testthat", "rstudioapi", "renv", "lifecycle"), #"pkgdown", "covr",
dir.t = "",
normalize = FALSE)
Expand Down Expand Up @@ -108,6 +110,9 @@ devtools::test()
devtools::load_all()
testthat::test_file(here::here("tests/testthat/test-amend-description.R"))

# Test for dependencies
tools:::.check_packages_used_in_tests(dir = ".", testdir = "tests/testthat")

# Checks for CRAN release ----
# Check package as CRAN
rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"))
Expand All @@ -128,19 +133,22 @@ urlchecker::url_update()

# check on other distributions
# _rhub
devtools::check_rhub()
# devtools::check_rhub()
rhub::local_check_linux_images()
rhub::local_check_linux(image = "rhub/debian-gcc-release")
rhub::local_check_linux(image = "rhub/debian-clang-devel")

rhub::platforms()
rhub::check(platform = "windows-x86_64-devel", show_status = FALSE)
rhub::check(platform = "windows-x86_64-oldrel", show_status = FALSE)
rhub::check_on_solaris(show_status = FALSE)
aa <- rhub::check_for_cran(show_status = FALSE)
aa
rhub::check_for_cran(show_status = FALSE)


# _win devel
devtools::check_win_devel()
devtools::check_win_release()
devtools::check_win_oldrelease()
devtools::check_mac_release()

# Check reverse dependencies
Expand All @@ -157,6 +165,7 @@ id <- rstudioapi::terminalExecute("Rscript -e 'revdepcheck::revdep_check(num_wor
rstudioapi::terminalKill(id)
# See outputs
revdep_details(revdep = "fusen")
revdep_details(revdep = "golem")
revdep_summary()
# table of results by package
revdep_report() # in revdep/
Expand Down
3 changes: 3 additions & 0 deletions inst/dummypackage/tests/testthat/test-addition.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test_that("Add works", {
expect_equal(1 + 1, 2)
})
10 changes: 10 additions & 0 deletions man/att_from_rmd.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions man/att_from_rmds.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion man/attachment-deprecated.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions man/attachment-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4772336

Please sign in to comment.