forked from schnaq/schnaq
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
213 lines (192 loc) · 6.12 KB
/
.gitlab-ci.yml
File metadata and controls
213 lines (192 loc) · 6.12 KB
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
# Fallback: Use this tag when the cs servers are down.
#default:
# tags: [ 'bi-lab' ]
stages:
- build
- test
- report
- build-docker-images
- deploy
cache:
key: one-key-to-rule-them-all
paths:
- ./.m2/repository
- ./resources/public/node_modules
variables:
BACKEND_IMAGE: $CI_REGISTRY_IMAGE/backend
FRONTEND_IMAGE: $CI_REGISTRY_IMAGE/frontend
BACKEND_IMAGE_TAGGED: $CI_REGISTRY_IMAGE/backend:$CI_PIPELINE_IID
FRONTEND_IMAGE_TAGGED: $CI_REGISTRY_IMAGE/frontend:$CI_PIPELINE_IID
.with-datomic-pro:
before_script:
- mkdir -p ~/.m2
- cp settings.xml ~/.m2/settings.xml
# ------------------------------------------------------------------------------
# Stage "test"
test:
extends: .with-datomic-pro
image: clojure:temurin-17-alpine
script:
- clojure -Sdeps '{:mvn/local-repo "./.m2/repository"}' -A:test
artifacts:
paths:
- target/coverage/lcov.info
expire_in: 1 hour
test-cljs:
extends: .with-datomic-pro
image: ghcr.io/schnaq/clojure-yarn-chrome
before_script:
- yarn install
script:
- clj -Sdeps '{:mvn/local-repo "./.m2/repository"}' -M:test-cljs
- yarn karma start --single-run
lint:
extends: .with-datomic-pro
image: clojure:temurin-17-alpine
script:
- clojure -Sdeps '{:mvn/local-repo "./.m2/repository"}' -A:clj-kondo --lint src
allow_failure: true
when: always
css-compile-and-lint:
image: ghcr.io/schnaq/clojure-yarn-chrome
before_script:
- yarn install --dev
- yarn global add sass
script:
- yarn stylelint "resources/public/css/*.scss" --config-basedir "resources/public/node_modules/"
- sass ./resources/public/css/main.scss ./resources/public/css/main.min.css --no-source-map --style compressed
when: always
up-to-date?:
extends: .with-datomic-pro
image: clojure:temurin-17-alpine
script:
- clojure -Sdeps '{:mvn/local-repo "./.m2/repository"}' -A:outdated
allow_failure: true
when: always
# ------------------------------------------------------------------------------
# Stage "report"
coverage-report:
image: python:3-alpine
stage: report
script:
- wget -O - https://s3.schnaq.com/schnaq-ci/lcov_cobertura.py | python3 - target/coverage/lcov.info --output target/coverage/coverage.xml
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: target/coverage/coverage.xml
# ------------------------------------------------------------------------------
# Stage "build-docker-images"
build-frontend-image:
extends: .with-datomic-pro
image: docker
tags:
- ht
services:
- docker:dind
stage: build-docker-images
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- >
docker build -f Dockerfile.frontend --pull
--build-arg REST_API_URL=https://api.app.schnaq.com
--build-arg BUILD_HASH=$CI_COMMIT_SHORT_SHA
--build-arg KEYCLOAK_REALM=$KEYCLOAK_REALM
--build-arg KEYCLOAK_CLIENT=$KEYCLOAK_CLIENT
--build-arg FAQ_SHARE_HASH=$FAQ_SHARE_HASH
--build-arg DATOMIC_REPO_USERNAME
--build-arg DATOMIC_REPO_PASSWORD
-t $FRONTEND_IMAGE_TAGGED .
- docker tag $FRONTEND_IMAGE_TAGGED $FRONTEND_IMAGE:latest
- docker push $FRONTEND_IMAGE_TAGGED
- docker push $FRONTEND_IMAGE:latest
only:
- deploy
build-backend-image:
extends: .with-datomic-pro
image: docker
tags:
- ht
services:
- docker:dind
stage: build-docker-images
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- >
docker build -f Dockerfile.backend --pull
--build-arg BUILD_HASH=$CI_COMMIT_SHORT_SHA
--build-arg DATOMIC_REPO_USERNAME
--build-arg DATOMIC_REPO_PASSWORD
-t $BACKEND_IMAGE_TAGGED .
- docker tag $BACKEND_IMAGE_TAGGED $BACKEND_IMAGE:latest
- docker push $BACKEND_IMAGE_TAGGED
- docker push $BACKEND_IMAGE:latest
only:
- deploy
# ------------------------------------------------------------------------------
build-frontend-staging-image:
extends: .with-datomic-pro
image: docker
tags:
- ht
services:
- docker:dind
stage: build-docker-images
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- >
docker build -f Dockerfile.frontend --pull
--build-arg REST_API_URL=https://api.app.staging.schnaq.com
--build-arg BUILD_HASH=$CI_COMMIT_SHORT_SHA
--build-arg KEYCLOAK_REALM=$KEYCLOAK_REALM_STAGING
--build-arg KEYCLOAK_CLIENT=$KEYCLOAK_CLIENT_STAGING
--build-arg DATOMIC_REPO_USERNAME
--build-arg DATOMIC_REPO_PASSWORD
--build-arg ROBOTS_TXT=./robots-staging.txt
-t ${FRONTEND_IMAGE_TAGGED}-staging .
- docker tag ${FRONTEND_IMAGE_TAGGED}-staging $FRONTEND_IMAGE:staging
- docker push ${FRONTEND_IMAGE_TAGGED}-staging
- docker push $FRONTEND_IMAGE:staging
only:
- develop
build-backend-staging-image:
extends: .with-datomic-pro
image: docker
tags:
- ht
services:
- docker:dind
stage: build-docker-images
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- >
docker build -f Dockerfile.backend --pull
--build-arg BUILD_HASH=$CI_COMMIT_SHORT_SHA
--build-arg DATOMIC_REPO_USERNAME
--build-arg DATOMIC_REPO_PASSWORD
-t ${BACKEND_IMAGE_TAGGED}-staging .
- docker tag ${BACKEND_IMAGE_TAGGED}-staging $BACKEND_IMAGE:staging
- docker push ${BACKEND_IMAGE_TAGGED}-staging
- docker push $BACKEND_IMAGE:staging
only:
- develop
# ------------------------------------------------------------------------------
# Deploy
deploy-staging:
stage: deploy
variables:
DEPLOYMENT: staging
DEPLOY_BACKEND_IMAGE: $CI_REGISTRY_IMAGE/backend:$CI_PIPELINE_IID-staging # here, we cannot use the constructed vars from above, because than var expansion fails.
DEPLOY_FRONTEND_IMAGE: $CI_REGISTRY_IMAGE/frontend:$CI_PIPELINE_IID-staging
trigger: dialogo/deployments/schnaq
only:
- develop
deploy-production:
stage: deploy
variables:
DEPLOYMENT: app
DEPLOY_BACKEND_IMAGE: $CI_REGISTRY_IMAGE/backend:$CI_PIPELINE_IID
DEPLOY_FRONTEND_IMAGE: $CI_REGISTRY_IMAGE/frontend:$CI_PIPELINE_IID
trigger: dialogo/deployments/schnaq
only:
- deploy