-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
230 lines (188 loc) · 5.47 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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
# SPDX-FileCopyrightText: 2019-2020 Magenta ApS
# SPDX-License-Identifier: MPL-2.0
################################################################################
# Changes to this file requires approval from Labs. Please add a person from #
# Labs as required approval to your MR if you have any changes. #
################################################################################
# For pushing of release images to work, the following environment variables have
# to set in the Gitlab UI.
# RELEASE_REGISTRY_USER
# RELEASE_REGISTRY_PASSWORD
#
stages:
- sync
- lint
- build
- test
- release
- deploy
variables:
PRECOMMIT_USE_POETRY: "true"
# Project variables
RELEASE_REGISTRY: docker.io
RELEASE_REGISTRY_IMAGE: index.docker.io/magentaaps/dipex
IMAGE_SHA: ${CI_REGISTRY_IMAGE}:${CI_COMMIT_SHA}
IMAGE_DEV: ${RELEASE_REGISTRY_IMAGE}:dev
IMAGE_RC: ${RELEASE_REGISTRY_IMAGE}:rc
IMAGE_VERSION: ${RELEASE_REGISTRY_IMAGE}:${CI_COMMIT_TAG}
IMAGE_LATEST: ${RELEASE_REGISTRY_IMAGE}:latest
POETRY_VERSION: "1.3.1"
# Conditions
#############
.if-default-branch-refs: &if-default-branch-refs
if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
.if-tag: &if-tag
if: '$CI_COMMIT_TAG'
.if-merge-request: &if-merge-request
if: '$CI_MERGE_REQUEST_IID'
# Workflow
###########
workflow:
rules:
- <<: *if-tag
- <<: *if-default-branch-refs
- <<: *if-merge-request
include:
- project: 'labs/salt-automation'
file:
- gitlab-ci-templates/common/no-interrupt.v1.yml
- gitlab-ci-templates/common/pre-commit.v1.yml
- gitlab-ci-templates/common/conventional-commits.v1.yml
- gitlab-ci-templates/common/docker-build-meta.v2.yml
- gitlab-ci-templates/common/docker-release.v1.yml
- gitlab-ci-templates/common/rules.v1.yml
- gitlab-ci-templates/python/pypi-meta.v1.yml
- gitlab-ci-templates/common/config-updater-meta.v1.yml
- local: exporters/sql_export/.gitlab-ci.yml
.manual-rules: &manual-rules
rules:
- if: $CI_COMMIT_TAG =~ /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/
when: manual
- if: $CI_COMMIT_REF_NAME == "master"
when: manual
- when: always
# Lint stage
############
.Lint Dockerfiles:
stage: lint
needs: []
image: hadolint/hadolint:latest-debian
before_script:
- apt-get -y update
- apt-get -y install --no-install-recommends git
script:
- git ls-files --exclude='Dockerfile*' --ignored | xargs --max-lines=1 hadolint
# Build stage
#############
Build TestImage:
extends: .build-docker
variables:
DOCKERFILE: ${CI_PROJECT_DIR}/docker/Dockerfile
# Test stage
############
.test-python:
stage: test
needs: [ 'Build TestImage' ]
image:
name: ${IMAGE_SHA}
services: [ ]
variables:
GIT_STRATEGY: none # We do not need the source code
HYPOTHESIS_PROFILE: ci
before_script:
- cd /code
Test AD Integration: # runs outside image (unfortunately)
extends: .test-python
script:
- cd integrations/ad_integration/
- pytest tests/
Test CPR Mapper:
extends: .test-python
script:
- python -m doctest -v integrations/cpr_mapper.py
Test OPUS Org Tree Print:
extends: .test-python
script:
- python -m doctest -v integrations/opus/org_tree_print/main.py
Test OPUS importers:
extends: .test-python
script:
- cp settings/kommune-andeby.json settings/settings.json
- python -m pytest -v integrations/opus/tests
Test OPUS Helpers:
extends: .test-python
script:
- cp settings/kommune-andeby.json settings/settings.json
- python -m doctest -v integrations/opus/opus_helpers.py
Test AAK LOS Integration:
extends: .test-python
script:
- cd integrations/aarhus
- pip install -r ../requirements/test.txt
- pytest tests/
Test Reports:
extends: .test-python
script:
- pytest reports/os2mo_tests/ --ignore reports/os2mo_tests/test_viborg_managers.py
- pytest reports/tests/egedal
Test Exporter Utils:
extends: .test-python
script:
- pytest exporters/utils/tests/
Test tools:
extends: .test-python
script:
- python -m doctest -v tools/data_fixers/class_tools.py
- pytest tools/tests/
Test rollekatalog:
extends: .test-python
script:
- pip install -r exporters/os2rollekatalog/requirements.txt
- pytest exporters/os2rollekatalog/tests/
Test plan2learn:
extends: .test-python
script:
- cp settings/kommune-andeby.json settings/settings.json
- pytest exporters/tests/test_plan2learn_export_job.py
#TODO readd these tests once everything has been set again
#Test engagements Reports:
# extends: .test-python
# script:
# - pytest -vv reports/tests/test_reports_on_new_and_ended_engagements.py
# Release stage
###############
Release to Dev:
extends: .release-to-dev
needs: ["Release version"]
variables:
ENDPOINT: os2mo/flux/dipex/update-dev
Release to Test:
extends: .release-to-test
needs: []
variables:
ENDPOINT: os2mo/flux/dipex/update-test
Release to Prod:
extends: .release-to-prod
needs: []
variables:
ENDPOINT: os2mo/flux/dipex/update-prod
Release updates to salt Dev:
extends: .release-to-dev
needs: ["Release version"]
variables:
ENDPOINT: os2mo/salt/dipex/update-dev
Release updates to salt Test:
extends: .release-to-test
needs: []
variables:
ENDPOINT: os2mo/salt/dipex/update-test
Release updates to salt Prod:
extends: .release-to-prod
needs: []
variables:
ENDPOINT: os2mo/salt/dipex/update-prod
Release DIPEX to PyPI:
variables:
PYPI_TOKEN: ${DIPEX_PYPI_TOKEN}
extends:
- .release_to_pypi_cc