-
Notifications
You must be signed in to change notification settings - Fork 11
/
.gitlab-ci.yml
125 lines (115 loc) · 3.33 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
image: ${CI_REGISTRY_IMAGE}:latest
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
stages:
- build
- check
- test
- end
- deploy
variables:
_R_CHECK_CRAN_INCOMING_: "false"
_R_CHECK_SUGGESTS_ONLY: "false"
_R_CHECK_FORCE_SUGGESTS_: "true"
_R_CHECK_DONTTEST_EXAMPLES_: "false"
R_PROFILE: "$R_HOME/etc/Rprofile.site"
APT_CACHE: "$CI_PROJECT_DIR/ci/lib/apt-cache"
R_LIBS_USER: "$CI_PROJECT_DIR/ci/lib"
R_LIBS: "$CI_PROJECT_DIR/ci/lib"
BUILD_LOGS_DIR: "$CI_PROJECT_DIR/ci/logs"
NOT_CRAN: "true"
PKG_PATH: "$CI_PROJECT_DIR/docs"
CONNECT_API_KEY: $CONNECT_API_KEY
CONNECT_SERVER: $CONNECT_SERVER
PAGES_OUTDIR: "$CI_PROJECT_DIR/public"
build-image:
stage: build
cache: []
image: ${DEVOPS_REGISTRY}usgs/docker:20
services:
- name: ${DEVOPS_REGISTRY}usgs/docker:20-dind
alias: docker
rules:
- changes:
- docker/Dockerfile
- .gitlab-ci.yml
script:
- echo ${CI_REGISTRY_PASSWORD} | docker login -u ${CI_REGISTRY_USER} --password-stdin $CI_REGISTRY
- docker pull ${CI_REGISTRY_IMAGE}:latest || true
- cd docker
- docker build
--cache-from ${CI_REGISTRY_IMAGE}:latest
-t ${CI_REGISTRY_IMAGE}:BUILD_${CI_COMMIT_SHORT_SHA}
-t ${CI_REGISTRY_IMAGE}:latest
.
# If this is building a git tag, create the corresponding docker tag
- if [ -n "${CI_COMMIT_TAG}" ]; then docker tag ${CI_REGISTRY_IMAGE}:BUILD_${CI_COMMIT_SHORT_SHA} ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG}; fi
- docker push --all-tags ${CI_REGISTRY_IMAGE}
buildcheck:
stage: check
cache: []
dependencies:
- build-image
script:
- R CMD build . --no-build-vignettes --no-manual
- R -e 'devtools::check(document = FALSE, args = "--no-tests", error_on = "error", check_dir = Sys.getenv("BUILD_LOGS_DIR"))'
artifacts:
expire_in: 1 week
paths:
- $BUILD_LOGS_DIR
unittests:
stage: test
cache: []
dependencies:
- build-image
- buildcheck
script:
- R -e 'library(testthat); options(testthat.output_file = file.path(Sys.getenv("CI_PROJECT_DIR"), "test-out.xml")); devtools::test(reporter = "junit")'
artifacts:
when: always
expire_in: 1 week
paths:
- test-out.xml
reports:
junit: test-out.xml
covertests:
stage: test
dependencies:
- build-image
- buildcheck
script:
- R -e 'x <- covr::package_coverage(); covr::to_cobertura(x); x; '
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: cobertura.xml
expire_in: 1 week
coverage: '/Coverage: \d+.\d+\%/'
pages:
stage: end
only:
- main
script:
- echo -e "options(repos=c(DEV = '${DEV}', CRAN = '${CRAN}'));" >> $R_PROFILE
- Rscript -e 'install.packages("toxEval", repos = Sys.getenv("DEV")); packageVersion("toxEval"); source("deploy_simple.R")'
- Rscript -e 'pkgdown::build_site(override = list(destination = "public"))'
artifacts:
paths:
- $PAGES_OUTDIR
expire_in: 1 week
Validate Inventory:
stage: end
image: ${INTERNAL_REGISTRY}software/software-management:latest
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- software-management review
--project "${CI_PROJECT_PATH}"
--ref "${CI_COMMIT_BRANCH}"
--type "provisional"
--token "${GIT_TOKEN_CUSTOM}"
tags:
- chs-shared