-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
290 lines (242 loc) · 8.53 KB
/
Makefile
File metadata and controls
290 lines (242 loc) · 8.53 KB
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# Makefile for fmrireg R package
# ===================================
.PHONY: help install check test document coverage coverage-report clean vignettes deps
# Default target
help:
@echo "fmrireg Makefile"
@echo "================"
@echo ""
@echo "Available targets:"
@echo " make install - Install package and dependencies"
@echo " make deps - Install all dependencies"
@echo " make document - Generate documentation with roxygen2"
@echo " make check - Run R CMD check"
@echo " make check-cran - Run R CMD check with CRAN settings"
@echo " make test - Run all tests"
@echo " make test-file FILE=<file> - Run specific test file"
@echo " make coverage - Generate test coverage report (interactive)"
@echo " make coverage-report - Generate and open HTML coverage report"
@echo " make coverage-ci - Generate coverage for CI (codecov format)"
@echo " make vignettes - Build vignettes"
@echo " make clean - Clean built files"
@echo " make clean-all - Deep clean (including installed package)"
@echo " make spell - Check spelling"
@echo " make url-check - Check URLs in documentation"
@echo " make lint - Run lintr checks"
@echo " make format - Format code with styler"
@echo ""
# Installation targets
# ---------------------
install: document
@echo "Installing fmrireg..."
R CMD INSTALL --no-multiarch --with-keep.source .
deps:
@echo "Installing dependencies..."
Rscript -e "if (!requireNamespace('remotes', quietly = TRUE)) install.packages('remotes')"
Rscript -e "remotes::install_deps(dependencies = TRUE, upgrade = 'never')"
# Documentation targets
# ----------------------
document:
@echo "Generating documentation..."
Rscript -e "devtools::document()"
vignettes:
@echo "Building vignettes..."
Rscript -e "devtools::build_vignettes()"
# Testing targets
# ----------------
test:
@echo "Running all tests..."
Rscript -e "devtools::test()"
test-file:
ifndef FILE
@echo "Error: FILE not specified. Usage: make test-file FILE=test_ar_integration.R"
@exit 1
endif
@echo "Running tests in $(FILE)..."
Rscript -e "testthat::test_file('tests/testthat/$(FILE)')"
# Coverage targets
# -----------------
coverage: document
@echo "Generating test coverage report (interactive)..."
@echo ""
Rscript -e '\
if (!requireNamespace("covr", quietly = TRUE)) { \
stop("covr package not installed. Install with: install.packages(\"covr\")"); \
}; \
cov <- covr::package_coverage(type = c("tests", "examples"), quiet = FALSE); \
print(cov); \
cat("\n"); \
covr::report(cov, browse = FALSE); \
invisible(cov)'
coverage-report: document
@echo "Generating HTML coverage report..."
@mkdir -p coverage
Rscript -e '\
if (!requireNamespace("covr", quietly = TRUE)) { \
stop("covr package not installed. Install with: install.packages(\"covr\")"); \
}; \
cov <- covr::package_coverage(type = c("tests", "examples"), quiet = FALSE); \
print(cov); \
cat("\n=================================\n"); \
cat("Coverage Summary:\n"); \
cat("=================================\n"); \
print(covr::percent_coverage(cov)); \
cat("\n"); \
cat("Generating HTML report...\n"); \
report_file <- covr::report(cov, file = "coverage/coverage.html", browse = FALSE); \
cat(sprintf("Coverage report saved to: %s\n", normalizePath(report_file))); \
cat("\nOpening in browser...\n"); \
browseURL(report_file)'
coverage-ci:
@echo "Generating coverage for CI (codecov format)..."
Rscript -e '\
if (!requireNamespace("covr", quietly = TRUE)) { \
stop("covr package not installed. Install with: install.packages(\"covr\")"); \
}; \
cov <- covr::package_coverage(type = c("tests", "examples"), quiet = FALSE); \
print(cov); \
cat("\n"); \
cat(sprintf("Total coverage: %.2f%%\n", covr::percent_coverage(cov))); \
covr::codecov(coverage = cov)'
coverage-summary: document
@echo "Quick coverage summary..."
Rscript -e '\
cov <- covr::package_coverage(type = "tests", quiet = TRUE); \
cat(sprintf("\nTotal test coverage: %.2f%%\n\n", covr::percent_coverage(cov))); \
df <- covr::tally_coverage(cov, by = "line"); \
by_file <- aggregate(value ~ filename, data = df, FUN = function(x) sum(x > 0) / length(x) * 100); \
by_file <- by_file[order(-by_file$$value), ]; \
names(by_file) <- c("File", "Coverage %"); \
print(by_file, row.names = FALSE)'
# Check targets
# --------------
check: document
@echo "Running R CMD check..."
Rscript -e "devtools::check()"
check-cran: document
@echo "Running R CMD check with CRAN settings..."
Rscript -e "devtools::check(cran = TRUE)"
check-fast: document
@echo "Running fast R CMD check (no vignettes, no examples)..."
Rscript -e "devtools::check(vignettes = FALSE, run_dont_test = FALSE)"
# Code quality targets
# ---------------------
spell:
@echo "Checking spelling..."
Rscript -e "devtools::spell_check()"
url-check:
@echo "Checking URLs..."
Rscript -e '\
if (!requireNamespace("urlchecker", quietly = TRUE)) { \
install.packages("urlchecker"); \
}; \
urlchecker::url_check()'
lint:
@echo "Running lintr checks..."
Rscript -e '\
if (!requireNamespace("lintr", quietly = TRUE)) { \
stop("lintr not installed. Install with: install.packages(\"lintr\")"); \
}; \
lintr::lint_package()'
format:
@echo "Formatting R code with styler..."
Rscript -e '\
if (!requireNamespace("styler", quietly = TRUE)) { \
stop("styler not installed. Install with: install.packages(\"styler\")"); \
}; \
styler::style_pkg()'
# Build targets
# --------------
build: document
@echo "Building source package..."
R CMD build .
build-binary: document
@echo "Building binary package..."
R CMD INSTALL --build .
# Cleanup targets
# ----------------
clean:
@echo "Cleaning built files..."
@rm -rf src/*.o src/*.so src/*.dll
@rm -rf man/*.Rd
@rm -rf *.tar.gz
@rm -rf ..Rcheck
@rm -rf coverage
@rm -rf doc
@rm -rf Meta
clean-all: clean
@echo "Deep cleaning..."
@Rscript -e "remove.packages('fmrireg')" 2>/dev/null || true
# CI/CD targets
# --------------
ci-deps:
@echo "Installing CI dependencies..."
Rscript -e "remotes::install_deps(dependencies = TRUE, upgrade = 'always')"
Rscript -e "install.packages(c('covr', 'devtools', 'testthat'))"
ci-check: document
@echo "Running CI checks..."
Rscript -e "devtools::check(error_on = 'warning', check_dir = '.', cran = TRUE)"
ci-test:
@echo "Running CI tests..."
Rscript -e "devtools::test(reporter = 'summary')"
# Development targets
# --------------------
dev-deps:
@echo "Installing development dependencies..."
Rscript -e '\
pkgs <- c("devtools", "testthat", "covr", "lintr", "styler", \
"urlchecker", "roxygen2", "knitr", "rmarkdown"); \
install.packages(pkgs)'
quick: document test
@echo "Quick development cycle complete!"
watch:
@echo "Watching for changes and running tests..."
@while true; do \
inotifywait -r -e modify,create,delete R/ tests/ src/ 2>/dev/null && \
make quick; \
done
# Debugging targets
# ------------------
debug-test:
ifndef FILE
@echo "Error: FILE not specified. Usage: make debug-test FILE=test_ar_integration.R"
@exit 1
endif
@echo "Running test with browser() support..."
Rscript -e "testthat::test_file('tests/testthat/$(FILE)', reporter = 'progress')"
show-coverage-files:
@echo "Files with coverage data:"
Rscript -e '\
cov <- covr::package_coverage(type = "tests", quiet = TRUE); \
df <- covr::tally_coverage(cov, by = "line"); \
files <- unique(df$$filename); \
cat(paste(files, collapse = "\n")); \
cat("\n")'
# Info targets
# -------------
info:
@echo "Package: fmrireg"
@echo "Version: $$(grep '^Version:' DESCRIPTION | sed 's/Version: //')"
@echo "R version: $$(R --version | head -1)"
@echo "Installed: $$(Rscript -e 'cat(ifelse(requireNamespace(\"fmrireg\", quietly=TRUE), \"Yes\", \"No\"))' 2>/dev/null || echo 'No')"
@echo ""
@echo "Test files: $$(ls tests/testthat/test*.R 2>/dev/null | wc -l | tr -d ' ')"
@echo "R files: $$(ls R/*.R 2>/dev/null | wc -l | tr -d ' ')"
@echo "C++ files: $$(ls src/*.cpp 2>/dev/null | wc -l | tr -d ' ')"
# Package release targets
# ------------------------
release-check: clean-all deps document check-cran spell url-check
@echo "Pre-release checks complete!"
@echo ""
@echo "Next steps:"
@echo " 1. Review check results"
@echo " 2. Update NEWS.md"
@echo " 3. Update version in DESCRIPTION"
@echo " 4. Run: make coverage-report"
@echo " 5. Commit and tag release"
wincheck:
@echo "Submitting to win-builder..."
Rscript -e "devtools::check_win_devel()"
rhub-check:
@echo "Checking on rhub..."
Rscript -e "rhub::check_for_cran()"