-
Notifications
You must be signed in to change notification settings - Fork 85
/
.gitlab-ci.yml
109 lines (98 loc) · 2.58 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
image: ${CI_REGISTRY_IMAGE}:latest
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
default:
tags:
- chs-shared
- dind
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"
CRAN: "https://rpkg.chs.usgs.gov/prod-cran/latest"
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"
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
-t ${CI_REGISTRY_IMAGE}:latest
.
- docker push --all-tags ${CI_REGISTRY_IMAGE}
buildcheck:
stage: check
cache: []
dependencies:
- build-image
script:
- R CMD build . --no-manual
- Rscript -e 'devtools::check(document = FALSE, args = "--no-tests", check_dir = Sys.getenv("BUILD_LOGS_DIR"), vignettes = FALSE)'
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")'
- R -e 'x <- covr::package_coverage(); covr::to_cobertura(x); x; '
artifacts:
when: always
expire_in: 1 week
paths:
- test-out.xml
reports:
junit: test-out.xml
coverage_report:
coverage_format: cobertura
path: cobertura.xml
coverage: '/Coverage: \d+.\d+\%/'
pages:
stage: end
cache: []
only:
- main
script:
- Rscript -e 'pkgdown::build_site(override = list(destination = "public"))'
- Rscript -e 'source("deploy_simple.R")'
artifacts:
paths:
- $PAGES_OUTDIR
expire_in: 1 week
Validate Inventory:
stage: end
image: ${INTERNAL_REGISTRY}software/software-management:latest
script:
- software-management review
--project "${CI_PROJECT_PATH}"
--ref "${CI_COMMIT_BRANCH}"
--type "provisional"
--token "${GIT_TOKEN_CUSTOM}"
tags:
- chs-shared