forked from RedHatProductSecurity/component-registry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
213 lines (197 loc) · 4.92 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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
stages:
- lint
- test
- build
- deploy-stage
- deploy-prod
include:
- project: 'product-security/dev/component-registry-ops'
ref: "$CORGI_OPS_BRANCH"
file: '/templates/gitlab/ansible-run.yml'
.common_ci_setup: &common_ci_setup
- export LANG=en_US.UTF-8
- cd /etc/pki/ca-trust/source/anchors/ && curl -O "${ROOT_CA_URL}"; cd -
- update-ca-trust
- export REQUESTS_CA_BUNDLE=/etc/pki/tls/certs/ca-bundle.crt
.common_test_setup: &common_test_setup
# Define below in CI settings, then export here so subprocesses can use also
# Keep in sync with OpenShift
# Internal hostnames or URLs that appear in build metadata; used in tests
- export CORGI_TEST_CACHITO_URL
- export CORGI_TEST_CODE_URL
- export CORGI_TEST_DOWNLOAD_URL
- export CORGI_TEST_OSBS_HOST1
- export CORGI_TEST_OSBS_HOST2
- export CORGI_TEST_OSBS_HOST3
- export CORGI_TEST_REGISTRY_URL
# Not used in tests directly, but needed for tests to pass
- export CORGI_LOOKASIDE_CACHE_URL
- export CORGI_APP_STREAMS_LIFE_CYCLE_URL
- export CORGI_BREW_URL
- export CORGI_BREW_DOWNLOAD_ROOT_URL
- export CORGI_ERRATA_TOOL_URL
- export CORGI_MANIFEST_HINTS_URL
- export CORGI_PRODSEC_DASHBOARD_URL
- export PIP_INDEX_URL
- export ROOT_CA_URL
build-image:
stage: build
extends:
- .ansible-build
# No "except: refs: schedules" here, daily image rebuilds
# (as part of detect-secrets daily CI job) give us any new security updates
deploy-stage:
stage: deploy-stage
extends:
- .ansible-deploy-stage
except:
refs:
- schedules
deploy-prod:
stage: deploy-prod
extends:
- .ansible-deploy-prod
except:
refs:
- schedules
test:
stage: test
# Keep in sync with Dockerfile
image: registry.redhat.io/ubi8/ubi:8.6
services:
# Keep in sync with OpenShift
- name: registry.redhat.io/rhel8/postgresql-13:1
alias: postgres
variables:
# Env vars for postgres image initialization
POSTGRESQL_ADMIN_PASSWORD: test
# Application-specific env vars
CORGI_DB_USER: postgres # default admin user
CORGI_DB_HOST: postgres # same as service alias
CORGI_DB_PASSWORD: test # same as POSTGRESQL_ADMIN_PASSWORD
before_script:
- *common_ci_setup
- *common_test_setup
script:
- dnf --disableplugin=subscription-manager --nodocs -y install python39 python39-devel gcc krb5-devel postgresql-devel
- python3.9 -m pip install tox
- tox -e corgi -- --record-mode=none --cov-report term --junitxml=junit.xml # Do not create any VCR cassettes in CI
except:
refs:
- schedules
# report coverage lines like 'TOTAL 2962 882 70%'
coverage: '/TOTAL(?:\s+\d+\s+\d+\s+)(\d+)%/'
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
junit:
- junit.xml
expire_in: 1 week
test-migrations:
stage: test
# Keep in sync with Dockerfile
image: registry.redhat.io/ubi8/ubi:8.6
services:
# Keep in sync with OpenShift
- name: registry.redhat.io/rhel8/postgresql-13:1
alias: postgres
variables:
# Env vars for postgres image initialization
POSTGRESQL_ADMIN_PASSWORD: test
# Application-specific env vars
CORGI_DB_USER: postgres # default admin user
CORGI_DB_HOST: postgres # same as service alias
CORGI_DB_PASSWORD: test # same as POSTGRESQL_ADMIN_PASSWORD
before_script:
- *common_ci_setup
- *common_test_setup
script:
- dnf --disableplugin=subscription-manager --nodocs -y install python39 python39-devel gcc krb5-devel postgresql-devel
- python3.9 -m pip install tox
- tox -e corgi-migrations
except:
refs:
- schedules
mypy:
stage: test
image: $PYTHON_TOX_IMAGE_LATEST
before_script:
- *common_ci_setup
script:
- tox -e mypy
except:
refs:
- schedules
schema:
stage: test
image: $PYTHON_TOX_IMAGE_LATEST
before_script:
- *common_ci_setup
script:
- tox -e schema
except:
refs:
- schedules
flake8:
stage: lint
image: $PYTHON_TOX_IMAGE_LATEST
before_script:
- *common_ci_setup
script:
- tox -e flake8
except:
refs:
- schedules
black:
stage: lint
image: $PYTHON_TOX_IMAGE_LATEST
before_script:
- *common_ci_setup
script:
- tox -e black
except:
refs:
- schedules
isort:
stage: lint
image: $PYTHON_TOX_IMAGE_LATEST
before_script:
- *common_ci_setup
script:
- tox -e isort
except:
refs:
- schedules
bandit:
stage: lint
image: $PYTHON_TOX_IMAGE_LATEST
before_script:
- *common_ci_setup
script:
- tox -e bandit
except:
refs:
- schedules
radon:
stage: lint
image: $PYTHON_TOX_IMAGE_LATEST
before_script:
- *common_ci_setup
script:
- tox -e radon
except:
refs:
- schedules
secrets:
stage: lint
image: $PYTHON_TOX_IMAGE_LATEST
before_script:
- *common_ci_setup
script:
- tox -e secrets
only:
refs:
- schedules