Skip to content

Commit

Permalink
Merge pull request #69 from inbo/cran
Browse files Browse the repository at this point in the history
avoid checks on CRAN
  • Loading branch information
ThierryO authored Nov 3, 2021
2 parents 3d8da38 + ed5ee4a commit bfd2642
Show file tree
Hide file tree
Showing 48 changed files with 603 additions and 166 deletions.
5 changes: 4 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
^_pkgdown.yml$
^.*\.Rproj$
^.*\.zenodo.json$
^.dockerignore$
^\.github$
^\.httr-oauth$
^\.Rproj\.user$
^\.zenodo\.json$
^checklist.yml$
^CITATION\.cff$
^codecov\.yml$
^codemeta\.json$
^data-raw$
^docker-compose.test.yml$
^docker$
^Dockerfile$
^docker-compose.test.yml$
^docs$
^LICENSE.md$
^man-roxygen$
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/check_on_branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ jobs:
check-package:
runs-on: ubuntu-latest
name: "check package"
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ORCID_TOKEN: ${{ secrets.ORCID_TOKEN }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: inbo/actions/check_pkg@master
with:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ORCID_TOKEN: ${{ secrets.ORCID_TOKEN }}
1 change: 1 addition & 0 deletions .github/workflows/check_on_different_r_os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,4 @@ jobs:
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
retention-days: 5
8 changes: 4 additions & 4 deletions .github/workflows/check_on_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
check-package:
runs-on: ubuntu-latest
name: "check package"
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ORCID_TOKEN: ${{ secrets.ORCID_TOKEN }}
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: inbo/actions/check_pkg@master
with:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
ORCID_TOKEN: ${{ secrets.ORCID_TOKEN }}
token: ${{ secrets.pat }}
18 changes: 0 additions & 18 deletions .github/workflows/remove_old_artifacts.yml

This file was deleted.

41 changes: 21 additions & 20 deletions .zenodo.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
{
"title": "A Thorough and Strict Set of Checks for R Packages and Source Code",
"description": "An opinated set of rules for R packages and R source code projects an used at the Research Institute for Nature and Forest (INBO), Brussels, Belgium (<a href=\"https://www.inbo.be/en\">www.inbo.be</a>).",
"license": "GPL-3.0",
"upload_type": "other",
"access_right": "open",
"creators": [
{
"name": "Onkelinx, Thierry",
"affiliation": "Research Institute for Nature and Forest",
"orcid": "0000-0001-8804-4216"
}
],
"keywords": [
"R",
"package",
"open science",
"continous integreation",
"unit test",
"code style"
]
"title": ["checklist: A Thorough and Strict Set of Checks for R Packages and Source Code"],
"version": ["0.1.14"],
"description": ["An opinated set of rules for R packages and R source code projects."],
"creators": [
{
"name": ["Onkelinx, Thierry"],
"orcid": ["https://orcid.org/0000-0001-8804-4216"]
}
],
"contributors": [
{
"name": ["Lommelen, Els"],
"orcid": ["https://orcid.org/0000-0002-3481-5684"]
}
],
"upload_type": ["software"],
"access_rights": ["open"],
"license": ["GPL-3.0"],
"communities": {
"identifier": ["inbo"]
}
}
22 changes: 22 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
cff-version: 1.2.0
message: If you use this software, please cite it as below.
authors:
- family-names: Onkelinx
given-names: Thierry
orcid: https://orcid.org/0000-0001-8804-4216
contact:
- email: [email protected]
family-names: Onkelinx
given-names: Thierry
- email: [email protected]
name: Research Institute for Nature and Forest
title: 'checklist: A Thorough and Strict Set of Checks for R Packages and Source Code'
version: 0.1.14
abstract: An opinated set of rules for R packages and R source code projects.
license: GPL-3.0
type: software
doi: 10.5281/zenodo.4028303
repository-code: https://github.com/inbo/checklist
identifiers:
- type: url
value: https://inbo.github.io/checklist/
26 changes: 10 additions & 16 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,21 +1,14 @@
Type: Package
Package: checklist
Title: A Thorough and Strict Set of Checks for R Packages and Source Code
Version: 0.1.13
Authors@R:
c(person(given = "Thierry",
family = "Onkelinx",
role = c("aut", "cre"),
email = "[email protected]",
comment = c(ORCID = "0000-0001-8804-4216")),
person(given = "Els",
family = "Lommelen",
role = "ctb",
email = "[email protected]",
comment = c(ORCID = "0000-0002-3481-5684")),
person(given = "Research Institute for Nature and Forest",
role = c("cph", "fnd"),
email = "[email protected]"))
Version: 0.1.14
Authors@R: c(
person("Thierry", "Onkelinx", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-8804-4216")),
person("Els", "Lommelen", , "[email protected]", role = "ctb",
comment = c(ORCID = "0000-0002-3481-5684")),
person("Research Institute for Nature and Forest", , , "[email protected]", role = c("cph", "fnd"))
)
Description: An opinated set of rules for R packages and R source code
projects.
License: GPL-3
Expand All @@ -30,6 +23,7 @@ Imports:
devtools (> 2.4.0),
git2r,
httr,
jsonlite,
lintr,
pkgdown,
rcmdcheck,
Expand All @@ -53,4 +47,4 @@ Additional_repositories: https://ropensci.r-universe.dev
Encoding: UTF-8
LazyData: true
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
3 changes: 3 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export(tidy_desc)
export(update_citation)
export(validate_email)
export(write_checklist)
export(write_citation_cff)
export(write_zenodo_json)
export(yesno)
importFrom(R6,R6Class)
importFrom(assertthat,"on_failure<-")
Expand Down Expand Up @@ -75,6 +77,7 @@ importFrom(grDevices,svg)
importFrom(graphics,plot.new)
importFrom(graphics,text)
importFrom(httr,HEAD)
importFrom(jsonlite,toJSON)
importFrom(lintr,lint_dir)
importFrom(lintr,lint_package)
importFrom(pkgdown,build_site)
Expand Down
14 changes: 14 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# checklist 0.1.14

* Improve error message when changes in `CITATION` need to be commit. (#64)
* `create_package()` can use maintainer information stored in the options.
See `usethis::use_description()` on how to set the option.
* Add R universe badges to README.
* Add `write_zenodo_json()` and `write_citation_cff()`.
* Improve the checklist Github Actions.

## Bugfix

* `create_package()` replaces package name place holder with actual package name
in `_pkgdown.yml`.

# checklist 0.1.13

* A new function `update_citation()` creates or updates a default citation in
Expand Down
11 changes: 10 additions & 1 deletion R/check_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ tidy_desc <- function(x = ".") {

unchanged_repo <- function(repo, old_status) {
current_status <- status(repo)
identical(
ok <- identical(
current_status$staged,
old_status$staged
) &&
Expand All @@ -186,6 +186,15 @@ unchanged_repo <- function(repo, old_status) {
current_status$untracked,
old_status$untracked
)
new_files <- unlist(current_status)
old_files <- unlist(old_status)
changes <- c(
new_files[!new_files %in% old_files], old_files[!old_files %in% new_files]
)
attr(ok, "files") <- sprintf(
"changed files:\n%s", paste(changes, collapse = "\n")
)
return(ok)
}

#' Check the license of a package
Expand Down
14 changes: 9 additions & 5 deletions R/check_documentation.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,24 @@ check_documentation <- function(x = ".") {
repo <- repository(x$get_path)
status_before <- status(repo)
document(x$get_path)
detect_changes <- unchanged_repo(repo, status_before)
si <- session_info(pkgs = "roxygen2")
doc_error <- c(
doc_error,
"Missing documentation. Run `devtools::document()`"[
!unchanged_repo(repo, status_before)
]
sprintf(
"Running `devtools::document()` with roxygen2 %s %s",
si$packages$loadedversion[si$packages$package == "roxygen2"],
attr(detect_changes, "files")
)[!detect_changes]
)

if (file_test("-f", file.path(x$get_path, "README.Rmd"))) {
status_before <- status(repo)
build_readme(x$get_path, encoding = "UTF-8")
current <- unlist(status(repo, ignored = TRUE))
doc_error <- c(
doc_error,
"`README.Rmd` need to be rendered. Run `devtools::build_readme()`"[
!unchanged_repo(repo, status_before)
"README.md" %in% current
]
)
}
Expand Down
2 changes: 1 addition & 1 deletion R/check_filename.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ Failing folder: `%s`",
paste(
c(
"\\.[a-zA-Z]+ignore", "\\.Rprofile", "\\.[a-zA-Z]+\\.(json|yml)",
"CITATION", "DESCRIPTION", "NAMESPACE",
"CITATION", "DESCRIPTION", "NAMESPACE", "CITATION.cff",
"README\\.R?md", "NEWS\\.md", # nolint
"CODE_OF_CONDUCT.md", "CONTRIBUTING.md", "LICENSE.md", "SUPPORT.md",
"SECURITY.md", "FUNDING.yml",
Expand Down
31 changes: 17 additions & 14 deletions R/create_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#' @param maintainer The output of [utils::person()] or [`orcid2person()`].
#' If you use [utils::person()], then you must provide `given`, `family`,
#' `role`, `email` and `comment` with valid `ORCID`.
#' When missing, the functions looks for `usethis.description` in the options.
#' See [usethis::use_description()] for more information.
#' @export
#' @importFrom assertthat assert_that is.string
#' @importFrom git2r add init
Expand Down Expand Up @@ -48,6 +50,17 @@ create_package <- function(
msg =
"Please install the `roxygen2` package. `install.packages(\"roxygen2\")`"
)
if (missing(maintainer)) {
utd <- getOption("usethis.description")
assert_that(
has_name(utd, "Authors@R"),
msg = paste(
"maintainer not provided and no usethis::use_description defaults",
"available."
)
)
maintainer <- head(eval(parse(text = utd$"Authors@R")), 1)
}
assert_that(inherits(maintainer, "person"))
assert_that(dir.exists(path), msg = sprintf("`%s` is not a directory", path))
assert_that(is.string(package))
Expand Down Expand Up @@ -241,25 +254,15 @@ allowed:
add(
repo = repo, file.path(".github", "workflows", "release.yml"), force = TRUE
)
file.copy(
system.file(
file.path("package_template", "remove_old_artifacts.yml"),
package = "checklist"
),
file.path(path, ".github", "workflows", "remove_old_artifacts.yml"),
overwrite = TRUE
)
add(
repo = repo, file.path(".github", "workflows", "release.yml"), force = TRUE
)

# prepare pkgdown
file.copy(
pkgd <- readLines(
system.file(
file.path("package_template", "_pkgdown.yml"), package = "checklist"
),
file.path(path, "_pkgdown.yml")
)
)
pkgd <- gsub("\\{\\{\\{ Package \\}\\}\\}", package, pkgd)
writeLines(pkgd, file.path(path, "_pkgdown.yml"))
add(repo = repo, "_pkgdown.yml")

dir.create(file.path(path, "pkgdown"), showWarnings = FALSE)
Expand Down
18 changes: 4 additions & 14 deletions R/setup_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,15 @@ allowed:
add(
repo = repo, file.path(".github", "workflows", "release.yml"), force = TRUE
)
file.copy(
system.file(
file.path("package_template", "remove_old_artifacts.yml"),
package = "checklist"
),
file.path(path, ".github", "workflows", "remove_old_artifacts.yml"),
overwrite = TRUE
)
add(
repo = repo, file.path(".github", "workflows", "release.yml"), force = TRUE
)

# Add pkgdown website
file.copy(
pkgd <- readLines(
system.file(
file.path("package_template", "_pkgdown.yml"), package = "checklist"
),
file.path(path, "_pkgdown.yml")
)
)
pkgd <- gsub("\\{\\{\\{ Package \\}\\}\\}", package, pkgd)
writeLines(pkgd, file.path(path, "_pkgdown.yml"))
add(repo = repo, "_pkgdown.yml", force = TRUE)
dir.create(file.path(path, "pkgdown"), showWarnings = FALSE)
file.copy(
Expand Down
Loading

0 comments on commit bfd2642

Please sign in to comment.