-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
191 lines (174 loc) · 4.66 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
190
191
workflow:
name: $azul_gitlab_pipeline_name
rules:
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH
variables:
azul_gitlab_pipeline_name: $CI_COMMIT_TITLE
- if: $CI_PIPELINE_SOURCE == 'schedule'
variables:
azul_gitlab_pipeline_name: Scheduled $azul_gitlab_schedule
variables:
azul_image: $CI_REGISTRY_IMAGE
azul_image_tag: $CI_PIPELINE_ID
stages:
- build_image
- setup
- test
- deploy
- early_reindex
- integration_test
- teardown
- reindex
- schedule
.on_push:
rules:
- if: $CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH
build_image:
# Build an image containing the build prerequisites (python, terraform, etc).
# This lets us exploit Docker's layer caching to speed up the build. The
# image will only be rebuilt after changes to the Dockerfile,
# requirements*.txt, common.mk and the Makefile.
extends: .on_push
stage: build_image
timeout: 6m
rules:
- if: $CI_COMMIT_BRANCH
script:
- >
printenv CI_REGISTRY_PASSWORD
| docker login --username $CI_REGISTRY_USER --password-stdin $CI_REGISTRY_IMAGE
- set -o allexport ; source environment.boot ; set +o allexport
# FIXME: Remove azul_proc_sys_crypto
# https://github.com/DataBiosphere/azul/issues/6675
- azul_proc_sys_crypto=/proc/sys/crypto make docker_dev_push
.base:
dependencies:
- build_image
image: ${azul_image}/dev:${azul_image_tag}
before_script:
- cp -vR /etc/gitlab/azul/* . # Copy files like environment.local into the build directory.
- source /build/.venv/bin/activate
- pip list
- source environment # load global defaults
- deployment=$(PYTHONPATH=src python scripts/check_branch.py --print)
- _link $deployment
- _refresh
- status_context="gitlab/${azul_gitlab_instance_name}/${AZUL_DEPLOYMENT_STAGE}"
- make clean
.base_on_push:
extends:
- .on_push
- .base
setup:
extends: .base_on_push
stage: setup
timeout: 30s
script:
- python scripts/github_status_check.py "${status_context}" pending
test:
extends: .base_on_push
stage: test
timeout: 1h 30m
script:
- make format
# FIXME: Remove azul_proc_sys_crypto
# https://github.com/DataBiosphere/azul/issues/6675
- >
python -m azul -t config.deployment.is_lower_sandbox
&& azul_proc_sys_crypto=/proc/sys/crypto make requirements_update
- make -C lambdas openapi
- make environment.boot
- make -C .github
- make anvil_schema
- make check_clean
- make pep8
- AZUL_DEBUG=0 make test
deploy:
extends: .base_on_push
stage: deploy
timeout: 45m
script:
- make auto_deploy
- make create
artifacts:
paths:
- terraform/plan.json
deploy_browser:
extends: .base_on_push
stage: deploy
timeout: 20m # initial deploys can take a while
needs:
- build_image
- deploy
script:
- test -e deployments/$deployment.browser || exit 0
- _link $deployment.browser
- _refresh
- cd terraform/browser
- make auto_apply
artifacts:
paths:
- terraform/browser/plan.json
integration_test:
# FIXME: Use a dynamic GitLab job timeout based on deployment
# https://github.com/DataBiosphere/azul/issues/5404
extends: .base_on_push
stage: integration_test
timeout: 2h
script:
- make integration_test
on_success:
extends: .base_on_push
stage: teardown
when: on_success
timeout: 30s
script:
- python scripts/github_status_check.py "${status_context}" success
on_failure:
extends: .base_on_push
stage: teardown
when: on_failure
timeout: 30s
script:
- python scripts/github_status_check.py "${status_context}" failure
early_reindex:
# FIXME: Use a dynamic GitLab job timeout based on deployment
# https://github.com/DataBiosphere/azul/issues/5404
extends: .base_on_push
stage: early_reindex
when: manual
timeout: 4d
script:
- make reindex
reindex:
# FIXME: Use a dynamic GitLab job timeout based on deployment
# https://github.com/DataBiosphere/azul/issues/5404
extends: .base_on_push
stage: reindex
when: manual
timeout: 4d
script:
- make reindex
sell_unused_slots:
extends: .base
stage: schedule
timeout: 30s
rules:
- if: $CI_PIPELINE_SOURCE == 'schedule'
&& $azul_gitlab_schedule == 'sell_unused_slots'
script:
- python3 scripts/sell_unused_slots.py
fedramp_inventory:
extends: .base
stage: schedule
timeout: 5m
rules:
- if: $CI_PIPELINE_SOURCE == 'schedule'
&& $azul_gitlab_schedule == 'fedramp_inventory'
script:
- python3 scripts/compliance/fedramp_inventory.py fedramp_inventory.xlsx
artifacts:
paths:
- fedramp_inventory.xlsx
expire_in:
1 year