forked from Rdatatable/data.table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
368 lines (342 loc) · 14 KB
/
.gitlab-ci.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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
variables:
CRAN_MIRROR: "https://cloud.r-project.org"
_R_CHECK_FORCE_SUGGESTS_: "FALSE"
stages:
- dependencies
- build
- test
- integration
- deploy
.artifacts-template: &artifacts
artifacts:
expire_in: 2 weeks
when: always
paths:
- bus
mirror-packages: # download all recursive dependencies of data.table suggests and integration suggests from inst/tests/tests-DESCRIPTION
stage: dependencies
tags:
- linux
image: registry.gitlab.com/jangorecki/dockerfiles/r-base-dev
cache:
paths:
- bus/$CI_BUILD_NAME/cran
variables:
R_BIN_VERSION: "3.5"
R_DEVEL_BIN_VERSION: "3.6"
script:
- echo 'source("ci.R")' >> .Rprofile
- mkdir -p bus/$CI_BUILD_NAME/cran/src/contrib
# mirror R dependencies: source, win.binary
- Rscript -e 'mirror.packages(dcf.dependencies(c("DESCRIPTION","inst/tests/tests-DESCRIPTION"), "all"), repos=c(Sys.getenv("CRAN_MIRROR"), dcf.repos("inst/tests/tests-DESCRIPTION")), repodir="bus/mirror-packages/cran")'
- Rscript -e 'sapply(simplify=FALSE, setNames(nm=Sys.getenv(c("R_BIN_VERSION","R_DEVEL_BIN_VERSION"))), function(binary.ver) mirror.packages(type="win.binary", dcf.dependencies("DESCRIPTION", "all"), repos=Sys.getenv("CRAN_MIRROR"), repodir="bus/mirror-packages/cran", binary.ver=binary.ver))'
<<: *artifacts
build: # build data.table sources as tar.gz archive
stage: build
tags:
- linux
image: registry.gitlab.com/jangorecki/dockerfiles/r-builder
dependencies:
- mirror-packages
script:
- Rscript -e 'install.packages("knitr", repos=file.path("file:",normalizePath("bus/mirror-packages/cran")))'
- rm -r bus
- echo "Revision:" $CI_BUILD_REF >> ./DESCRIPTION
- R CMD build .
- mkdir -p bus/$CI_BUILD_NAME/cran/src/contrib
- mv $(ls -1t data.table_*.tar.gz | head -n 1) bus/$CI_BUILD_NAME/cran/src/contrib/.
- Rscript -e 'tools::write_PACKAGES(contrib.url("bus/build/cran"), fields="Revision", addFiles=TRUE)'
<<: *artifacts
.test-copy-src: ©-src
- ©-src
cp $(ls -1t bus/build/cran/src/contrib/data.table_*.tar.gz | head -n 1) .
.test-move-src: &move-src
- &move-src
mkdir -p bus/$CI_BUILD_NAME && mv $(ls -1t data.table_*.tar.gz | head -n 1) bus/$CI_BUILD_NAME
.test-cleanup-src: &cleanup-src
- &cleanup-src
rm $(ls -1t data.table_*.tar.gz | head -n 1)
.test-template: &test
stage: test
dependencies:
- mirror-packages
- build
<<: *artifacts
.test-linux-template: &test-linux
<<: *test
tags:
- linux
.test-windows-template: &test-windows
<<: *test
tags:
- windows
before_script:
- export PATH="/c/$R_DIR/bin:/c/Rtools/bin:$PATH"
- rm -rf /tmp/$R_DIR/library && mkdir -p /tmp/$R_DIR/library
- export R_LIBS_USER="/tmp/$R_DIR/library"
.test-macosx-template: &test-macosx
<<: *test
tags:
- macosx
test-r-release: # most comprehensive tests, force all suggests, also integration tests
<<: *test-linux
image: registry.gitlab.com/jangorecki/dockerfiles/r-builder
variables: # unlike CRAN
_R_CHECK_CRAN_INCOMING_: "FALSE"
_R_CHECK_CRAN_INCOMING_REMOTE_: "FALSE"
_R_CHECK_FORCE_SUGGESTS_: "TRUE"
OPENBLAS_MAIN_FREE: "1"
TEST_DATA_TABLE_WITH_OTHER_PACKAGES: "TRUE"
script:
- Rscript -e 'source("ci.R"); install.packages(dcf.dependencies(c("DESCRIPTION","inst/tests/tests-DESCRIPTION"), which="all"))'
- *copy-src
- rm -r bus
- *move-src
- cd bus/$CI_BUILD_NAME
- R CMD check $(ls -1t data.table_*.tar.gz | head -n 1)
- *cleanup-src
test-r-release-vanilla: # minimal installation, no suggested deps, no vignettes or manuals, measure memory
<<: *test-linux
image: registry.gitlab.com/jangorecki/dockerfiles/r-base-dev
variables:
TEST_DATA_TABLE_MEMTEST: "TRUE"
script:
- *copy-src
- rm -r bus
- *move-src
- cd bus/$CI_BUILD_NAME
- R CMD check --no-manual --ignore-vignettes $(ls -1t data.table_*.tar.gz | head -n 1)
- *cleanup-src
test-r-release-cran: # as CRAN
<<: *test-linux
image: registry.gitlab.com/jangorecki/dockerfiles/r-builder
variables:
_R_CHECK_CRAN_INCOMING_: "TRUE"
_R_CHECK_CRAN_INCOMING_REMOTE_: "TRUE"
script:
- Rscript -e 'source("ci.R"); install.packages(dcf.dependencies("DESCRIPTION", which="most"))'
- *copy-src
- rm -r bus
- *move-src
- cd bus/$CI_BUILD_NAME
- R CMD check --as-cran $(ls -1t data.table_*.tar.gz | head -n 1)
- *cleanup-src
test-r-devel-cran: # R-devel as CRAN
<<: *test-linux
image: registry.gitlab.com/jangorecki/dockerfiles/r-devel
allow_failure: true
variables:
_R_CHECK_CRAN_INCOMING_: "TRUE"
_R_CHECK_CRAN_INCOMING_REMOTE_: "TRUE"
script:
- Rscript -e 'source("ci.R"); install.packages(dcf.dependencies("DESCRIPTION", which="most"))'
- *copy-src
- rm -r bus
- *move-src
- cd bus/$CI_BUILD_NAME
- R CMD check --as-cran $(ls -1t data.table_*.tar.gz | head -n 1)
- *cleanup-src
test-r-3.1.0-cran: # test stated dependency on R 3.1.0 as CRAN
<<: *test-linux
image: registry.gitlab.com/jangorecki/dockerfiles/r-3.1.0
variables:
_R_CHECK_CRAN_INCOMING_: "TRUE"
_R_CHECK_CRAN_INCOMING_REMOTE_: "TRUE"
script:
- Rscript -e 'source("ci.R"); install.packages(dcf.dependencies("DESCRIPTION", which="most"))'
- *copy-src
- rm -r bus
- *move-src
- cd bus/$CI_BUILD_NAME
- R CMD check --as-cran $(ls -1t data.table_*.tar.gz | head -n 1)
- *cleanup-src
test-r-release-windows: # windows test and build binaries
<<: *test-windows
variables:
R_BIN_VERSION: "3.5"
R_DIR: "R-3.5.0"
script:
- Rscript -e "source('ci.R'); install.packages(dcf.dependencies('DESCRIPTION', which='all'))"
- *copy-src
- rm -r bus
- *move-src
- cd bus/$CI_BUILD_NAME
- R CMD check --no-manual $(ls -1t data.table_*.tar.gz | head -n 1)
- R CMD INSTALL --build $(ls -1t data.table_*.tar.gz | head -n 1)
- mkdir -p cran/bin/windows/contrib/$R_BIN_VERSION
- mv $(ls -1t data.table_*.zip | head -n 1) cran/bin/windows/contrib/$R_BIN_VERSION
- *cleanup-src
test-r-devel-windows: # R-devel on windows
<<: *test-windows
variables:
R_BIN_VERSION: "3.6"
R_DIR: "R-devel"
TEST_DATA_TABLE_MEMTEST: "TRUE"
allow_failure: true
script:
- Rscript -e "source('ci.R'); install.packages(dcf.dependencies('DESCRIPTION', which='all'))"
- *copy-src
- rm -r bus
- *move-src
- cd bus/$CI_BUILD_NAME
- R CMD check --no-manual --ignore-vignettes $(ls -1t data.table_*.tar.gz | head -n 1)
- R CMD INSTALL --build $(ls -1t data.table_*.tar.gz | head -n 1)
- mkdir -p cran/bin/windows/contrib/$R_BIN_VERSION
- mv $(ls -1t data.table_*.zip | head -n 1) cran/bin/windows/contrib/$R_BIN_VERSION
- *cleanup-src
.test-r-release-macosx: # macosx test and build binaries
<<: *test-macosx
variables:
R_BIN_VERSION: "3.5"
script:
- Rscript -e 'source("ci.R"); install.packages(dcf.dependencies("DESCRIPTION", which="all"))'
- *copy-src
- rm -r bus
- *move-src
- cd bus/$CI_BUILD_NAME
- R CMD check $(ls -1t data.table_*.tar.gz | head -n 1)
- R CMD INSTALL --build $(ls -1t data.table_*.tar.gz | head -n 1)
- mkdir -p cran/bin/macosx/el-capitan/contrib/$R_BIN_VERSION
- mv $(ls -1t data.table_*.tgz | head -n 1) cran/bin/macosx/el-capitan/contrib/$R_BIN_VERSION
- *cleanup-src
integration: # merging all artifacts to produce single R repository and summaries
stage: integration
image: registry.gitlab.com/jangorecki/dockerfiles/r-builder
tags:
- linux
only:
- master
dependencies:
- mirror-packages
- build
- test-r-release
- test-r-release-cran
- test-r-devel-cran
- test-r-release-vanilla
- test-r-3.1.0-cran
- test-r-release-windows
- test-r-devel-windows
#- test-r-release-macosx
variables:
R_BIN_VERSION: "3.5"
R_DEVEL_BIN_VERSION: "3.6"
script:
- echo 'source("ci.R"); source("publish.R")' >> .Rprofile
# list of available test-* jobs dynamically based on bus/test-* directories
- Rscript -e 'cat("\ntest.jobs <- c(\n"); cat(paste0(" \"",list.files("bus",pattern="^test-"),"\" = \"data.table\""), sep=",\n"); cat(")\n")' >> .Rprofile
- Rscript -e 'sapply(names(test.jobs), check.test, pkg="data.table", simplify=FALSE)'
- mkdir -p bus/$CI_BUILD_NAME
# delete any existing non-dev version of data.table
- rm -f bus/mirror-packages/cran/src/contrib/data.table_*.tar.gz
- rm -f bus/mirror-packages/cran/bin/windows/contrib/$R_BIN_VERSION/data.table_*.zip
- rm -f bus/mirror-packages/cran/bin/windows/contrib/$R_DEVEL_BIN_VERSION/data.table_*.zip
#- rm -f bus/mirror-packages/cran/bin/macosx/el-capitan/contrib/$R_BIN_VERSION/data.table_*.tgz
#- rm -f bus/mirror-packages/cran/bin/macosx/el-capitan/contrib/$R_DEVEL_BIN_VERSION/data.table_*.tgz
# merge mirror-packages and R devel packages
- mv bus/mirror-packages/cran bus/$CI_BUILD_NAME/
# publish package sources
- mkdir -p bus/$CI_BUILD_NAME/cran/library bus/$CI_BUILD_NAME/cran/doc
- mv $(ls -1t bus/build/cran/src/contrib/data.table_*.tar.gz | head -n 1) bus/$CI_BUILD_NAME/cran/src/contrib
- Rscript -e 'tools::write_PACKAGES(contrib.url("bus/integration/cran", type="source"), type="source", fields="Revision", addFiles=TRUE)'
# publish binaries
- Rscript -e 'move.bin("test-r-release-windows", Sys.getenv("R_BIN_VERSION"), os.type="windows")'
- Rscript -e 'move.bin("test-r-devel-windows", Sys.getenv("R_DEVEL_BIN_VERSION"), os.type="windows", silent=TRUE)'
- Rscript -e 'tools::write_PACKAGES(contrib.url("bus/integration/cran", type="win.binary", ver=Sys.getenv("R_BIN_VERSION")), type="win.binary", fields="Revision", addFiles=TRUE)'
- Rscript -e 'tools::write_PACKAGES(contrib.url("bus/integration/cran", type="win.binary", ver=Sys.getenv("R_DEVEL_BIN_VERSION")), type="win.binary", fields="Revision", addFiles=TRUE)'
#- Rscript -e 'move.bin("test-r-release-macosx", Sys.getenv("R_BIN_VERSION"), os.type="macosx")'
#- Rscript -e 'move.bin("test-r-devel-macosx", Sys.getenv("R_DEVEL_BIN_VERSION"), os.type="macosx", silent=TRUE)'
#- Rscript -e 'tools::write_PACKAGES(contrib.url("bus/integration/cran", type="mac.binary.el-capitan", ver=Sys.getenv("R_BIN_VERSION")), type="mac.binary.el-capitan", fields="Revision", addFiles=TRUE)'
#- Rscript -e 'tools::write_PACKAGES(contrib.url("bus/integration/cran", type="mac.binary.el-capitan", ver=Sys.getenv("R_DEVEL_BIN_VERSION")), type="mac.binary.el-capitan", fields="Revision", addFiles=TRUE)'
# install all pkgs to render html and double check successful installation of all devel packages
- mkdir -p /tmp/opencran/library /tmp/opencran/doc/html
- Rscript -e 'install.packages("data.table", dependencies=TRUE, lib="/tmp/opencran/library", repos=file.path("file:",normalizePath("bus/integration/cran")), INSTALL_opts="--html", quiet=TRUE)'
- Rscript -e 'packageVersion("data.table", lib.loc="/tmp/opencran/library")'
# CRAN style web/CRAN_web.css
- wget -q -P bus/integration/cran/web https://cran.r-project.org/web/CRAN_web.css
# web/packages/$pkg/index.html
- Rscript -e 'sapply(rownames(installed.packages(lib.loc="/tmp/opencran/library", priority="NA")), package.index, lib.loc="/tmp/opencran/library")'
# R docs, html, css, icons
- Rscript -e 'doc.copy(repodir="/tmp/opencran")'
# Update packages.html, rewrite file:/ to relative path
- Rscript -e 'setwd("/tmp/opencran/doc/html"); make.packages.html(lib.loc="../../library", docdir="/tmp/opencran/doc"); tmp<-readLines(f<-"/tmp/opencran/doc/html/packages.html"); writeLines(gsub("file:///../../library","../../library", tmp, fixed=TRUE), f)'
- mv /tmp/opencran/doc bus/integration/cran/
# library html manual, vignettes
- Rscript -e 'lib.copy(lib.from="/tmp/opencran/library")'
# web/checks/$pkg/$job: 00install.out, 00check.log, *.Rout, memtest.csv, memtest.png
- Rscript -e 'sapply(names(test.jobs), check.copy, simplify=FALSE)'
# web/packages/$pkg/$pkg.pdf
- Rscript -e 'pdf.copy("data.table", "test-r-release")'
# web/checks/check_results_$pkg.html
- Rscript -e 'check.index("data.table", names(test.jobs))'
# cleanup artifacts from other jobs
- mkdir tmpbus
- mv bus/$CI_BUILD_NAME tmpbus
- rm -r bus
- mv tmpbus bus
<<: *artifacts
.docker-template: &docker
stage: deploy
tags:
- linux
image: docker
services:
- docker:dind
dependencies:
- build
before_script:
- sed "s/SRC_IMAGE_NAME/$SRC_IMAGE_NAME/" < Dockerfile.in > Dockerfile
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" -f Dockerfile .
- docker run --rm "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG" Rscript -e 'cat(R.version.string, "\ndata.table revision", read.dcf(system.file("DESCRIPTION", package="data.table"), fields="Revision")[[1L]], "\n"); require(data.table); test.data.table()'
- docker push "$CI_REGISTRY_IMAGE/$IMAGE_NAME:$IMAGE_TAG"
docker-r-release: # publish docker image of data.table on R-release
only:
- master
variables:
SRC_IMAGE_NAME: "r-base-dev"
IMAGE_NAME: "r-release"
IMAGE_TAG: "latest"
<<: *docker
docker-r-release-builder: # publish on R-release and OS dependencies for building Rmd vignettes
only:
- master
variables:
SRC_IMAGE_NAME: "r-builder"
IMAGE_NAME: "r-release-builder"
IMAGE_TAG: "latest"
<<: *docker
docker-r-devel: # publish docker image of data.table on R-devel
only:
- master
variables:
SRC_IMAGE_NAME: "r-devel"
IMAGE_NAME: "r-devel"
IMAGE_TAG: "latest"
<<: *docker
docker-tags: # publish only on tagged commits, we use tags for version
only:
- tags
variables:
SRC_IMAGE_NAME: "r-base-dev"
IMAGE_NAME: "r-release"
IMAGE_TAG: $CI_COMMIT_TAG
<<: *docker
pages: # publish R repository, test jobs summaries, html documentation of all packages in repo
stage: deploy
environment: production
tags:
- linux
only:
- master
image: ubuntu
dependencies:
- integration
script:
- mkdir -p public
- cp -r bus/integration/cran/* public
- cat public/src/contrib/PACKAGES
artifacts: # publish when no failure
expire_in: 2 weeks
paths:
- public