-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
182 lines (167 loc) · 3.93 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
image: python:3.10
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
runStages: prepare lint test dependency-check sonarqube-check
cache:
paths:
- .cache/pip
key: pip
before_script:
- python -V
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- test -n "$SKIP_PIP_INSTALL" || find .wheels -name '*.whl' -print0 | xargs -0 --no-run-if-empty pip --require-virtualenv install
- test -n "$SKIP_PIP_INSTALL" || pip --require-virtualenv install -r requirements_dev.txt
stages:
- prepare
- lint
- test
- docs
- dependency-check
- sonarqube-check
build-ldap:
stage: prepare
variables:
SKIP_PIP_INSTALL: "yes"
script:
- apt update && apt install -y libldap-dev python3-dev libsasl2-dev
- pip install python-ldap
- mkdir .wheels
- find .cache/pip -name 'python_ldap*.whl' -print0 | xargs -0 -i cp -v "{}" .wheels/
artifacts:
expire_in: 2 days
paths:
- .wheels
rules:
- if: $runStages =~ /(prepare|test|lint|sonarqube-check)/
when: always
test:
script:
- printf "[run]\nconcurrency = multiprocessing" > .coveragerc
- coverage run ./manage.py test --parallel
- coverage combine
- coverage xml
artifacts:
expire_in: 2 days
paths:
- coverage.xml
rules:
- if: $runStages =~ /(test|sonarqube-check)/
when: always
migrations-check:
stage: test
script:
- ./manage.py makemigrations --no-input --check -v0 ||
( RET=$?; echo "makemigrations failed with code $?, dry-run follows:" 1>&2;
./manage.py makemigrations --no-input --dry-run; exit $RET )
rules:
- if: $runStages =~ /test/
when: always
black:
stage: lint
script:
- black . --check
rules:
- if: $runStages =~ /lint/
when: always
flake8:
stage: lint
script:
- flake8
rules:
- if: $runStages =~ /lint/
when: always
isort:
stage: lint
script:
- isort . --check
rules:
- if: $runStages =~ /lint/
when: always
mypy:
stage: lint
script:
- mypy .
rules:
- if: $runStages =~ /lint/
when: always
sonarqube-check:
stage: sonarqube-check
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
GIT_DEPTH: "0"
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
before_script:
- ''
script:
- >
sonar-scanner
-Dsonar.qualitygate.wait=true
-Dsonar.host.url=${CI_SONAR_HOST}
-Dsonar.token=${CI_SONAR_TOKEN}
-Dsonar.dependencyCheck.jsonReportPath=dependency-check-report.json
-Dsonar.dependencyCheck.htmlReportPath=dependency-check-report.html
-Dsonar.dependencyCheck.severity.high=7.0
-Dsonar.dependencyCheck.severity.medium=4.0
-Dsonar.dependencyCheck.severity.low=0.0
allow_failure: true
needs:
- job: test
artifacts: true
- job: dependency-check
artifacts: true
rules:
- if: $runStages =~ /sonarqube-check/
when: always
dependency-check:
stage: dependency-check
image:
name: owasp/dependency-check-action:latest
entrypoint: [""]
before_script:
- apt update && apt install -y python3
script:
- >
/usr/share/dependency-check/bin/dependency-check.sh
--project Kamu --scan . --enableExperimental
--format HTML --format JSON
allow_failure: true
artifacts:
when: always
expire_in: 1 week
paths:
- dependency-check-report.html
- dependency-check-report.json
needs: []
rules:
- if: $runStages =~ /(dependency-check|sonarqube-check)/
when: always
pages:
stage: docs
script:
- make -C docs html
- mv docs/_build/html public
artifacts:
expire_in: 1 week
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == "main"
pages-test:
stage: docs
script:
- make -C docs html
- mv docs/_build/html test
artifacts:
expire_in: 1 week
paths:
- test
rules:
- if: $CI_COMMIT_BRANCH != "main"