From d34201a8c13e93797be10ff3be95b4d949d45a1e Mon Sep 17 00:00:00 2001 From: Pascal Sauer Date: Wed, 24 Apr 2024 18:53:45 +0200 Subject: [PATCH] build --- .Rbuildignore | 6 ++++ .buildlibrary | 8 +++++ .github/workflows/check.yaml | 68 ++++++++++++++++++++++++++++++++++++ .pre-commit-config.yaml | 28 +++++++++++++++ CITATION.cff | 14 ++++++++ DESCRIPTION | 4 +-- Makefile | 46 ++++++++++++++++++++++++ NAMESPACE | 2 ++ R/mrlandcore-package.R | 6 ++++ README.md | 53 ++++++++++++++++++++++++++++ man/mrlandcore-package.Rd | 22 ++++++++++++ tests/testthat/test-dummy.R | 1 + 12 files changed, 256 insertions(+), 2 deletions(-) create mode 100644 .Rbuildignore create mode 100644 .buildlibrary create mode 100644 .github/workflows/check.yaml create mode 100644 .pre-commit-config.yaml create mode 100644 CITATION.cff create mode 100644 Makefile create mode 100644 NAMESPACE create mode 100644 R/mrlandcore-package.R create mode 100644 README.md create mode 100644 man/mrlandcore-package.Rd create mode 100644 tests/testthat/test-dummy.R diff --git a/.Rbuildignore b/.Rbuildignore new file mode 100644 index 0000000..f6acc6d --- /dev/null +++ b/.Rbuildignore @@ -0,0 +1,6 @@ +^\.buildlibrary$ +^\.pre-commit-config\.yaml$ +^Makefile$ +^workflow$ +^.*CITATION.cff$ +^\.github$ diff --git a/.buildlibrary b/.buildlibrary new file mode 100644 index 0000000..d92d19b --- /dev/null +++ b/.buildlibrary @@ -0,0 +1,8 @@ +ValidationKey: '376922837' +AutocreateReadme: yes +AcceptedWarnings: +- 'Warning: package ''.*'' was built under R version' +- 'Warning: namespace ''.*'' is not available and has been replaced' +AcceptedNotes: ~ +allowLinterWarnings: no +enforceVersionUpdate: no diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml new file mode 100644 index 0000000..f6ea5d4 --- /dev/null +++ b/.github/workflows/check.yaml @@ -0,0 +1,68 @@ +name: check + +on: + push: + branches: [main, master] + pull_request: + branches: [main, master] + +jobs: + check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true + extra-repositories: "https://rse.pik-potsdam.de/r/packages" + + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: | + any::lucode2 + any::covr + any::madrat + any::magclass + any::citation + any::gms + any::goxygen + any::GDPuc + # piam packages also available on CRAN (madrat, magclass, citation, + # gms, goxygen, GDPuc) will usually have an outdated binary version + # available; by using extra-packages we get the newest version + + - uses: actions/setup-python@v5 + with: + python-version: 3.9 + + - name: Install python dependencies if applicable + run: | + [ -f requirements.txt ] && python -m pip install --upgrade pip wheel || true + [ -f requirements.txt ] && pip install -r requirements.txt || true + + - name: Verify validation key + shell: Rscript {0} + run: lucode2:::validkey(stopIfInvalid = TRUE) + + - name: Verify that lucode2::buildLibrary was successful + if: github.event_name == 'pull_request' + shell: Rscript {0} + run: lucode2:::isVersionUpdated() + + - name: Checks + shell: Rscript {0} + run: | + options(crayon.enabled = TRUE) + lucode2::check(runLinter = FALSE) + + - name: Test coverage + shell: Rscript {0} + run: | + nonDummyTests <- setdiff(list.files("./tests/testthat/"), c("test-dummy.R", "_snaps")) + if(length(nonDummyTests) > 0) covr::codecov(quiet = FALSE) + env: + NOT_CRAN: "true" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..243f46a --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,28 @@ +# testthat snapshots are machine-generated regression tests that +# have to be preserved exactly as they are +exclude: '^tests/testthat/_snaps/.*$' +repos: +- repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.5.0 + hooks: + - id: check-case-conflict + - id: check-json + - id: check-merge-conflict + - id: check-yaml + - id: fix-byte-order-marker + - id: check-added-large-files + args: ['--maxkb=100'] + - id: mixed-line-ending + +- repo: https://github.com/lorenzwalthert/precommit + rev: v0.4.0 + hooks: + - id: parsable-R + - id: deps-in-desc + args: [--allow_private_imports] + - id: no-browser-statement + - id: no-debug-statement + - id: readme-rmd-rendered + - id: use-tidy-description +ci: + autoupdate_schedule: quarterly diff --git a/CITATION.cff b/CITATION.cff new file mode 100644 index 0000000..f185d8d --- /dev/null +++ b/CITATION.cff @@ -0,0 +1,14 @@ +cff-version: 1.2.0 +message: If you use this software, please cite it using the metadata from this file. +type: software +title: 'mrlandcore: One-line description of this awesome package' +version: 0.0.1.9001 +date-released: '2024-04-24' +abstract: One-paragraph description of this awesome package. +authors: +- family-names: Karstens + given-names: Kristine + email: karstens@pik-potsdam.de +license: LGPL-3.0 +repository-code: https://github.com/pik-piam/mrlandcore + diff --git a/DESCRIPTION b/DESCRIPTION index 65d7e59..117da0f 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: mrlandcore Title: One-line description of this awesome package -Version: 0.0.1 +Version: 0.0.1.9001 Date: 2024-04-24 Authors@R: person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")) @@ -11,4 +11,4 @@ URL: https://github.com/pik-piam/mrlandcore Suggests: testthat Encoding: UTF-8 -RoxygenNote: 7.2.1 +RoxygenNote: 7.3.1 diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..38e857f --- /dev/null +++ b/Makefile @@ -0,0 +1,46 @@ +.PHONY: help build check test lint lint-all format format-all install docs +.DEFAULT_GOAL = help + +# extracts the help text and formats it nicely +HELP_PARSING = 'm <- readLines("Makefile");\ + m <- grep("\#\#", m, value=TRUE);\ + command <- sub("^([^ ]*) *\#\#(.*)", "\\1", m);\ + help <- sub("^([^ ]*) *\#\#(.*)", "\\2", m);\ + cat(sprintf("%-8s%s", command, help), sep="\n")' + +help: ## Show this help. + @Rscript -e $(HELP_PARSING) + +build: ## Build the package using lucode2::buildLibrary(). You can pass the + ## updateType with 'make build u=3' + Rscript -e 'lucode2::buildLibrary(updateType = "$(u)")' + +check: ## Build documentation and vignettes, run testthat tests, + ## and check if code etiquette is followed using lucode2::check(). + Rscript -e 'lucode2::check()' + +test: ## Run testthat tests + Rscript -e 'devtools::test(show_report = TRUE)' + +lint: ## Check if code etiquette is followed using lucode2::lint(). + ## Only checks files you changed. + Rscript -e 'lucode2::lint()' + +lint-all: ## Check if code etiquette is followed using lucode2::lint(). + ## Checks all files. + Rscript -e 'lucode2::lint(".")' + +format: ## Apply auto-formatting to changed files and lint afterwards. + Rscript -e 'lucode2::autoFormat()' + +format-all: ## Apply auto-formatting to all files and lint afterwards. + Rscript -e 'lucode2::autoFormat(files=list.files("./R", full.names = TRUE, pattern = "\\.R"))' + +install: ## Install the package locally via devtools::install() after + ## generating NAMESPACE and docs (see docs target). + Rscript -e 'roxygen2::roxygenize(); devtools::install(upgrade = "never")' + +docs: ## Generate the package documentation (man/*.Rd files) and + ## NAMESPACE via roxygen2::roxygenize(), view the generated + ## documentation with `?package::function`. + Rscript -e 'roxygen2::roxygenize()' diff --git a/NAMESPACE b/NAMESPACE new file mode 100644 index 0000000..6ae9268 --- /dev/null +++ b/NAMESPACE @@ -0,0 +1,2 @@ +# Generated by roxygen2: do not edit by hand + diff --git a/R/mrlandcore-package.R b/R/mrlandcore-package.R new file mode 100644 index 0000000..a65cf64 --- /dev/null +++ b/R/mrlandcore-package.R @@ -0,0 +1,6 @@ +#' @keywords internal +"_PACKAGE" + +## usethis namespace: start +## usethis namespace: end +NULL diff --git a/README.md b/README.md new file mode 100644 index 0000000..3581db9 --- /dev/null +++ b/README.md @@ -0,0 +1,53 @@ +# One-line description of this awesome package + +R package **mrlandcore**, version **0.0.1.9001** + +[![CRAN status](https://www.r-pkg.org/badges/version/mrlandcore)](https://cran.r-project.org/package=mrlandcore) [![R build status](https://github.com/pik-piam/mrlandcore/workflows/check/badge.svg)](https://github.com/pik-piam/mrlandcore/actions) [![codecov](https://codecov.io/gh/pik-piam/mrlandcore/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrlandcore) + +## Purpose and Functionality + +One-paragraph description of this awesome package. + + +## Installation + +For installation of the most recent package version an additional repository has to be added in R: + +```r +options(repos = c(CRAN = "@CRAN@", pik = "https://rse.pik-potsdam.de/r/packages")) +``` +The additional repository can be made available permanently by adding the line above to a file called `.Rprofile` stored in the home folder of your system (`Sys.glob("~")` in R returns the home directory). + +After that the most recent version of the package can be installed using `install.packages`: + +```r +install.packages("mrlandcore") +``` + +Package updates can be installed using `update.packages` (make sure that the additional repository has been added before running that command): + +```r +update.packages() +``` + +## Questions / Problems + +In case of questions / problems please contact Kristine Karstens . + +## Citation + +To cite package **mrlandcore** in publications use: + +Karstens K (2024). _mrlandcore: One-line description of this awesome package_. R package version 0.0.1.9001, . + +A BibTeX entry for LaTeX users is + + ```latex +@Manual{, + title = {mrlandcore: One-line description of this awesome package}, + author = {Kristine Karstens}, + year = {2024}, + note = {R package version 0.0.1.9001}, + url = {https://github.com/pik-piam/mrlandcore}, +} +``` diff --git a/man/mrlandcore-package.Rd b/man/mrlandcore-package.Rd new file mode 100644 index 0000000..661493e --- /dev/null +++ b/man/mrlandcore-package.Rd @@ -0,0 +1,22 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/mrlandcore-package.R +\docType{package} +\name{mrlandcore-package} +\alias{mrlandcore} +\alias{mrlandcore-package} +\title{mrlandcore: One-line description of this awesome package} +\description{ +One-paragraph description of this awesome package. +} +\seealso{ +Useful links: +\itemize{ + \item \url{https://github.com/pik-piam/mrlandcore} +} + +} +\author{ +\strong{Maintainer}: Kristine Karstens \email{karstens@pik-potsdam.de} + +} +\keyword{internal} diff --git a/tests/testthat/test-dummy.R b/tests/testthat/test-dummy.R new file mode 100644 index 0000000..909f17c --- /dev/null +++ b/tests/testthat/test-dummy.R @@ -0,0 +1 @@ +skip("dummy test")