forked from DOI-USGS/dataRetrieval
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
165 lines (154 loc) · 3.93 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
165 lines (154 loc) · 3.93 KB
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
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
default:
tags:
- chs-shared
stages:
- build-package
- 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"
R_LIBS_USER: "$CI_PROJECT_DIR/ci/lib"
APT_CACHE: "$CI_PROJECT_DIR/ci/lib/apt-cache"
CRAN: "https://rpkg.chs.usgs.gov/prod-cran/latest"
R_LIBS: "$CI_PROJECT_DIR/ci/lib"
BUILD_LOGS_DIR: "$CI_PROJECT_DIR/ci/logs"
NOT_CRAN: "true"
PAGES_OUTDIR: "$CI_PROJECT_DIR/public"
CUSTOM_DR_UA: "GitLab_CI"
API_USGS_PAT: "${API_USGS_PAT}"
build-package:
stage: build-package
image: ${CI_REGISTRY_IMAGE}:latest
script:
- set -euo pipefail
- R CMD build .
artifacts:
paths:
- "*.tar.gz"
expire_in: 1 day
build-image:
stage: build
cache: []
tags:
- chs-shared
- dind
image: ${DEVOPS_REGISTRY}usgs/docker:29
services:
- name: ${DEVOPS_REGISTRY}usgs/docker:29-dind
alias: docker
script:
- echo "${CI_REGISTRY_PASSWORD}" | docker login -u "${CI_REGISTRY_USER}" --password-stdin $CI_REGISTRY
- docker pull ${CI_REGISTRY_IMAGE}:latest || true
- docker build --cache-from ${CI_REGISTRY_IMAGE}:latest -t ${CI_REGISTRY_IMAGE}:latest -t ${CI_REGISTRY_IMAGE}:BUILD_${CI_COMMIT_SHORT_SHA} -f docker/Dockerfile .
# If this is building a git tag, also push 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:
image: ${CI_REGISTRY_IMAGE}:latest
stage: check
cache: []
dependencies:
- build-image
script:
- |
Rscript -e "
rcmdcheck::rcmdcheck(
args = c('--no-manual', '--no-tests'),
build_args = c('--no-manual', '--no-resave-data'),
check_dir = '.',
error_on = 'warning'
)
"
artifacts:
paths:
- "*.tar.gz"
expire_in: 1 hour
# unittests:
# stage: test
# cache: []
# image: ${CI_REGISTRY_IMAGE}:latest
# dependencies:
# - build-image
# - buildcheck
# script:
# - |
# Rscript -e '
# library(testthat)
# options(testthat.output_file = file.path(Sys.getenv("CI_PROJECT_DIR"), "test-out.xml"))
# test_local(reporter = "junit")'
# - |
# Rscript -e '
# x <- covr::package_coverage()
# covr::to_cobertura(x)
# x'
# artifacts:
# when: always
# expire_in: 1 hour
# paths:
# - test-out.xml
# reports:
# junit: test-out.xml
# coverage_report:
# coverage_format: cobertura
# path: cobertura.xml
# coverage: '/Coverage: \d+.\d+\%/'
longtest:
stage: test
image: ${CI_REGISTRY_IMAGE}:latest
dependencies:
- build-image
- buildcheck
script:
- |
Rscript -e '
testthat::test_local(path = "tests/manual")'
rules:
- if: $RUN_LONG_TESTS == "FALSE"
when: always
- when: never
artifacts:
expire_in: 5 minutes
pages:
image: ${CI_REGISTRY_IMAGE}:latest
stage: end
dependencies:
- build-image
- buildcheck
variables:
RETICULATE_PYTHON: /usr/bin/python3
script:
- |
Rscript -e '
pkgdown::build_site(override = list(destination = "public"))
file.copy(from = "./public/articles/logo.png", to = "./public/reference/logo.png")'
- quarto render
artifacts:
paths:
- $PAGES_OUTDIR
expire_in: 1 hour
Validate Inventory:
stage: end
only:
- main
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
artifacts:
expire_in: 5 minutes