-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path.gitlab-ci.yml
189 lines (181 loc) · 8.89 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
variables:
CI_TOOLS: "https://svn.r-project.org/R/branches/tools4pkgs/src/library/tools/R/packages.R"
CRAN_MIRROR: "https://cloud.r-project.org"
BIOC_MIRROR: "https://bioconductor.org/packages/3.4/bioc"
_R_CHECK_FORCE_SUGGESTS_: "FALSE"
stages:
- dependencies
- build
- test
- integration
- deploy
mirror-packages:
stage: dependencies
tags:
- linux
image: docker.io/jangorecki/r-base-dev
script:
- mkdir -p bus/$CI_BUILD_NAME/cran/src/contrib
# mirror R dependencies
- Rscript -e 'source(Sys.getenv("CI_TOOLS")); mirror.packages(packages.dcf("DESCRIPTION", "all"), repos=c(Sys.getenv("CRAN_MIRROR"), Sys.getenv("BIOC_MIRROR")), repodir="bus/mirror-packages/cran")'
#- Rscript -e 'source(Sys.getenv("CI_TOOLS")); mirror.packages(type="win.binary", packages.dcf("DESCRIPTION", "all"), repos=c(Sys.getenv("CRAN_MIRROR"), Sys.getenv("BIOC_MIRROR")), repodir="bus/mirror-packages/cran")'
artifacts:
expire_in: 2 weeks
paths:
- bus
build:
stage: build
tags:
- linux
image: docker.io/jangorecki/r-builder
dependencies:
- mirror-packages
script:
- Rscript -e 'install.packages(c("data.table","R6","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.cube_*.tar.gz | head -n 1) bus/$CI_BUILD_NAME/cran/src/contrib/.
- Rscript -e 'tools::write_PACKAGES(contrib.url("bus/build/cran"), addFiles=TRUE, fields="Revision")'
artifacts:
expire_in: 2 weeks
paths:
- bus
test-r-release: # R-release most comprehensive tests, force all suggests
stage: test
tags:
- linux
variables: # unlike CRAN
_R_CHECK_CRAN_INCOMING_: "FALSE"
_R_CHECK_CRAN_INCOMING_REMOTE_: "FALSE"
_R_CHECK_FORCE_SUGGESTS_: "TRUE"
OPENBLAS_MAIN_FREE: "1"
image: docker.io/jangorecki/r-builder
dependencies:
- mirror-packages
- build
script:
- mkdir -p bus/$CI_BUILD_NAME
- Rscript -e 'source(Sys.getenv("CI_TOOLS")); if (length(pkgs<-packages.dcf("DESCRIPTION", "all"))) install.packages(pkgs, repos=file.path("file:",normalizePath("bus/mirror-packages/cran")))'
- cd bus/$CI_BUILD_NAME
- Rscript -e 'file.copy(download.packages("data.cube", repos=file.path("file:",normalizePath("../build/cran")))[,2], ".")'
- R CMD check $(ls -1t data.cube_*.tar.gz | head -n 1)
artifacts:
expire_in: 2 weeks
when: always
paths:
- bus
test-r-release-cran: # R-release CRAN check
stage: test
tags:
- linux
image: docker.io/jangorecki/r-builder
variables:
_R_CHECK_CRAN_INCOMING_: "TRUE"
_R_CHECK_CRAN_INCOMING_REMOTE_: "TRUE"
dependencies:
- mirror-packages
- build
script:
- mkdir -p bus/$CI_BUILD_NAME
- Rscript -e 'source(Sys.getenv("CI_TOOLS")); if (length(pkgs<-packages.dcf("DESCRIPTION", "all"))) install.packages(pkgs, repos=file.path("file:",normalizePath("bus/mirror-packages/cran")))'
- cd bus/$CI_BUILD_NAME
- Rscript -e 'file.copy(download.packages("data.cube", repos=file.path("file:",normalizePath("../build/cran")))[,2], ".")'
- R CMD check --as-cran $(ls -1t data.cube_*.tar.gz | head -n 1)
artifacts:
expire_in: 2 weeks
when: always
paths:
- bus
test-r-3.1.0-cran:
stage: test
tags:
- linux
image: docker.io/jangorecki/r-3.1.0
variables:
_R_CHECK_CRAN_INCOMING_: "TRUE"
_R_CHECK_CRAN_INCOMING_REMOTE_: "TRUE"
dependencies:
- mirror-packages
- build
script:
- mkdir -p bus/$CI_BUILD_NAME
- curl -O $CI_TOOLS
- R3script -e 'source("packages.R"); if (length(pkgs<-packages.dcf("DESCRIPTION", "all"))) install.packages(pkgs, repos=file.path("file:",normalizePath("bus/mirror-packages/cran")))'
- cd bus/$CI_BUILD_NAME
- R3script -e 'file.copy(download.packages("data.cube", repos=file.path("file:",normalizePath("../build/cran")))[,2], ".")'
- R3 CMD check --no-manual --as-cran $(ls -1t data.cube_*.tar.gz | head -n 1)
artifacts:
expire_in: 2 weeks
when: always
paths:
- bus
integration:
stage: integration
tags:
- linux
only:
- master
image: docker.io/jangorecki/r-builder
dependencies:
- mirror-packages
- build
- test-r-release
- test-r-release-cran
- test-r-3.1.0-cran
script:
- mkdir -p bus/$CI_BUILD_NAME
# integration helpers, not in tools4pkgs branch, for multi pkgs use: pkg<-strsplit(job, "-", fixed=TRUE)[[1L]][2L]
- echo 'test.jobs<-c("test-r-release"="data.cube","test-r-release-cran"="data.cube","test-r-3.1.0-cran"="data.cube")' > integration.R
- echo 'lib.copy<-function(lib.from, repodir="bus/integration/cran"){ pkgs.from<-list.dirs(lib.from, recursive=FALSE); pkgs.to<-list.dirs(lib.to<-file.path(repodir,"library"), recursive=FALSE); pkg.copy<-function(pkg.from, lib.to){ pkg<-basename(pkg.from); dir.create(file.path(lib.to, pkg), recursive=TRUE); lib.dirs<-intersect(c("html","doc"), all.lib.dirs<-list.dirs(pkg.from, full.names=FALSE)); ans1<-setNames(file.copy(file.path(pkg.from, lib.dirs), file.path(lib.to, pkg), recursive=TRUE), lib.dirs); lib.files<-setdiff(list.files(pkg.from), all.lib.dirs); ans2<-setNames(file.copy(file.path(pkg.from, lib.files), file.path(lib.to, pkg)), lib.files); all(ans1, ans2)}; pkgs.from.new<-pkgs.from[!basename(pkgs.from) %in% basename(pkgs.to)]; setNames(sapply(pkgs.from.new, pkg.copy, lib.to=lib.to), basename(pkgs.from.new)) }' >> integration.R
- echo 'doc.copy<-function(repodir="bus/integration/cran"){ cp1<-c("COPYING","AUTHORS","THANKS"); ans1<-setNames(file.copy(file.path(R.home("doc"), cp1), file.path(repodir, "doc", cp1)), cp1); cp2<-c("html","manual"); ans2<-setNames(file.copy(file.path(R.home("doc"), cp2), file.path(repodir,"doc"), recursive=TRUE), cp2); c(ans1, ans2) }' >> integration.R
- echo 'check.copy<-function(job, repodir="bus/integration/cran"){ dir.create(job.checks<-file.path(repodir, "web", "checks", pkg<-"data.cube", job), recursive=TRUE); all(file.copy(file.path("bus", sprintf("%s/%s.Rcheck", job, pkg), c("00install.out","00check.log")), job.checks)) }' >> integration.R
- echo 'pdf.copy<-function(job, repodir="bus/integration/cran"){ dir.create(pkg.to<-file.path(repodir,"web","packages",pkg<-"data.cube"), recursive=TRUE); file.copy(file.path("bus", job, sprintf("%s.Rcheck", pkg), sprintf("%s-manual.pdf",pkg)), to=file.path(pkg.to, sprintf("%s.pdf",pkg))) }' >> integration.R
- echo 'check.test<-function(job) { check<-readLines(file.path("bus", job, sprintf("%s.Rcheck", pkg<-"data.cube"), "00check.log")); check[length(check)] }' >> integration.R
#- echo '' >> integration.R
# TODO: testing CRAN check results raise error so deploy wont start if there are check issues
- Rscript -e 'source("integration.R"); sapply(names(test.jobs), check.test, simplify=FALSE)'
# merge mirror-packages and R devel packages
- cp -R bus/mirror-packages/cran bus/$CI_BUILD_NAME/
- mkdir -p bus/$CI_BUILD_NAME/cran/library bus/$CI_BUILD_NAME/cran/doc
- mv $(ls -1t bus/build/cran/src/contrib/data.cube_*.tar.gz | head -n 1) bus/$CI_BUILD_NAME/cran/src/contrib
- Rscript -e 'tools::write_PACKAGES(contrib.url("bus/integration/cran"), addFiles=TRUE, fields="Revision")'
# 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.cube", dependencies=TRUE, lib="/tmp/opencran/library", repos=file.path("file:",normalizePath("bus/integration/cran")), INSTALL_opts="--html", quiet=TRUE)'
- Rscript -e 'sapply("data.cube", packageVersion, lib.loc="/tmp/opencran/library", simplify=FALSE)'
# R docs, html, css, icons
- Rscript -e 'source("integration.R"); 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
- Rscript -e 'source("integration.R"); lib.copy(lib.from="/tmp/opencran/library")'
# web/checks/$pkg/$job: 00install.out, 00check.log
- Rscript -e 'source("integration.R"); sapply(names(test.jobs), check.copy)'
# web/packages - here is only single package
#- Rscript -e 'source("integration.R"); sapply(sprintf("test-%s-r-release", unique(test.jobs)), pdf.copy)'
- Rscript -e 'source("integration.R"); pdf.copy("test-r-release")'
artifacts:
expire_in: 2 weeks
paths:
- bus
pages:
stage: deploy
environment: production
tags:
- linux
only:
- master
image: docker.io/ubuntu
dependencies:
- integration
script:
- mkdir -p public
- cp -r bus/integration/cran/* public
- cat public/src/contrib/PACKAGES
artifacts:
expire_in: 2 weeks
paths:
- public