-
Notifications
You must be signed in to change notification settings - Fork 35
/
Taskfile.yml
298 lines (272 loc) · 7.59 KB
/
Taskfile.yml
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
291
292
293
294
295
296
297
298
version: "3"
env:
NOT_CRAN: "true"
LIBR_POLARS_BUILD: "true"
LIBR_POLARS_FEATURES: "full_features"
VIRTUAL_ENV: "{{.VENV_DIR}}"
vars:
PACKAGE_NAME: polars
REQUIRE_R_PKGS: "arrow,nanoarrow,knitr"
VENV_DIR: .venv_altdoc
VENV_BIN:
sh: echo '{{.VENV_DIR}}/{{if eq OS "windows"}}Scripts{{else}}bin{{end}}'
MANIFEST: src/rust/Cargo.toml
CARGO_LOCK: src/rust/Cargo.lock
R_SOURCE: R/*
VIGNETTES: vignettes/**/*.Rmd
RUST_SOURCE: src/rust/src/**/*.rs
R_FUNC_IMPORT_REQUIRED_PKGS: strsplit("{{.REQUIRE_R_PKGS}}", ",") |> unlist() |> lapply(require, character.only = TRUE) |> invisible()
tasks:
setup-dev:
desc: Install tools for development.
deps:
- setup-r-tools
- setup-rust-tools
- setup-python-tools
setup-r-tools:
env:
PKG_SYSREQS: FALSE
desc: Install R packages for development.
cmds:
- Rscript -e 'install.packages("pak", repos = sprintf("https://r-lib.github.io/p/pak/stable/%s/%s/%s", .Platform$pkgType, R.Version()$os, R.Version()$arch))'
- Rscript -e
'pak::repo_add("https://cloud.r-project.org/");
pak::local_install_deps(dependencies = c("all", "Config/Needs/dev", "Config/Needs/website"))'
setup-rust-tools:
internal: true
desc: Install Rust tools for development.
vars:
RUST_TOOLCHAIN_VERSION:
sh: Rscript -e 'read.dcf("DESCRIPTION", fields = "Config/polars/RustToolchainVersion", all = TRUE)[1, 1] |> cat()'
cmds:
- task: setup-rust-toolchain
- task: setup-cargo-tools
setup-rust-toolchain:
desc: Install Rust toolchain.
vars:
RUST_TOOLCHAIN_VERSION:
sh: Rscript -e 'read.dcf("DESCRIPTION", fields = "Config/polars/RustToolchainVersion", all = TRUE)[1, 1] |> cat()'
cmds:
- rustup toolchain install {{.RUST_TOOLCHAIN_VERSION}}{{if eq OS "windows"}}-gnu{{end}}
- rustup default {{.RUST_TOOLCHAIN_VERSION}}{{if eq OS "windows"}}-gnu{{end}}
- rustup component add rustfmt
- rustup component add clippy
setup-cargo-tools:
desc: Install cargo tools for development.
cmds:
- cargo install cargo-binstall
- cargo binstall -y cargo-license cargo-outdated
setup-venv:
desc: Setup Python venv for development.
internal: true
generates:
- "{{.VENV_BIN}}"
cmds:
- python3 -m venv {{.VENV_DIR}}
setup-python-tools:
desc: Install Python tools for development.
deps:
- setup-venv
cmds:
- "{{.VENV_BIN}}/python -m pip install --upgrade uv"
- "{{.VENV_BIN}}/uv pip install --upgrade mkdocs-material mdx_truly_sane_lists"
build-lib-sums:
desc: Build lib-sums.tsv.
sources:
- dev/generate-lib-sums.R
- tools/prep-lib.R
- DESCRIPTION
- "{{.CARGO_LOCK}}"
generates:
- tools/lib-sums.tsv
cmds:
- Rscript dev/generate-lib-sums.R
build-all:
desc: Build the R package, generate documents, run all tests, and update files.
deps:
- build-lib-sums
- build-documents
cmds:
- task: test-all
- task: build-readme
test-all:
desc: Run all tests.
cmds:
- task: test-source
- task: test-examples
- task: test-vignettes
test-source:
desc: Run all tests for source.
internal: true
sources:
- tests/**/*
- "{{.R_SOURCE}}"
- src/Makevars*
- configure*
- "{{.MANIFEST}}"
- "{{.CARGO_LOCK}}"
- "{{.RUST_SOURCE}}"
deps:
- install-package
cmds:
- Rscript -e 'devtools::test()'
test-examples:
desc: Check if examples can be run.
internal: true
sources:
- "{{.R_SOURCE}}"
- src/Makevars*
- configure*
- "{{.MANIFEST}}"
- "{{.CARGO_LOCK}}"
- "{{.RUST_SOURCE}}"
deps:
- install-package
cmds:
- Rscript -e 'devtools::run_examples(document = FALSE)'
test-vignettes:
desc: Check if vignettes can be rendered.
internal: true
vars:
ITEMS:
sh: find vignettes -type f -name '*.Rmd'
sources:
- "{{.VIGNETTES}}"
- "{{.R_SOURCE}}"
- src/Makevars*
- configure*
- "{{.MANIFEST}}"
- "{{.CARGO_LOCK}}"
- "{{.RUST_SOURCE}}"
deps:
- install-package
cmds:
- for: { var: ITEMS }
cmd: Rscript -e
'library({{.PACKAGE_NAME}});
rmarkdown::render("{{.ITEM}}", output_dir = tempdir())'
build-documents:
desc: Build the R package and generate documents.
sources:
- DESCRIPTION
- "{{.R_SOURCE}}"
generates:
- man/*.Rd
status:
- Rscript -e 'if (desc::desc_get("RoxygenNote") < packageVersion("roxygen2")) quit(status = 1)'
deps:
- build-rust
- format-r
cmds:
- Rscript -e
'{{.R_FUNC_IMPORT_REQUIRED_PKGS}};
devtools::document()'
build-rust:
desc: Build the Rust library and generate the `extendr-wrappers.R` file.
sources:
- src/Makevars*
- configure*
- "{{.MANIFEST}}"
- "{{.CARGO_LOCK}}"
- "{{.RUST_SOURCE}}"
deps:
- format-rs
generates:
- R/extendr-wrappers.R
status:
- Rscript -e 'if (desc::desc_get("Config/rextendr/version") < packageVersion("rextendr")) quit(status = 1)'
cmds:
- Rscript -e
'withr::local_envvar(devtools::r_env_vars());
rextendr::register_extendr()'
build-readme:
desc: Build README.md
sources:
- README.Rmd
- "{{.R_SOURCE}}"
- src/Makevars*
- configure*
- "{{.MANIFEST}}"
- "{{.CARGO_LOCK}}"
- "{{.RUST_SOURCE}}"
generates:
- README.md
deps:
- install-package
cmds:
- Rscript -e
'library({{.PACKAGE_NAME}});
rmarkdown::render(input = "README.Rmd", output_file = "README.md")'
install-package:
desc: Install the R package.
sources:
- DESCRIPTION
- "{{.R_SOURCE}}"
- src/Makevars*
- configure*
- "{{.MANIFEST}}"
- "{{.CARGO_LOCK}}"
- "{{.RUST_SOURCE}}"
deps:
- build-documents
cmds:
- R CMD INSTALL --no-multiarch --with-keep.source .
build-website:
desc: Build the website.
sources:
- man/*.Rd
- altdoc/altdoc_preprocessing.R
- altdoc/altdoc_postprocessing.R
- altdoc/*.yml
- "{{.VIGNETTES}}"
generates:
- docs/**
cmds:
- task: build-readme
- task: build-altdoc-ref-home
- Rscript -e
'future::plan(future::multicore);
source("altdoc/altdoc_preprocessing.R");
altdoc::render_docs(freeze = FALSE, parallel = TRUE, verbose = TRUE);
source("altdoc/altdoc_postprocessing.R");'
build-altdoc-ref-home:
internal: true
desc: Build the altdoc reference home markdown
sources:
- "{{.R_SOURCE}}"
- src/Makevars*
- configure*
- "{{.MANIFEST}}"
- "{{.CARGO_LOCK}}"
- "{{.RUST_SOURCE}}"
generates:
- altdoc/reference_home.md
deps:
- install-package
cmds:
- Rscript -e
'library({{.PACKAGE_NAME}});
rmarkdown::render("altdoc/reference_home.Rmd")'
format-r:
desc: Format R source files.
vars:
FORMATER_SCRIPT: dev/styler_utils.R
sources:
- "**/*.R"
- "{{.FORMATER_SCRIPT}}"
generates:
- "**/*.R"
- exclude: R/extendr-wrappers.R
cmds:
- Rscript -e
'source("{{.FORMATER_SCRIPT}}"); style_files()'
format-rs:
desc: Format Rust source files.
sources:
- "{{.RUST_SOURCE}}"
cmds:
- cargo fmt --manifest-path "{{.MANIFEST}}"
test-snapshot-accept:
desc: Accept all test snapshots. (Shortcut to accept snapshots after running tests)
cmds:
- Rscript -e 'testthat::snapshot_accept()'