Test script to manually validate creating a new rdev package or R analysis package.
Load devtools. Load package manually using devtools::load_all(".")
(command-shift-l).
# devtools already loaded htmltools::tagList( xaringanExtra::use_clipboard( button_text = "<i class=\"fa fa-clipboard fa-2xl\"></i>", success_text = "<i class=\"fa fa-check fa-2xl\" style=\"color: #90BE6D\"></i>" ), rmarkdown::html_dependency_font_awesome() )
Given:
setup-r
)When:
Creating a new GitHub repository with the following command:
rdev::create_github_repo("rdtest1", "rdev test package 1")
Then:
~/.Rprofile
LICENSE
: GitHub MIT License, with active GitHub user's name and current year in Copyright.gitignore
: GitHub
R.gitignore.Rbuildignore
DESCRIPTION
NAMESPACE
rdtest1.Rproj
Regression tests:
rdev::create_github_repo("rdtest1")
errors when the "rdtest1" directory
exists in usethis:::conspicuous_place()
rdev::create_github_repo("rdtest1")
Given:
When:
Following ?quickstart
, without committing to git, initialize the rdev package by running init()
in the newly created project:
rdev::init()
When prompted, select "Yes" and "implicit mode":
Initialize rdev package (run after create_github_repo)? (yes/No/cancel) y ... This project contains a DESCRIPTION file. Which files should renv use for dependency discovery in this project? 1: Use only the DESCRIPTION file. (explicit mode) 2: Use all files in this project. (implicit mode) Selection: 2
Then:
.Rbuildignore
, DESCRIPTION
, NAMESPACE
, rdtest1.Rproj
) will be
committed to GitHub with the message rdev::create_github_repo()
There will be 22 new or changed files (new unless otherwise noted):
.github/.gitignore
.github/workflows/lint.yaml
.github/workflows/missing-deps.yaml
.github/workflows/R-CMD-check.yaml
.gitignore
: changed, add 'macOS, vim' section.lintr
.Rbuildignore
: changed, sorted.Rprofile
DESCRIPTION
: changedLICENSE.md
man/rdtest1-package.Rd
NEWS.md
R/package.R
README.md
README.Rmd
renv.lock
renv/.gitignore
renv/activate.R
renv/settings.json
tests/testthat.R
tests/testthat/test-package.R
TODO.md
On GitHub:
Task:
Following ?quickstart
, manually update the Title and Description fields in the DESCRIPTION file
(without committing):
desc::desc_set(Title = "Rdev Test Package 1") desc::desc_set(Description = "Used in manual testing of the rdev package.")
Regression tests:
.git/hooks/pre-commit
is owner-executable (must be executable to work) and
matches the pre-commit
template:dir .git/hooks/pre-commit
-rwxr--r-- 1 agamemnon staff 409 Jan 30 15:58 .git/hooks/pre-commit
cat .git/hooks/pre-commit
1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/bin/bash # forked from https://github.com/r-lib/usethis/blob/main/inst/templates/readme-rmd-pre-commit.sh README=($(git diff --cached --name-only | grep -Ei '^README\.[R]?md$')) MSG="use 'git commit --no-verify' to override this check" if [[ ${#README[@]} == 0 ]]; then exit 0 fi if [[ README.Rmd -nt README.md ]]; then echo -e "README.md is out of date; please re-knit README.Rmd\n$MSG" exit 1 fi |
Given:
When:
Following ?quickstart
, without committing to git, running setup_rdev()
to configure the package
as an rdev package:
rdev::setup_rdev()
When prompted, answer "Yes" to all questions:
Set up rdev package (run after init)? (yes/No/cancel) y ... Do you want to proceed? [Y/n]: y ... Are you sure you want to update the wordlist? 1: Yes 2: No Selection: 1 ... Do you want to proceed? [Y/n]: y ... Do you want to proceed? [Y/n]: y
Additionally, ci()
will run successfully, generating the following R CMD check
note:
> checking package subdirectories ... NOTE Problems with news in ‘NEWS.md’: No news entries found.
Then:
If using RStudio, there will be 5 files open:
_pkgdown.yml
TODO.md
NEWS.md
README.Rmd
DESCRIPTION
The following commits will be added to git:
rdev::use_rdev_package()
: 22 new files or changed files from 'Initialize rdev package'rdev::use_rdev_pkgdown()
: 6 new or changed files:.Rbuildignore
: changed, added ^_pkgdown\.yml$
, ^docs$
, ^pkgdown$
, sorted.gitignore
: changed, added docs
DESCRIPTION
: added pkgdown_pkgdown.yml
: newman/rdtest1-package.Rd
: updated title and descriptionpkgdown/extra.css
: newrdev::use_spelling()
: 5 new or changed files:DESCRIPTION
: added spelling, withr, Languageinst/WORDLIST
: new, with the following words in the list:tests/spelling.R
: new, from rdev templatetests/testthat/test-package.R
: deletedtests/testthat/test-spelling.R
: new, from rdev templaterdev::use_codecov()
: 6 new or changed files:.Rbuildignore
: added codecov.yml
.github/workflows/test-coverage.yaml
: new, added from rdev workflowsDESCRIPTION
: added covr, DTREADME.Rmd
: added 'Codecov test coverage' badgecodecov.yml
: newrenv.lock
: added covr, DT, dependenciesTask:
Revert the changes to test use_analysis_package()
:
rdev::use_codecov()
rdev::use_spelling()
rdev::use_rdev_pkgdown()
rdev::use_rdev_package()
(without discarding the 22 files)renv::clean()
to remove unused packagesRegression tests:
Given:
When:
Following ?quickstart
, without committing to git, running setup_analysis()
to configure the
package as an analysis package:
rdev::setup_analysis()
When prompted, answer "Yes" to all questions:
Set up analysis package (run after init)? (yes/No/cancel) y ... Do you want to proceed? [Y/n]: y ... Do you want to proceed? [Y/n]: y ... Are you sure you want to update the wordlist? 1: Yes 2: No Selection: 1
Additionally, ci()
will run successfully, generating the following R CMD check
note:
> checking package subdirectories ... NOTE Problems with news in ‘NEWS.md’: No news entries found.
Then:
If using RStudio, there will be 4 files open:
TODO.md
NEWS.md
README.Rmd
DESCRIPTION
The following commits will be added to git:
rdev::use_rdev_package()
: 22 new files or changed files from 'Initialize rdev package'rdev::use_analysis_package()
: 10 new or changed files:.Rbuildignore
: added analysis package generated files, sorted.gitignore
: added # analysis package generated files
section.nojekyll
: new, empty fileDESCRIPTION
: added dplyr, purrr, quarto to Suggests
README.Rmd
: changed, with Notebooks section_quarto.yml
: newanalysis/_metadata.yml
: newanalysis/assets/extra.css
: newchangelog.qmd
: newindex.qmd
: newman/rdtest1-package.Rd
: updated title and descriptionrenv.lock
: updated with dplyr and dependenciesrdev::use_spelling()
: 5 new or changed files:DESCRIPTION
: added spelling, withr, Languageinst/WORDLIST
: new, with the following words in the list:tests/spelling.R
: new, from rdev templatetests/testthat/test-package.R
: deletedtests/testthat/test-spelling.R
: new, from rdev templateRegression tests:
Test the installation by the Quarto builder, which should throw an error:
build_quarto_site() #> Error in build_analysis_site() : no *.Rmd or *.qmd files in analysis directory
Create an analysis notebook in RStudio using File > New File > R Markdown... > From Template >
Analysis Notebook, save in analysis
as test.Rmd
, removing all library
commands in the setup
block except library(dplyr)
, remove order:
in the header, and re-run the checks, which should
complete successfully:
build_quarto_site()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.