Skip to content

Commit

Permalink
Merge pull request #28 from inbo/0.1.7
Browse files Browse the repository at this point in the history
0.1.7
  • Loading branch information
ThierryO authored Jan 13, 2021
2 parents 5b7b460 + fd11bf2 commit 2030bdd
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check_on_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
branches:
- master
schedule:
- cron: '6 0 * * 1'
- cron: '6 0 15 * *'

name: "check package on master"

Expand Down
6 changes: 3 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: checklist
Title: A Thorough and Strict Set of Checks for R Packages and Source Code
Version: 0.1.6
Version: 0.1.7
Authors@R:
c(person(given = "Thierry",
family = "Onkelinx",
Expand All @@ -14,7 +14,8 @@ Authors@R:
Description: An opinated set of rules for R packages and R source code
projects.
License: GPL-3
URL: https://inbo.github.io/checklist, https://github.com/inbo/checklist
URL: https://inbo.github.io/checklist, https://github.com/inbo/checklist,
https://doi.org/10.5281/zenodo.4028303
BugReports: https://github.com/inbo/checklist/issues
Imports:
R6,
Expand All @@ -26,7 +27,6 @@ Imports:
httr,
lintr,
rcmdcheck,
rmarkdown,
rorcid,
sessioninfo,
utils,
Expand Down
3 changes: 1 addition & 2 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ importFrom(assertthat,noNA)
importFrom(codemetar,give_opinions)
importFrom(desc,desc)
importFrom(desc,description)
importFrom(devtools,build_readme)
importFrom(devtools,document)
importFrom(git2r,add)
importFrom(git2r,branch_target)
Expand All @@ -56,8 +57,6 @@ importFrom(httr,add_headers)
importFrom(lintr,lint_dir)
importFrom(lintr,lint_package)
importFrom(rcmdcheck,rcmdcheck)
importFrom(rmarkdown,github_document)
importFrom(rmarkdown,render)
importFrom(rorcid,as.orcid)
importFrom(sessioninfo,session_info)
importFrom(stats,na.omit)
Expand Down
9 changes: 9 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# checklist 0.1.7

* Pushing to master should automatically create a release, using `set_tag()`.
* Add a Zenodo DOI badge to the README and DOI URL to DESCRIPTION.
* `check_description()` now checks authors (#7).
* INBO is set as copyright holder and funder.
* Every author has an ORCID.
* `setup_package()` adds the required files for a `pkgdown` website (#21).

# checklist 0.1.6

* Drop the `codemeta.json` file.
Expand Down
26 changes: 24 additions & 2 deletions R/check_description.R
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ check_description <- function(x = ".") {
desc_error,
"DESCRIPTION not tidy. Use `checklist::tidy_desc()`"[
!unchanged_repo(repo, status_before)
]
],
check_authors(description)
)

x$add_error(desc_error, "DESCRIPTION")

check_license(x = x)
Expand Down Expand Up @@ -197,3 +197,25 @@ Please send a pull request if you need support for this license.",

return(x)
}

check_authors <- function(description) {
authors <- description$get_authors()
authors <- lapply(authors, unlist, recursive = FALSE)
inbo <- person(
given = "Research Institute for Nature and Forest",
role = c("cph", "fnd"), email = "[email protected]"
)
problems <- paste(
"Research Institute for Nature and Forest must be listed as copyright",
"holder and funder and use [email protected] as email."
)[!inbo %in% authors]
authors <- authors[!authors %in% inbo]
orcid <- sapply(authors, `[[`, "comment")
c(
problems,
"Every author and contributor must have an ORCID"[
any(names(orcid) != "ORCID")
]
)

}
9 changes: 2 additions & 7 deletions R/check_documentation.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#' Check the documentation
#' @inheritParams read_checklist
#' @export
#' @importFrom devtools document
#' @importFrom rmarkdown github_document render
#' @importFrom devtools build_readme document
#' @family package
check_documentation <- function(x = ".") {
if (!inherits(x, "Checklist") || !"checklist" %in% x$get_checked) {
Expand Down Expand Up @@ -38,11 +37,7 @@ check_documentation <- function(x = ".") {

if (file_test("-f", file.path(x$get_path, "README.Rmd"))) {
status_before <- status(repo)
render(
file.path(x$get_path, "README.Rmd"),
output_format = github_document(html_preview = FALSE),
encoding = "UTF-8"
)
build_readme(x$get_path, encoding = "UTF-8")
doc_error <- c(
doc_error,
"`README.Rmd` need to be rendered. Run `devtools::build_readme()`"[
Expand Down
38 changes: 20 additions & 18 deletions R/set_tag.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@
#' Otherwise it will only return a message.
#' @export
#' @inheritParams read_checklist
#' @param token The GitHub access token
#' @importFrom assertthat assert_that
#' @importFrom git2r config is_detached repository tag tags
#' @family package
set_tag <- function(x = ".") {
set_tag <- function(x = ".", token) {
if (
!as.logical(Sys.getenv("GITHUB_ACTIONS", "false")) ||
Sys.getenv("GITHUB_REF") != "refs/heads/master" ||
Expand Down Expand Up @@ -57,48 +58,49 @@ set_tag <- function(x = ".") {
user.name = "Checklist bot",
user.email = "[email protected]"
)
tag(
repo,
name = paste0("v", version),
message = paste(news[seq(start[current], end[current])], collapse = "\n")
tag_message <- paste(news[seq(start[current], end[current])], collapse = "\n")
tag(repo, name = paste0("v", version), message = tag_message)
cmd <- sprintf(
"cd %s; git push origin; git push origin v%s", repo$path, version
)
cmd <- sprintf("cd %s; git push origin v%s", repo$path, version)
message(cmd)
system(cmd)

create_release(repo = repo, version = version, message = message)
create_release(
repo = repo, version = version, tag_message = tag_message, token = token
)
return(invisible(NULL))
}

#' @importFrom httr add_headers POST
#' @importFrom git2r remote_url
create_release <- function(repo, version, message) {
create_release <- function(repo, version, tag_message, token) {
url <- remote_url(repo, "origin")
if (!grepl("github.com", url)) {
warning("no `origin` or `origin` not on GitHub.")
return(invisible(NULL))
}
owner <- gsub(".*github.com:(.*?)/(.*?)\\.git", "\\1", url)
repo <- gsub(".*github.com:(.*?)/(.*?)\\.git", "\\1", url)
owner <- tolower(gsub(".*github.com:(.*?)/(.*?)\\.git", "\\1", url))
repo <- gsub(".*github.com:(.*?)/(.*?)\\.git", "\\2", url)
url <- sprintf("https://api.github.com/repos/%s/%s/releases", owner, repo)
body <- c(
tag_name = paste0("v", version),
name = paste("Version", version),
body = message,
tag_name = paste0("\"v", version, "\""),
name = paste("\"Version", version, "\""),
body = paste0("\"", tag_message, "\""),
draft = "false",
release = "false"
prerelease = "false"
)
body <- sprintf(
"{\n%s\n}",
paste(
sprintf(" \"%s\" : \"%s\"", names(body), body),
collapse = "\n"
sprintf(" \"%s\" : %s", names(body), body),
collapse = ",\n"
)
)
POST(
url = url,
config = add_headers(
"User-Agent" = "inbo/checklist package",
# "User-Agent" = "inbo/checklist package",
Authorization = paste("Bearer", token),
accept = "application/vnd.github.v3+json"
),
body = body,
Expand Down
22 changes: 19 additions & 3 deletions R/setup_package.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,27 +100,43 @@ allowed:
dir.create(file.path(path, ".github", "workflows"), showWarnings = FALSE)
file.copy(
system.file("package_template/check_on_branch.yml", package = "checklist"),
file.path(path, ".github", "workflows", "check_on_branch.yml")
file.path(path, ".github", "workflows", "check_on_branch.yml"),
overwrite = TRUE
)
add(repo = repo, ".github/workflows/check_on_branch.yml", force = TRUE)
file.copy(
system.file("package_template/check_on_master.yml", package = "checklist"),
file.path(path, ".github", "workflows", "check_on_master.yml")
file.path(path, ".github", "workflows", "check_on_master.yml"),
overwrite = TRUE
)
add(repo = repo, ".github/workflows/check_on_master.yml", force = TRUE)
file.copy(
system.file(
"package_template/check_on_different_r_os.yml",
package = "checklist"
),
file.path(path, ".github", "workflows", "check_on_different_r_os.yml")
file.path(path, ".github", "workflows", "check_on_different_r_os.yml"),
overwrite = TRUE
)
add(
repo = repo,
".github/workflows/check_on_different_r_os.yml",
force = TRUE
)

# Add pkgdown website
file.copy(
system.file("package_template/_pkgdown.yml", package = "checklist"),
file.path(path, "_pkgdown.yml")
)
add(repo = repo, "_pkgdown.yml", force = TRUE)
dir.create(file.path(path, "pkgdown"), showWarnings = FALSE)
file.copy(
system.file("package_template/pkgdown.css", package = "checklist"),
file.path(path, "pkgdown", "extra.css"), overwrite = TRUE
)
add(repo = repo, "pkgdown/extra.css", force = TRUE)

message("package prepared for checklist::check_package()")
return(invisible(NULL))
}
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ output: github_document
[![Codecov test coverage](https://codecov.io/gh/inbo/checklist/branch/master/graph/badge.svg)](https://codecov.io/gh/inbo/checklist?branch=master)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/inbo/checklist.svg)
![GitHub repo size](https://img.shields.io/github/repo-size/inbo/checklist.svg)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4028303.svg)](https://doi.org/10.5281/zenodo.4028303)

```{r setup, include = FALSE}
knitr::opts_chunk$set(
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ coverage](https://codecov.io/gh/inbo/checklist/branch/master/graph/badge.svg)](h
bytes](https://img.shields.io/github/languages/code-size/inbo/checklist.svg)
![GitHub repo
size](https://img.shields.io/github/repo-size/inbo/checklist.svg)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4028303.svg)](https://doi.org/10.5281/zenodo.4028303)

The goal of `checklist` is to provide an elaborate and strict set of
checks for R packages and R code.
Expand Down
2 changes: 1 addition & 1 deletion entrypoint_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ elif [ "$GITHUB_REF" != "refs/heads/master" ]; then
else
git checkout master
echo '\nUpdating tag...\n';
Rscript --no-save --no-restore -e 'checklist::set_tag()';
Rscript --no-save --no-restore -e 'checklist::set_tag(token = "$2")';

echo '\nPush pkgdown website...\n'
cp -R docs ../docs
Expand Down
2 changes: 1 addition & 1 deletion inst/package_template/check_on_master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
branches:
- master
schedule:
- cron: '6 0 * * 1'
- cron: '6 0 15 * *'

name: "check package on master"

Expand Down
4 changes: 3 additions & 1 deletion man/set_tag.Rd

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

0 comments on commit 2030bdd

Please sign in to comment.