-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestdeployment.R
59 lines (46 loc) · 1.72 KB
/
testdeployment.R
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
################################################################################
# setup
library(crayon)
exec <- function(cmd, temp.dir = NULL) {
cat(green(paste0("== RUNNING: ",cmd,"\n")))
out <- system(cmd,
ignore.stdout = TRUE,
ignore.stderr = FALSE)
if (out != 0) {
# remove temp dir and output
cat(yellow(paste0("== REMOVING: ",temp.dir,"\n")))
unlink(temp.dir, recursive = TRUE)
stop(red(paste0("== ERROR: ",cmd)))
}
}
################################################################################
# deployment test
## temp
dir <- tempdir()
setwd(dir)
## clone
exec("git clone --depth=1 [email protected]:cayek/TESS3Article.git")
setwd("TESS3Article")
tmp.dir <- paste0(dir,"/TESS3Article")
## retrieve binary data
exec("make pull_binary", temp.dir = tmp.dir)
## pull docker image
## RMK : stop and rm container can be necessary before running
exec("make pull", temp.dir = tmp.dir)
exec("make run", temp.dir = tmp.dir)
## make
### figure1
exec("docker exec tess3_article bash -c 'cd Figure1/; make figures'" , temp.dir = tmp.dir)
### figure2
exec("docker exec tess3_article bash -c 'cd Figure2/; make figures'" , temp.dir = tmp.dir)
### figure3
exec("docker exec tess3_article bash -c 'cd Figure3/; make figures'" , temp.dir = tmp.dir)
### figure4
exec("docker exec tess3_article bash -c 'cd Figure4/; make figures'" , temp.dir = tmp.dir)
### figure5
exec("docker exec tess3_article bash -c 'cd Figure5/; make figures'" , temp.dir = tmp.dir)
exec("docker exec tess3_article bash -c 'cd Figure5/; make rmarkdowns'" , temp.dir = tmp.dir)
## stop docker container
exec("make stop", temp.dir = tmp.dir)
exec("make rm_container", temp.dir = tmp.dir)
cat(bgCyan("Ok for deployment !\n"))