# Development tasks. Everything runs through `R`, so there is nothing to # install first beyond the two runtime dependencies (curl, jsonlite) and # roxygen2 for `make document`. # # make list the targets # make test install into check/lib and run tests/ # make lint parse every file + codetools, no files touched # make build build the source tarball R ?= R RSCRIPT ?= Rscript PKG := cepis VERSION := $(shell awk '/^Version:/ { print $$2 }' DESCRIPTION) TARBALL := $(PKG)_$(VERSION).tar.gz LIB := $(CURDIR)/check/lib .DEFAULT_GOAL := help .PHONY: help install test lint document build check check-cran clean help: @echo 'Targets:' @echo ' test install into check/lib and run every tests/test-*.R' @echo ' lint parse the sources + codetools::checkUsagePackage (read-only)' @echo ' document regenerate man/ and NAMESPACE with roxygen2 (writes)' @echo ' build build $(TARBALL)' @echo ' check lint + test + build, in that order' @echo ' check-cran build, then R CMD check the tarball' @echo ' clean remove build and check artefacts' install: @mkdir -p $(LIB) $(R) CMD INSTALL --library=$(LIB) . test: install @cd tests && for file in test-*.R; do \ echo "==> $$file"; \ R_LIBS=$(LIB) $(RSCRIPT) "$$file" || exit 1; \ done # Read-only by design, so it is safe in CI and in a pre-commit hook. lint: install @R_LIBS=$(LIB) $(RSCRIPT) -e 'for (f in list.files(c("R", "tests"), pattern = "[.]R$$", recursive = TRUE, full.names = TRUE)) invisible(parse(f)); cat("parsed\n")' @R_LIBS=$(LIB) $(RSCRIPT) -e 'suppressMessages(library($(PKG))); codetools::checkUsagePackage("$(PKG)", suppressLocalUnused = TRUE); cat("checked\n")' document: $(RSCRIPT) -e 'roxygen2::roxygenise(load_code = "source")' build: $(R) CMD build . # The order matters: lint is the fastest to fail, build the slowest, so a # broken run reports the cheapest problem first. check: lint test build check-cran: build $(R) CMD check --no-manual $(TARBALL) clean: rm -rf check $(PKG).Rcheck *.tar.gz