Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-sauer committed Apr 24, 2024
1 parent 7075b3f commit d34201a
Show file tree
Hide file tree
Showing 12 changed files with 256 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
^\.buildlibrary$
^\.pre-commit-config\.yaml$
^Makefile$
^workflow$
^.*CITATION.cff$
^\.github$
8 changes: 8 additions & 0 deletions .buildlibrary
Original file line number Diff line number Diff line change
@@ -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
68 changes: 68 additions & 0 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
@@ -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"
28 changes: 28 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -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: [email protected]
license: LGPL-3.0
repository-code: https://github.com/pik-piam/mrlandcore

4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre"))
Expand All @@ -11,4 +11,4 @@ URL: https://github.com/pik-piam/mrlandcore
Suggests:
testthat
Encoding: UTF-8
RoxygenNote: 7.2.1
RoxygenNote: 7.3.1
46 changes: 46 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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()'
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Generated by roxygen2: do not edit by hand

6 changes: 6 additions & 0 deletions R/mrlandcore-package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#' @keywords internal
"_PACKAGE"

## usethis namespace: start
## usethis namespace: end
NULL
53 changes: 53 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>.

## 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, <https://github.com/pik-piam/mrlandcore>.

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},
}
```
22 changes: 22 additions & 0 deletions man/mrlandcore-package.Rd

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

1 change: 1 addition & 0 deletions tests/testthat/test-dummy.R
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
skip("dummy test")

0 comments on commit d34201a

Please sign in to comment.