-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
279 lines (266 loc) · 7.19 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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
stages:
- setup
- initialize
- test
- analysis
- document
- deploy
# Set any variables we need
variables:
LGGR_IMAGE: $CI_REGISTRY/kgroup/lggr:74
MYSQL_DATABASE: $MYSQL_DB
MYSQL_ROOT_PASSWORD: $MYSQL_PASS
DOCKER_AUTH_CONFIG: '{ "auths": { "https://index.docker.io/v1/": { "auth": "$DOCKER_AUTH" } }}'
SELENIUM_URL: $SELENIUM_URL
websetup:
stage: setup
tags:
- docker
image: $LGGR_IMAGE
rules:
- if: '$DODOCKER != "yes"'
script:
- composer --no-interaction --quiet install
- composer npm-install
- php -i|grep PDO
# link our project stuff
- rm .htaccess
- cd /var/www; mv html html_orig; ln -s /builds/kgroup/lggr html; ls -l
artifacts:
name: "web"
paths:
- vendor/
- node_modules/
- inc/
- composer.lock
dbsetup:
stage: initialize
tags:
- docker
image: $LGGR_IMAGE
rules:
- if: '$DODOCKER != "yes"'
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/mariadb:10.1
alias: mysql
- ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/redis:latest
script:
- sleep 60
- echo Did wait for services
- cat setup/1_db.sql | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql
- cat setup/2_auth.sql | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
- cat setup/3_user.sql | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql
- php admin/db_prefill.php
- mysqldump --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql --opt "$MYSQL_DATABASE" >dump.sql
dependencies:
- websetup
artifacts:
name: "database"
paths:
- dump.sql
dodocker:
stage: initialize
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:20.10.17
rules:
- if: '$DODOCKER == "yes"'
parallel:
matrix:
- D: ['74', '81', 'mkdocs', 'doxygen']
variables:
DOCKER_TLS_CERTDIR: "/certs"
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/docker:20-dind
alias: docker
tags:
- docker
before_script:
- mkdir -p $HOME/.docker
- echo $DOCKER_AUTH_CONFIG > $HOME/.docker/config.json
script:
- docker build -t registry.kretschmann.software/kgroup/lggr:$D . -f Dockerfile_$D
- docker push registry.kretschmann.software/kgroup/lggr:$D
unittest:
stage: test
tags:
- docker
image: $LGGR_IMAGE
rules:
- if: '$DODOCKER != "yes"'
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/mariadb:10.1
alias: mysql
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/redis:latest
alias: redis
before_script:
- ls -l dump.sql composer.lock
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" <dump.sql
- cat setup/3_user.sql | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql
script:
- composer test
after_script:
- php tests/x2j.php >logs/junit.json
dependencies:
- websetup
- dbsetup
artifacts:
name: "test"
paths:
- logs/junit.xml
- logs/coverage.xml
- logs/junit.json
- pub_phpunit
expire_in: 1 month
reports:
junit: logs/junit.xml
# cobertura: logs/coverage.xml
webtest:
stage: test
tags:
- docker
image: $LGGR_IMAGE
rules:
- if: '$DODOCKER != "yes"'
services:
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/mariadb:10.1
alias: mysql
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/selenium/standalone-chrome
alias: selenium
- name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/redis:latest
alias: redis
before_script:
- ls -l dump.sql composer.lock
- mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE" <dump.sql
- cat setup/3_user.sql | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql
- rm .htaccess
- cd /var/www; mv html html_orig; ln -s /builds/kgroup/lggr html; ls -l
- /etc/init.d/apache2 start
script:
- cd /builds/kgroup/lggr
- WEBIP=`hostname -i` composer webtest
allow_failure: true
dependencies:
- websetup
- dbsetup
artifacts:
paths:
- logs/webtest_junit.xml
reports:
junit: logs/webtest_junit.xml
doctest:
stage: test
tags:
- docker
image: $CI_REGISTRY/kgroup/lggr:mkdocs
rules:
- if: '$DODOCKER != "yes" && $CI_COMMIT_BRANCH == "master"'
before_script:
- mkdir test
script:
- mkdocs build --strict --verbose --site-dir test
artifacts:
paths:
- test
bom:
stage: analysis
tags:
- docker
variables:
DTRACK_URL: ${DTRACK_URL}
DTRACK_API: ${DTRACK_API}
DTRACK_NAME: "lggr"
image: $LGGR_IMAGE
rules:
- if: '$DODOCKER != "yes"'
script:
- composer CycloneDX:make-sbom
after_script:
- 'export DTRACK_VERSION=$(cut -d ":" -f 6 <VERSION.cpe)'
- echo "projectName=${DTRACK_NAME}"
- echo "projectVersion=${DTRACK_VERSION}"
- 'curl -X POST ${DTRACK_URL}api/v1/bom -H "Content-Type: multipart/form-data" -H "X-API-Key: ${DTRACK_API}" -F "autoCreate=true" -F "projectName=${DTRACK_NAME}" -F "projectVersion=${DTRACK_VERSION}" -F [email protected]'
allow_failure: false
artifacts:
paths:
- bom.xml
sonarqube:
stage: analysis
tags:
- docker
image:
name: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
rules:
- if: '$DODOCKER != "yes"'
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar"
before_script:
- git fetch --unshallow
script:
- sonar-scanner -Dsonar.qualitygate.wait=true -Dsonar.branch.name=${CI_COMMIT_REF_SLUG}
allow_failure: true
makedocs:
stage: document
tags:
- docker
image: $CI_REGISTRY/kgroup/lggr:mkdocs
rules:
- if: '$DODOCKER != "yes"'
before_script:
- mkdir pub_mkdocs
script:
- mkdocs build
artifacts:
paths:
- pub_mkdocs
doxygen:
stage: document
tags:
- docker
image: $CI_REGISTRY/kgroup/lggr:doxygen
rules:
- if: '$DODOCKER != "yes"'
before_script:
- mkdir -p pub_doxygen
script:
- doxygen Doxyfile
artifacts:
paths:
- pub_doxygen
pages:
stage: deploy
tags:
- docker
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/alpine:latest
rules:
- if: '$DODOCKER != "yes"'
before_script:
- mkdir public
script:
- cp -a pub_mkdocs/* public/
- cp -a pub_doxygen/html/* public/doxygen/
- cp -a pub_phpunit/* public/phpunit/
artifacts:
paths:
- public
deploy:
stage: deploy
tags:
- docker
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/curlimages/curl:latest
rules:
- if: '$DODOCKER != "yes"'
variables:
URL: "$CI_SERVER_PROTOCOL://$CI_SERVER_HOST:$CI_SERVER_PORT/api/v4/projects/$CI_PROJECT_ID/packages/composer?job_token=$CI_JOB_TOKEN"
script:
- version=$([[ -z "$CI_COMMIT_TAG" ]] && echo "branch=$CI_COMMIT_REF_NAME" || echo "tag=$CI_COMMIT_TAG")
- insecure=$([ "$CI_SERVER_PROTOCOL" = "http" ] && echo "--insecure" || echo "")
- response=$(curl -s -w "\n%{http_code}" $insecure --data $version $URL)
- code=$(echo "$response" | tail -n 1)
- body=$(echo "$response" | head -n 1)
# Output state information
- if [ $code -eq 201 ]; then
echo "Package created - Code $code - $body";
else
echo "Could not create package - Code $code - $body";
exit 1;
fi