From 6389bb42a71bd1bf2a23fce34f1246704e6ff5a1 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Wed, 7 Jun 2023 11:52:07 +0200 Subject: [PATCH 01/10] fix release --- .github/workflows/release.yml | 2 +- inst/package_template/release.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b2f57d3..95fdd8cb 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -20,7 +20,7 @@ jobs: - name: Get tag message run: | TAG=$(git tag --contains $(git rev-parse HEAD)) - TAG_BODY=$(git tag --contains {{ github.sha }} -n100 | awk '(NR>1)') + TAG_BODY=$(git tag --contains $(git rev-parse HEAD) -n100 | awk '(NR>2)') echo "TAG=$TAG" >> $GITHUB_OUTPUT echo "TAG_BODY=$TAG_BODY" >> $GITHUB_OUTPUT id: tag-body diff --git a/inst/package_template/release.yml b/inst/package_template/release.yml index 3b2f57d3..95fdd8cb 100644 --- a/inst/package_template/release.yml +++ b/inst/package_template/release.yml @@ -20,7 +20,7 @@ jobs: - name: Get tag message run: | TAG=$(git tag --contains $(git rev-parse HEAD)) - TAG_BODY=$(git tag --contains {{ github.sha }} -n100 | awk '(NR>1)') + TAG_BODY=$(git tag --contains $(git rev-parse HEAD) -n100 | awk '(NR>2)') echo "TAG=$TAG" >> $GITHUB_OUTPUT echo "TAG_BODY=$TAG_BODY" >> $GITHUB_OUTPUT id: tag-body From bea4bd35e681417b66ba66166897e4dd3be13f82 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Wed, 7 Jun 2023 11:52:20 +0200 Subject: [PATCH 02/10] improve tag message --- R/set_tag.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/set_tag.R b/R/set_tag.R index a0368bbd..f7bb7edd 100644 --- a/R/set_tag.R +++ b/R/set_tag.R @@ -76,7 +76,9 @@ set_tag <- function(x = ".") { repo = repo ) - tag_message <- paste(news[seq(start[current], end[current])], collapse = "\n") + tag_message <- paste( + news[seq(start[current] + 2, end[current])], collapse = "\n" + ) git_tag_create( name = paste0("v", version), message = tag_message, repo = repo ) From 25ce9948aa2989c3718121b1a9e3d46f57054b44 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Thu, 8 Jun 2023 10:51:41 +0200 Subject: [PATCH 03/10] preferred_protocol() asks everytime for a GitHub organisation with the organisation as default --- R/setup_project.R | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/R/setup_project.R b/R/setup_project.R index 7941178b..41330416 100644 --- a/R/setup_project.R +++ b/R/setup_project.R @@ -258,18 +258,8 @@ preferred_protocol <- function() { config <- read_yaml(config_file) } if ( - !has_name(config, "git") || !has_name(config$git, "protocol") || - !has_name(config$git, "organisation") + !has_name(config, "git") || !has_name(config$git, "protocol") ) { - org <- organisation$new() - sprintf( - "What is your default GitHub organisation. Leave empty for `%s`.", - org$get_github - ) |> - readline() -> config[["git"]][["organisation"]] - if (config[["git"]][["organisation"]] == "") { - config[["git"]][["organisation"]] <- org$get_github - } c("https (easy)", "ssh (more secure)") |> menu_first(title = "Which protocol do you prefer?") -> protocol config[["git"]][["protocol"]] <- c("https", "ssh")[protocol] @@ -277,6 +267,9 @@ preferred_protocol <- function() { dir_create() write_yaml(x = config, file = config_file, fileEncoding = "UTF-8") } + org <- organisation$new() + sprintf("Which GitHub organisation. Leave empty for `%s`.", org$get_github) |> + readline() -> config[["git"]][["organisation"]] ifelse( config$git$protocol == "https", "https://github.com/%s/%%s.git", "git@github.com:%s/%%s.git" From a5bc0cff4cdbceabb7ba8f21dd097881e2acebc5 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Thu, 8 Jun 2023 10:53:38 +0200 Subject: [PATCH 04/10] bump package version --- .zenodo.json | 2 +- CITATION.cff | 2 +- DESCRIPTION | 2 +- NEWS.md | 6 ++++++ inst/CITATION | 4 ++-- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.zenodo.json b/.zenodo.json index 02d8a46b..52155070 100644 --- a/.zenodo.json +++ b/.zenodo.json @@ -1,6 +1,6 @@ { "title": "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code", - "version": "0.3.3", + "version": "0.3.4", "license": "GPL-3.0", "upload_type": "software", "description": "

An opinionated set of rules for R packages and R source code\nprojects.<\/p>", diff --git a/CITATION.cff b/CITATION.cff index 60d0d5cb..2d705b9a 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -25,4 +25,4 @@ identifiers: value: 10.5281/zenodo.4028303 - type: url value: https://inbo.github.io/checklist/ -version: 0.3.3 +version: 0.3.4 diff --git a/DESCRIPTION b/DESCRIPTION index 3777df73..37197131 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: checklist Title: A Thorough and Strict Set of Checks for R Packages and Source Code -Version: 0.3.3 +Version: 0.3.4 Authors@R: c( person("Thierry", "Onkelinx", , "thierry.onkelinx@inbo.be", role = c("aut", "cre"), comment = c(ORCID = "0000-0001-8804-4216", affiliation = "Research Institute for Nature and Forest (INBO)")), diff --git a/NEWS.md b/NEWS.md index 4a184bb0..7414801e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,9 @@ +# checklist 0.3.4 + +* Ask which GitHub organisation to use when create a new project. + Default equals the organisation's default. +* Fix release GitHub Action. + # checklist 0.3.3 * New `organisation()` class to hold the requirements of the organisation. diff --git a/inst/CITATION b/inst/CITATION index 142157aa..3d432550 100644 --- a/inst/CITATION +++ b/inst/CITATION @@ -2,12 +2,12 @@ citHeader("To cite `checklist` in publications please use:") # begin checklist entry bibentry( bibtype = "Manual", - title = "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.3", + title = "checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.4", author = c( author = c(person(given = "Thierry", family = "Onkelinx"))), year = 2023, url = "https://inbo.github.io/checklist/", abstract = "An opinionated set of rules for R packages and R source code projects.", - textVersion = "Onkelinx, Thierry (2023) checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.3. https://github.com/inbo/checklist/; https://inbo.github.io/checklist/", + textVersion = "Onkelinx, Thierry (2023) checklist: A Thorough and Strict Set of Checks for R Packages and Source Code. Version 0.3.4. https://github.com/inbo/checklist/; https://inbo.github.io/checklist/", keywords = "quality control; documentation; publication", doi = "10.5281/zenodo.4028303", ) From d561477cb6d8fa71e0125e6fa773b331444c5dde Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Thu, 8 Jun 2023 11:09:31 +0200 Subject: [PATCH 05/10] bugfix: read_checklist() return the correct path when starting from a subdirectory --- R/check_project.R | 5 ----- R/read_checklist.R | 4 ++-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/R/check_project.R b/R/check_project.R index 52dd624f..40f342ff 100644 --- a/R/check_project.R +++ b/R/check_project.R @@ -8,11 +8,6 @@ #' @importFrom fs is_file #' @family project check_project <- function(x = ".", fail = !interactive(), quiet = FALSE) { - assert_that( - inherits(x, "checklist") || is_file(path(x, "checklist.yml")), - msg = "Please initialise the project first with `setup_project()`" - ) - x <- read_checklist(x = x) if (x$package) { return(check_package(x = x, fail = fail, quiet = quiet)) diff --git a/R/read_checklist.R b/R/read_checklist.R index fb50399c..4ae9f859 100644 --- a/R/read_checklist.R +++ b/R/read_checklist.R @@ -43,14 +43,14 @@ read_checklist <- function(x = ".") { } if (allowed$package) { x <- checklist$new( - x = x, package = TRUE, + x = current, package = TRUE, language = ifelse( has_name(allowed$spelling, "default"), allowed$spelling$default, "en-GB" ) ) } else { x <- checklist$new( - x = x, package = FALSE, + x = current, package = FALSE, language = ifelse( has_name(allowed$spelling, "default"), allowed$spelling$default, "en-GB" ) From 3013cd7b7f371866f9af727bcb063a1e4ade427d Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Fri, 9 Jun 2023 14:22:53 +0200 Subject: [PATCH 06/10] improve spellchecking --- R/spelling_parse.R | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/R/spelling_parse.R b/R/spelling_parse.R index 8b8bef10..2f23d603 100644 --- a/R/spelling_parse.R +++ b/R/spelling_parse.R @@ -261,6 +261,15 @@ spelling_parse_md <- function(md_file, wordlist, x) { # remove markdown footnotes text <- gsub("\\[\\^.*?\\]", "", text) + # remove dates in number formats + text <- gsub("\\d{1,2}\\/\\d{1,2}\\/\\d{2,4}", "", text, perl = TRUE) + text <- gsub("\\d+\\/\\d+", "", text, perl = TRUE) + + # remove numbers + text <- gsub( + "€?[\\s\\(\"][\\+-]?\\d+([\\.,]\\d+)*[\\s%\\)\"]", " ", text, perl = TRUE + ) + # extract other languages assert_that( length( From 596aa1502fc49b6725ce117a9cdb853f9c5c5a4a Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Tue, 20 Jun 2023 10:42:33 +0200 Subject: [PATCH 07/10] GHA for projects gains an INPUT_CRAN variable --- docker/entrypoint_project.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docker/entrypoint_project.sh b/docker/entrypoint_project.sh index 9d3eaeaf..8adb980f 100755 --- a/docker/entrypoint_project.sh +++ b/docker/entrypoint_project.sh @@ -7,6 +7,10 @@ git config advice.detachedHead false git checkout $GITHUB_SHA cd .. +if [ -n "$INPUT_CRAN" ]; then + CRAN='remotes::install_cran('${INPUT_CRAN}', upgrade = "always")' + Rscript --no-save --no-restore -e "$CRAN" +fi Rscript --no-save --no-restore -e 'checklist::check_project("check/'$INPUT_PATH'", fail = TRUE, quiet = FALSE)' if [ $? -ne 0 ]; then echo '\nThe project failed some checks. Please check the error message above.\n'; From 1c54cc840a20cf286a8a66e2a0764f9063b197e3 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Tue, 20 Jun 2023 16:52:58 +0200 Subject: [PATCH 08/10] use more effecient order of R packages in Dockerfile --- Dockerfile | 189 +++++++++++++++++++++++++---------------------------- 1 file changed, 90 insertions(+), 99 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5c68a840..3d904b51 100644 --- a/Dockerfile +++ b/Dockerfile @@ -23,132 +23,90 @@ RUN apt-get update \ COPY docker/.Rprofile $R_HOME/etc/Rprofile.site -## install INLA -RUN Rscript --no-save --no-restore -e 'remotes::install_cran("INLA", type = "source")' - ## install assertthat RUN apt update \ && apt install -y --no-install-recommends r-cran-assertthat \ && Rscript --no-save --no-restore -e 'remotes::install_cran("assertthat")' -## install codemetar -RUN apt update \ - && apt install -y --no-install-recommends r-cran-bookdown \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("bookdown")' - -## install codemetar -RUN Rscript --no-save --no-restore -e 'remotes::install_cran("codemetar")' - -## install covr -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libharfbuzz-dev \ - libfribidi-dev \ - r-cran-covr \ - && apt-get clean \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("covr")' - -## install curl -RUN apt update \ - && apt install -y --no-install-recommends r-cran-curl \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("curl")' - ## install desc RUN apt update \ && apt install -y --no-install-recommends r-cran-desc \ && Rscript --no-save --no-restore -e 'remotes::install_cran("desc")' -## install devtools -RUN apt update \ - && apt install -y --no-install-recommends r-cran-devtools \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("devtools")' - ## install fs RUN apt update \ && apt install -y --no-install-recommends r-cran-fs \ && Rscript --no-save --no-restore -e 'remotes::install_cran("fs")' -## install gert +## install jsonlite RUN apt update \ - && apt install -y --no-install-recommends r-cran-gert \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("gert")' + && apt install -y --no-install-recommends r-cran-jsonlite \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("jsonlite")' -## install hexSticker -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libmagick++-dev \ - && apt-get clean \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("hexSticker")' +## install hunspell +RUN apt update \ + && apt install -y --no-install-recommends r-cran-hunspell \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("hunspell")' + +## install R6 +RUN apt update \ + && apt install -y --no-install-recommends r-cran-r6 \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("R6")' ## install httr RUN apt update \ && apt install -y --no-install-recommends r-cran-httr \ && Rscript --no-save --no-restore -e 'remotes::install_cran("httr")' -## install hunspell -RUN apt update \ - && apt install -y --no-install-recommends r-cran-hunspell \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("hunspell")' - -## install jsonlite +## install gert RUN apt update \ - && apt install -y --no-install-recommends r-cran-jsonlite \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("jsonlite")' + && apt install -y --no-install-recommends r-cran-gert \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("gert")' ## install knitr RUN apt update \ && apt install -y --no-install-recommends r-cran-knitr \ && Rscript --no-save --no-restore -e 'remotes::install_cran("knitr")' -## install lintr -RUN Rscript --no-save --no-restore -e 'remotes::install_cran("lintr")' - -## install microbenchmark -RUN Rscript --no-save --no-restore -e 'remotes::install_cran("microbenchmark")' - -## install mockery +## install sessioninfo RUN apt update \ - && apt install -y --no-install-recommends r-cran-mockery \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("mockery")' - -## install pdftools -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libpoppler-cpp-dev \ - r-cran-pdftools \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("pdftools")' + && apt install -y --no-install-recommends r-cran-sessioninfo \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("sessioninfo")' -## install pkgdown -RUN apt-get update \ - && apt-get install -y --no-install-recommends \ - libfontconfig1-dev \ - libfreetype6-dev \ - libjpeg-dev \ - libpng-dev \ - libtiff5-dev \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("pkgdown")' +## install withr +RUN apt update \ + && apt install -y --no-install-recommends r-cran-withr \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("withr")' -## install R6 +## install yaml RUN apt update \ - && apt install -y --no-install-recommends r-cran-r6 \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("R6")' + && apt install -y --no-install-recommends r-cran-yaml \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("yaml")' -## install rcmdcheck +## install curl RUN apt update \ - && apt install -y --no-install-recommends r-cran-rcmdcheck \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("rcmdcheck")' + && apt install -y --no-install-recommends r-cran-curl \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("curl")' ## install renv RUN Rscript --no-save --no-restore -e 'remotes::install_cran("renv")' -## install rgdal +## install covr RUN apt-get update \ && apt-get install -y --no-install-recommends \ - libgdal-dev \ - libproj-dev \ - r-cran-rgdal \ + libharfbuzz-dev \ + libfribidi-dev \ + r-cran-covr \ && apt-get clean \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("rgdal")' + && Rscript --no-save --no-restore -e 'remotes::install_cran("covr")' + +## install lintr +RUN Rscript --no-save --no-restore -e 'remotes::install_cran("lintr")' + +## install rcmdcheck +RUN apt update \ + && apt install -y --no-install-recommends r-cran-rcmdcheck \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("rcmdcheck")' ## install rmarkdown RUN apt update \ @@ -160,42 +118,75 @@ RUN apt update \ && apt install -y --no-install-recommends r-cran-roxygen2 \ && Rscript --no-save --no-restore -e 'remotes::install_cran("roxygen2")' +## install INLA +RUN Rscript --no-save --no-restore -e 'remotes::install_cran("INLA", type = "source")' + +## install bookdown +RUN apt update \ + && apt install -y --no-install-recommends r-cran-bookdown \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("bookdown")' + +## install mockery +RUN apt update \ + && apt install -y --no-install-recommends r-cran-mockery \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("mockery")' + +## install pdftools +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libpoppler-cpp-dev \ + r-cran-pdftools \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("pdftools")' + ## install rstudioapi RUN apt update \ && apt install -y --no-install-recommends r-cran-rstudioapi \ && Rscript --no-save --no-restore -e 'remotes::install_cran("rstudioapi")' -## install sessioninfo +## install codemetar +RUN Rscript --no-save --no-restore -e 'remotes::install_cran("codemetar")' + +## install testthat RUN apt update \ - && apt install -y --no-install-recommends r-cran-sessioninfo \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("sessioninfo")' + && apt install -y --no-install-recommends r-cran-testthat \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("testthat")' -## install showtext -RUN Rscript --no-save --no-restore -e 'remotes::install_cran("showtext")' +## install pkgdown +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libfontconfig1-dev \ + libfreetype6-dev \ + libjpeg-dev \ + libpng-dev \ + libtiff5-dev \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("pkgdown")' ## install sysfonts RUN Rscript --no-save --no-restore -e 'remotes::install_cran("sysfonts")' -## install testthat -RUN apt update \ - && apt install -y --no-install-recommends r-cran-testthat \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("testthat")' +## install showtext +RUN Rscript --no-save --no-restore -e 'remotes::install_cran("showtext")' -## install withr -RUN apt update \ - && apt install -y --no-install-recommends r-cran-withr \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("withr")' +## install hexSticker +RUN apt-get update \ + && apt-get install -y --no-install-recommends \ + libmagick++-dev \ + && apt-get clean \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("hexSticker")' -## install yaml +## install devtools RUN apt update \ - && apt install -y --no-install-recommends r-cran-yaml \ - && Rscript --no-save --no-restore -e 'remotes::install_cran("yaml")' + && apt install -y --no-install-recommends r-cran-devtools \ + && Rscript --no-save --no-restore -e 'remotes::install_cran("devtools")' ## install zen4R RUN apt update \ && apt install -y --no-install-recommends libsecret-1-dev \ && Rscript --no-save --no-restore -e 'remotes::install_cran("zen4R")' +## install microbenchmark +RUN Rscript --no-save --no-restore -e 'remotes::install_cran("microbenchmark")' + ## install checklist COPY . /checklist/ RUN Rscript --no-save --no-restore -e 'remotes::install_local("checklist", upgrade = "always")' From b4a4a8b2bc508ac14aa537cad3066e3727c0dd1f Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Wed, 21 Jun 2023 09:19:11 +0200 Subject: [PATCH 09/10] replace Euro symbol with UTF-8 encoding --- R/spelling_parse.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/spelling_parse.R b/R/spelling_parse.R index 2f23d603..aa38d0e8 100644 --- a/R/spelling_parse.R +++ b/R/spelling_parse.R @@ -266,8 +266,10 @@ spelling_parse_md <- function(md_file, wordlist, x) { text <- gsub("\\d+\\/\\d+", "", text, perl = TRUE) # remove numbers + # \u20ac is the Euro symbol in UTF-8 notation text <- gsub( - "€?[\\s\\(\"][\\+-]?\\d+([\\.,]\\d+)*[\\s%\\)\"]", " ", text, perl = TRUE + "\u20ac?[\\s\\(\"][\\+-]?\\d+([\\.,]\\d+)*[\\s%\\)\"]", " ", text, + perl = TRUE ) # extract other languages From 2474a29f155020e9d5bfe875019dcfe163273523 Mon Sep 17 00:00:00 2001 From: Thierry Onkelinx Date: Wed, 21 Jun 2023 09:24:44 +0200 Subject: [PATCH 10/10] update NEWS --- NEWS.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/NEWS.md b/NEWS.md index 7414801e..6629348c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,12 @@ # checklist 0.3.4 +* `check_spelling()` ignores numbers. * Ask which GitHub organisation to use when create a new project. Default equals the organisation's default. +* GitHub Action for project allow to install package prior to checking the + project. + Use this in case `check_lintr()` returns an error about global variables in a + function and you did `require()` the package. * Fix release GitHub Action. # checklist 0.3.3