This repository has been archived by the owner on Oct 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
.gitlab-ci.yml
189 lines (167 loc) · 5.37 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
image: docker
services:
- docker:dind
stages:
- build
- test
- build-images
- analysis
- deploy
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- /dbas/dbas/static/node_modules
- /root/.cache/Cypress/
.add-services:
services:
- name: $CI_REGISTRY/cn-tsn/project/dbas/dbas/db:testing
alias: db
image: $CI_REGISTRY/cn-tsn/project/dbas/dbas:experimental
variables:
AUTHN_SECRET: 89#s3cr3t_15
DB_HOST: db
DB_PORT: 5432
DB_USER: postgres
DB_PW: DXxCNtfnt!MOo!f8LY1!P%sw3KGzt@s!
POSTGRES_PASSWORD: DXxCNtfnt!MOo!f8LY1!P%sw3KGzt@s!
URL: https://dbas.cs.uni-duesseldorf.de
KEY_PATH: devkey.pem
PUBKEY_PATH: devpublic.pem
before_script:
- alembic upgrade head && pserve development.ini --reload &
# ------------------------------------------------------------------------------
# Job definitions
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID # Execute jobs in merge request context
- if: $CI_COMMIT_BRANCH # Execute jobs when a new commit is pushed to a branch
build_test_image:
stage: build
tags:
- ht
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:experimental --cache-from $CI_REGISTRY_IMAGE:experimental --pull .
- docker push $CI_REGISTRY_IMAGE:experimental
build_test_db_image:
stage: build
tags:
- ht
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE/db:testing --cache-from $CI_REGISTRY_IMAGE/db:testing --pull docker/db
- docker push $CI_REGISTRY_IMAGE/db:testing
flake8:
stage: test
script:
- apk add --no-cache python3 && python3 -m ensurepip
- pip3 install --quiet flake8
- pip3 show flake8
- flake8 .
allow_failure: true
when: always
jshint:
stage: test
script:
- apk add --no-cache yarn bash
- yarn global add jshint
- bash -c "jshint ./dbas/static/js/{main,ajax,discussion,review,d3}/*.js"
- bash -c "jshint ./admin/static/js/main/*.js"
- bash -c "jshint ./websocket/static/js/*.js"
allow_failure: true
unit:
extends: .add-services
stage: test
script:
- nosetests --with-coverage --cover-package=dbas --cover-package=graph --cover-package=admin --cover-package=api --cover-xml -w . api dbas graph admin
coverage: '/^TOTAL\s*\d+\s*\d+\s*(\d+\%)\s*$/'
artifacts:
paths:
- coverage.xml
expire_in: 1 hrs
cypress:
extends: .add-services
stage: test
tags:
- ht
before_script:
- make dev-server &
- sed -i 's/deb.debian.org/mirror.cs.uni-duesseldorf.de/g' /etc/apt/sources.list
- sed -i 's/security.debian.org/mirror.cs.uni-duesseldorf.de/g' /etc/apt/sources.list
- apt update
- apt -yqq install libgtk2.0-0 libgtk-3-0 libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb
- yarn install --dev
- cd frontendtest
script:
- ../dbas/static/node_modules/.bin/cypress run --env WEB_HOST=localhost
artifacts:
paths:
- frontendtest/cypress/
expire_in: 1 day
when: on_failure
include:
- template: SAST.gitlab-ci.yml
sast:
stage: analysis
rules:
- if: $CI_COMMIT_BRANCH == "development"
allow_failure: true
# -----------------------------------------------------------------------------
build_production_image:
stage: build-images
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE --cache-from $CI_REGISTRY_IMAGE .
- docker push $CI_REGISTRY_IMAGE
# Build production docs for live version
- docker build -t $CI_REGISTRY_IMAGE/docs --cache-from $CI_REGISTRY_IMAGE/docs -f Dockerfile.docs --pull .
- docker push $CI_REGISTRY_IMAGE/docs
only:
- master
build_production_db_image:
stage: build-images
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE/db --cache-from $CI_REGISTRY_IMAGE/db --pull docker/db
- docker push $CI_REGISTRY_IMAGE/db
only:
- master
# -----------------------------------------------------------------------------
build_dev_image:
stage: build-images
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE:development --cache-from $CI_REGISTRY_IMAGE:development .
- docker push $CI_REGISTRY_IMAGE:development
# Build docs image for development
- docker build -t $CI_REGISTRY_IMAGE/docs:development --cache-from $CI_REGISTRY_IMAGE/docs:development -f Dockerfile.docs --pull .
- docker push $CI_REGISTRY_IMAGE/docs:development
only:
- development
build_db_dev_image:
stage: build-images
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build -t $CI_REGISTRY_IMAGE/db:development --cache-from $CI_REGISTRY_IMAGE/db:development --pull docker/db
- docker push $CI_REGISTRY_IMAGE/db:development
only:
- development
# -----------------------------------------------------------------------------
deploy_production:
image: alpine
stage: deploy
environment: production
dependencies: []
tags:
- cn
before_script:
- apk add --no-cache openssh
- eval "$(ssh-agent -s)"
- mkdir -p ~/.ssh
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- chmod 700 ~/.ssh/
- ssh-keyscan -H 'discovery.cs.hhu.de' > ~/.ssh/known_hosts
script:
- ssh root@discovery.cs.hhu.de
only:
- master