Skip to content

Commit 95cace5

Browse files
authored
Merge branch 'master' into macroRemoval
2 parents a5a6d14 + 5bb6450 commit 95cace5

File tree

24 files changed

+1159
-873
lines changed

24 files changed

+1159
-873
lines changed

.ci/README.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# data.table continuous integration and deployment
22

3-
On each Pull Request opened in GitHub we run GitHub Actions test jobs to provide prompt feedback about the status of PR. Our more thorough main CI pipeline runs nightly on GitLab CI. GitLab repository automatically mirrors our GitHub repository and runs pipeline on `master` branch every night. It tests more environments and different configurations. It publishes a variety of artifacts such as our [homepage](https://rdatatable.gitlab.io/data.table/) and [CRAN-like website for dev version](https://rdatatable.gitlab.io/data.table/web/packages/data.table/index.html), including windows binaries for the dev version.
3+
On each Pull Request opened in GitHub we run GitHub Actions test jobs to provide prompt feedback about the status of PR. Our more thorough main CI pipeline runs nightly on GitLab CI. In addition to branches pushed directly, the GitLab repository automatically mirrors our GitHub repository and runs pipeline on the `master` branch every night. It tests more environments and different configurations. It publishes a variety of artifacts such as our [homepage](https://rdatatable.gitlab.io/data.table/) and [CRAN-like website for dev version](https://rdatatable.gitlab.io/data.table/web/packages/data.table/index.html), including windows binaries for the dev version.
44

55
## Environments
66

@@ -13,7 +13,8 @@ Test jobs:
1313
- `test-lin-dev-gcc-strict-cran` - `--as-cran` on Linux, `r-devel` built with `-enable-strict-barrier --disable-long-double`, test for compilation warnings, test for new NOTEs/WARNINGs from `R CMD check`.
1414
- `test-lin-dev-clang-cran` - same as `gcc-strict` job but R built with `clang` and no `--enable-strict-barrier --disable-long-double` flags.
1515
- `test-lin-ancient-cran` - Stated R dependency version (currently 3.4.0) on Linux.
16-
- `test-lin-dev-san` - `r-devel` on Linux built with `clang -fsanitize=address,undefined` (including LeakSanitizer), test for sanitizer output in tests and examples.
16+
- `test-lin-dev-clang-san` - `r-devel` on Linux built with `clang -fsanitize=address,undefined` (including LeakSanitizer), test for sanitizer output in tests and examples.
17+
- `test-lin-dev-gcc-san` - `r-devel` on Linux built with `gcc -fsanitize=address,undefined` (including LeakSanitizer), test for sanitizer output in tests and examples.
1718
- `test-win-rel` - `r-release` on Windows.
1819
- `test-win-dev` - `r-devel` on Windows.
1920
- `test-win-old` - `r-oldrel` on Windows.
@@ -49,6 +50,23 @@ Base R implemented helper script, [originally proposed to base R](https://svn.r-
4950

5051
Base R implemented helper script to orchestrate generation of most artifacts and to arrange them nicely. It is being used only in [_integration_ stage in GitLab CI pipeline](./../.gitlab-ci.yml).
5152

53+
### [`lint.R`](./lint.R)
54+
55+
Base R runner for the manual (non-`lintr`) lint checks to be run from GitHub Actions during the code quality check. The command line arguments are as follows:
56+
1. Path to the directory containing files defining the linters. A linter is a function that accepts one argument (typically the path to the file) and signals an error if it fails the lint check.
57+
2. Path to the directory containing files to check.
58+
3. A regular expression matching the files to check.
59+
60+
One of the files in the linter directory may define the `.preprocess` function, which must accept one file path and return a value that other linter functions will understand. The function may also return `NULL` to indicate that the file must be skipped.
61+
62+
Example command lines:
63+
64+
```sh
65+
Rscript .ci/lint.R .ci/linters/c src '[.][ch]$'
66+
Rscript .ci/lint.R .ci/linters/po po '[.]po$'
67+
Rscript .ci/lint.R .ci/linters/md . '[.]R?md$'
68+
```
69+
5270
## GitLab Open Source Program
5371

5472
We are currently part of the [GitLab for Open Source Program](https://about.gitlab.com/solutions/open-source/). This gives us 50,000 compute minutes per month for our GitLab CI. Our license needs to be renewed yearly (around July) and is currently managed by @ben-schwen.

.ci/ci.R

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,11 @@ function(pkgs,
155155
db <- utils::available.packages(repos.url, type = type)
156156
allpkgs <- c(pkgs, unlist(tools::package_dependencies(unique(pkgs), db, which, recursive = TRUE), use.names = FALSE))
157157
except <- c("R", unlist(tools:::.get_standard_package_names()[except.priority], use.names = FALSE))
158-
## do not re-download existing packages, ignore version
158+
## do not re-download existing packages with the right version
159159
if (length(except.repodir) && file.exists(file.path(contrib.url(except.repodir, type = type, ver = binary.ver), "PACKAGES"))) {
160160
except.curl <- contrib.url(file.path("file:", normalizePath(except.repodir)), type = type, ver = binary.ver)
161-
except <- c(except, rownames(utils::available.packages(except.curl, type = type, fields = "Package")))
161+
except.db <- utils::available.packages(except.curl, type = type, fields = "Package")
162+
except <- c(except, merge(db, except.db, by = c("Package", "Version", "MD5sum"))[,"Package"])
162163
}
163164
newpkgs <- setdiff(allpkgs, except)
164165
if (!all(availpkgs<-newpkgs %in% rownames(db))) {
@@ -174,6 +175,13 @@ function(pkgs,
174175
"source" = "tar.gz",
175176
"mac.binary" = "tgz",
176177
"win.binary" = "zip")
178+
## clean up stale package files for which new versions will be downloaded
179+
if (file.exists(file.path(destdir, "PACKAGES"))) {
180+
repo.db <- utils::available.packages(file.path("file:", normalizePath(destdir)), type = type)
181+
oldver <- repo.db[repo.db[, "Package"] %in% newpkgs, c("Package", "Version"), drop=FALSE]
182+
oldfiles <- file.path(destdir, sprintf("%s_%s.%s", oldver[,"Package"], oldver[,"Version"], pkgsext))
183+
unlink(oldfiles[file.exists(oldfiles)])
184+
}
177185
pkgsver <- db[db[, "Package"] %in% newpkgs, c("Package", "Version"), drop=FALSE]
178186
dlfiles <- file.path(destdir, sprintf("%s_%s.%s", pkgsver[,"Package"], pkgsver[,"Version"], pkgsext))
179187
unlink(dlfiles[file.exists(dlfiles)])

.ci/lint.R

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/Rscript
2+
# Runner for the manual lint checks in .ci/linters
3+
args = commandArgs(TRUE)
4+
if (identical(args, '--help')) {
5+
writeLines(c(
6+
'Usage: Rscript .ci/lint.R .ci/linters/<KIND> <WHERE> <WHAT> [PREPROCESS]',
7+
'KIND must name the directory containing the *.R files defining the linter functions.',
8+
'WHERE must name the directory containing the files to lint, e.g. "po", or "src".',
9+
"WHAT must contain the regular expression matching the files to lint, e.g., '[.]po$', or '[.][ch]$'.",
10+
))
11+
q('no')
12+
}
13+
stopifnot(`Invalid arguments, see .ci/lint.R --help` = length(args) == 3)
14+
15+
linter_env = list2env(list(.preprocess = identity))
16+
for (f in list.files(args[[1]], full.names=TRUE)) sys.source(f, linter_env)
17+
if (!length(ls(linter_env))) stop(
18+
"No linters found after sourcing files in ", dQuote(args[[1]])
19+
)
20+
21+
sources = list.files(args[[2]], pattern = args[[3]], full.names = TRUE, recursive = TRUE)
22+
if (!length(sources)) stop(
23+
"No files to lint found in directory ", dQuote(args[[2]]), " for mask ", dQuote(args[[3]])
24+
)
25+
sources = Filter(Negate(is.null), lapply(setNames(nm = sources), linter_env$.preprocess))
26+
27+
okay = TRUE
28+
for (src in names(sources))
29+
for (linter in ls(linter_env)) tryCatch(
30+
linter_env[[linter]](sources[[src]]),
31+
error = function(e) {
32+
message('Source file ', dQuote(src), ' failed lint check ', dQuote(linter), ': ', conditionMessage(e))
33+
okay <<- FALSE
34+
}
35+
)
36+
stopifnot(`Please fix the issues above.` = okay)

.ci/linters/c/00preprocess.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.preprocess = function (f) list(
2+
c_obj = f, lines = readLines(f),
3+
preprocessed = system2(
4+
"gcc", shQuote(c("-fpreprocessed", "-E", f)),
5+
stdout = TRUE, stderr = FALSE
6+
)
7+
)

.ci/linters/md/heading_id_linter.R

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
any_mismatch = FALSE
2-
31
# ensure that ids are limited to alphanumerics and dashes
42
# (in particular, dots and underscores break the links)
53
check_header_ids = function(md) {
4+
if (!grepl('[.]Rmd$', md)) return(invisible())
5+
md = readLines(md)
66
# A bit surprisingly, some headings don't start with a letter.
77
# We're interested in those that set an id to link to, i.e., end with {#id}.
88
heading_captures = regmatches(md, regexec("^#+ \\S.*[{]#([^}]*)[}]$", md))
@@ -14,13 +14,5 @@ check_header_ids = function(md) {
1414
"On line %d, bad heading id '%s':\n%s\n",
1515
line, heading_captures[[line]][2], heading_captures[[line]][1]
1616
))
17-
!all(good_ids)
17+
stopifnot('Please fix the vignette issues above' = all(good_ids))
1818
}
19-
20-
any_error = FALSE
21-
for (vignette in list.files('vignettes', pattern = "[.]Rmd$", recursive = TRUE, full.name = TRUE)) {
22-
cat(sprintf("Checking vignette file %s...\n", vignette))
23-
rmd_lines = readLines(vignette)
24-
any_error = check_header_ids(rmd_lines) || any_error
25-
}
26-
if (any_error) stop("Please fix the vignette issues above.")

.ci/linters/md/news_linter.R

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
any_mismatch = FALSE
2-
31
# ensure that numbered list in each section is in sequence
42
check_section_numbering = function(news) {
3+
if (!grepl("NEWS", news)) return(invisible())
4+
news = readLines(news)
55
# plain '#' catches some examples; 'd' for 'data.table'
66
sections = grep("^#+ [A-Zd]", news)
77
entries = grep("^[0-9]+[.]", news)
88
entry_value = as.integer(gsub("^([0-9]+)[.].*", "\\1", news[entries]))
99
section_id = findInterval(entries, sections)
10-
10+
1111
any_mismatch = FALSE
1212
for (id in unique(section_id)) {
1313
section_entries = entry_value[section_id == id]
@@ -22,11 +22,12 @@ check_section_numbering = function(news) {
2222
paste0(" [", section_entries[!matched], " --> ", intended_value[!matched], "]", collapse="\n")
2323
))
2424
}
25-
return(any_mismatch)
25+
stopifnot("Please fix the NEWS issues above" = !any_mismatch)
2626
}
2727

2828
# ensure that GitHub link text & URL actually agree
2929
check_gh_links = function(news) {
30+
news = readLines(news)
3031
gh_links_info = gregexpr(
3132
"\\[#(?<md_number>[0-9]+)\\]\\(https://github.com/Rdatatable/data.table/(?<link_type>[^/]+)/(?<link_number>[0-9]+)\\)",
3233
news,
@@ -48,14 +49,5 @@ check_gh_links = function(news) {
4849
"In line %d, link pointing to %s %s is written #%s\n",
4950
line_number, link_type, link_number, md_number
5051
)))
51-
return(TRUE)
52-
}
53-
54-
any_error = FALSE
55-
for (news in list.files(pattern = "NEWS")) {
56-
cat(sprintf("Checking NEWS file %s...\n", news))
57-
news_lines = readLines(news)
58-
any_error = check_section_numbering(news_lines) || any_error
59-
any_error = check_gh_links(news_lines) || any_error
52+
stop("Please fix the NEWS issues above.")
6053
}
61-
if (any_error) stop("Please fix the NEWS issues above.")

.ci/linters/po/00preprocess.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.preprocess = function (f) {
2+
diff_v_master = system2('git', c('diff', 'master', f), stdout=TRUE)
3+
if (length(diff_v_master)) f
4+
}

.ci/linters/rd/options_doc_check.R

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Ensure that data.table options in code match documentation
2+
options_documentation_linter = function(rd_file) {
3+
if (!grepl("\\name{data.table-options}", readChar(rd_file, 100L), fixed = TRUE)) return(invisible())
4+
5+
# Find options in R code
6+
walk_r_ast_for_options = function(expr) {
7+
if (is.call(expr) && length(expr) >= 2L && identical(expr[[1L]], quote(getOption)) && is.character(e2 <- expr[[2L]]) && startsWith(e2, "datatable.")) {
8+
e2
9+
} else if (is.recursive(expr)) {
10+
unlist(lapply(expr, walk_r_ast_for_options))
11+
}
12+
}
13+
14+
# Find options in documentation
15+
walk_rd_ast_for_options = function(rd_element) {
16+
if (!is.list(rd_element)) return(character())
17+
18+
result = character()
19+
if (isTRUE(attr(rd_element, "Rd_tag") == "\\code") && length(rd_element) >= 1L) {
20+
content = rd_element[[1L]]
21+
if (is.character(content) && startsWith(content, "datatable.")) {
22+
result = content
23+
}
24+
}
25+
c(result, unlist(lapply(rd_element, walk_rd_ast_for_options)))
26+
}
27+
28+
code_opts = list.files("R", pattern = "\\.R$", full.names = TRUE) |>
29+
lapply(\(f) lapply(parse(f), walk_r_ast_for_options)) |>
30+
unlist() |>
31+
unique() |>
32+
setdiff("datatable.nomatch") # ignore deprecated option(s)
33+
34+
doc_opts = rd_file |>
35+
tools::parse_Rd() |>
36+
walk_rd_ast_for_options() |>
37+
unique()
38+
39+
miss_in_doc = setdiff(code_opts, doc_opts)
40+
miss_in_code = setdiff(doc_opts, code_opts)
41+
42+
if (length(miss_in_doc) > 0L || length(miss_in_code) > 0L) {
43+
if (length(miss_in_doc) > 0L) {
44+
cat(sprintf("Options in code but missing from docs: %s\n", toString(miss_in_doc)))
45+
}
46+
if (length(miss_in_code) > 0L) {
47+
cat(sprintf("Options in docs but not in code: %s\n", toString(miss_in_code)))
48+
}
49+
stop("Please sync man/data.table-options.Rd with code options")
50+
}
51+
}

.devcontainer/r-ancient-gcc/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.gitlab.com/jangorecki/dockerfiles/r-3.4.0
1+
FROM registry.gitlab.com/rdatatable/dockerfiles/r-3.4.0
22

33
RUN apt-get -qq update \
44
&& apt-get install -y --no-install-recommends git

.devcontainer/r-devel-gcc/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM registry.gitlab.com/jangorecki/dockerfiles/r-devel-gcc
1+
FROM registry.gitlab.com/rdatatable/dockerfiles/r-devel-gcc
22

33
RUN apt-get -qq update \
44
&& apt-get install -y --no-install-recommends git

0 commit comments

Comments
 (0)