1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# 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
|