-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
153 lines (121 loc) · 4.1 KB
/
Makefile
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
### * Description
# This is a Makefile, which can be used with the `make` command from the
# terminal to automatically run some tasks based on rules defined below.
### * Setup
# Get the path to the project top directory (based on where the `.git` folder is located)
TOP_DIR=$(shell git rev-parse --show-toplevel)
### ** Colors
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-printf-in-linux
# https://siongui.github.io/2016/02/18/makefile-printf-color-output/#id3
RED = "\\033[31m"
GREEN = "\\033[92m"
NC = "\\033[0m"
### * Rules
### ** help
# http://swcarpentry.github.io/make-novice/08-self-doc/
# https://stackoverflow.com/questions/19129485/in-linux-is-there-a-way-to-align-text-on-a-delimiter
.PHONY: help
help: Makefile
@printf "\n"
@printf "Please use 'make <target>' where <target> is one of\n"
@printf "\n"
@sed -n 's/^## / /p' $< | column -t -s ":"
### ** document
## document : generate package documentation using Roxygen
.PHONY: document
document:
@printf "\n"
@printf "$(GREEN)*** Generating package documentation with Roxygen ***$(NC)\n"
@printf "\n"
@ Rscript -e 'devtools::document()'
### ** test
## test : run package tests
.PHONY: test
test:
@printf "\n"
@printf "$(GREEN)*** Running package tests ***$(NC)\n"
@printf "\n"
@Rscript -e "library(devtools); test()"
@cd tests/testthat; rm -f Rplots.pdf
### ** coverage
## coverage : determine test coverage
.PHONY: coverage
coverage:
@printf "\n"
@printf "$(GREEN)*** Determining test coverage ***$(NC)\n"
@printf "\n"
@mkdir -p docs/coverage/
@Rscript -e "library(covr); cov = package_coverage(); report(cov, \"$(TOP_DIR)/docs/coverage/coverage.html\"); print(paste(\"Coverage_percent: --\", round(percent_coverage(cov), 2), \"--\"))"
### ** install
## install : install the package (also runs "document")
.PHONY: install
install: document
@printf "\n"
@printf "$(GREEN)*** Installing the package ***$(NC)\n"
@printf "\n"
@Rscript -e 'devtools::install(upgrade = FALSE)'
### ** install-deps
## install-deps : install dependencies needed for CI pipelines
.PHONY: install-deps
install-deps:
@printf "\n"
@printf "$(GREEN)*** Installing dependencies for continuous integration pipelines ***$(NC)\n"
@printf "\n"
@Rscript -e 'install.packages(c("ape", "readxl", "writexl", "testthat", "stringdist", "qualV", "igraph", "DT"))'
@Rscript -e 'install.packages(c("pkgdown", "covr"))'
### ** install-with-deps
## install-with-deps : run 'install-deps' and 'install'
.PHONY: install-with-deps
install-with-deps: install-deps install
### ** pkgdown
## pkgdown : build the package website in docs/ using pkgdown
.PHONY: pkgdown
pkgdown:
@printf "\n"
@printf "$(GREEN)*** Building package website with pkgdown ***$(NC)\n"
@printf "\n"
@Rscript -e 'pkgdown::build_site()'
### ** check
## check : run R CMD CHECK through devtools check() function
.PHONY: check
check:
@printf "\n"
@printf "$(GREEN)*** Running 'devtools::check()' ***$(NC)\n"
@printf "\n"
@Rscript .run_check_and_get_badge.R
### ** clean
## clean : delete all files and folders automatically generated
.PHONY: clean
clean: clean-man clean-docs clean-vignettes
@printf "\n"
@printf "$(GREEN)*** Cleaned automatically generated files and folders ***$(NC)\n"
@printf "\n"
rm -f rhub-report_*
### ** clean-man
##clean-man : delete documentation generated by Roxygen
.PHONY: clean-man
clean-man:
rm -f man/*.Rd
### ** clean-docs
##clean-docs : delete documentation generated by pkgdown
.PHONY: clean-docs
clean-docs:
rm -fr docs/*
### ** clean-vignettes
##clean-vignettes : delete files generated during vignettes run
.PHONY: clean-vignettes
clean-vignettes:
@rm -fr vignettes/merged-seqs*
@rm -fr vignettes/concatenated*
@rm -fr vignettes/concatipede_test
@rm -fr vignettes/Macrobiotidae_4genes*
@rm -fr vignettes/Macrobiotidae_COI*
@rm -fr vignettes/Macrobiotus_4genes*
@rm -f vignettes/*.html
@rm -f vignettes/auto-matched-for-later-check.xlsx
@rm -f vignettes/template-for-later-check.xlsx
@rm -f vignettes/my-merged-seqs.*
@rm -f vignettes/my-template.xlsx
@rm -f vignettes/template.xlsx
@rm -f vignettes/template_automatched.xlsx
@rm -f vignettes/seqnames.xlsx