forked from ekylibre/ekylibre
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
235 lines (223 loc) · 6.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
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
stages:
- lint
- build
- test
# - review
- build_version
- doc
- deploy
variables:
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: ""
TEST_IMAGE: ${CI_REGISTRY_IMAGE}/test:$CI_COMMIT_REF_SLUG
PROD_LATEST: ${CI_REGISTRY_IMAGE}/ekylibre:latest
REVIEW_HOST: ${CI_COMMIT_REF_SLUG}.ci.ekylibre.dev
KUBE_NAMESPACE: eky-test-deploy
# PROD_RAILS: ${CI_REGISTRY_IMAGE}/ekylibre-rails:$CI_COMMIT_REF_SLUG
# PROD_RAILS_LATEST: ${CI_REGISTRY_IMAGE}/ekylibre-rails:latest
# PROD_WEB: ${CI_REGISTRY_IMAGE}/ekylibre-web:$CI_COMMIT_REF_SLUG
# PROD_WEB_LATEST: ${CI_REGISTRY_IMAGE}/ekylibre-web:latest
#########################################
# BUILD #
#########################################
build_test:
image: registry.gitlab.com/ekylibre/docker-base-images/tools/deploy:1.5
stage: build
except:
- tags
services:
- docker:19.03-dind
before_script:
- echo "${CI_JOB_TOKEN}" | docker login --username $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
script:
- /exec ruby /build.rb -v -r $CI_COMMIT_REF_SLUG -b $CI_REGISTRY_IMAGE -f docker/test/Dockerfile -i test
build_version:
image: registry.gitlab.com/ekylibre/docker-base-images/tools/deploy:1
stage: build_version
only:
- tags
services:
- docker:19.03-dind
before_script:
- echo "${CI_BUILD_TOKEN}" | docker login --username $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
script:
- /exec ruby /build.rb -v -b $CI_REGISTRY_IMAGE -f docker/prod/Dockerfile -i ekylibre -r latest #-r $CI_COMMIT_TAG
#build_ci:
# image: registry.gitlab.com/ekylibre/docker-base-images/tools/deploy:1
# stage: build
# when: manual
# only:
# - branches
# variables:
# RUBY_VERSION: "2.3"
# services:
# - docker:18-dind
# before_script:
# - apk add openssh-client
# - /install-ssh-key $PLUGIN_SSH_KEY
# - echo "${CI_JOB_TOKEN}" | docker login --username $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
# script:
# - for plugin in $EKYLIBRE_PLUGINS; do echo "[email protected]:ekylibre/ekylibre-${plugin}.git" && git clone "[email protected]:ekylibre/ekylibre-${plugin}.git" "plugins/${plugin}"; done
# - /exec ruby /build.rb -v -r $CI_COMMIT_REF_SLUG -b $CI_REGISTRY_IMAGE -f docker/prod/Dockerfile -i ci-rails-aio-2.3
#
#
#.review_key: &REVIEW_KEY
# name: review/eky/$CI_COMMIT_REF_NAME
#
#.review_branches: &REVIEW_BRANCHES
# only:
# - branches
# except:
# - prod
# - core
#
#.default_review: &DEFAULT_REVIEW
# <<: *REVIEW_BRANCHES
# environment:
# <<: *REVIEW_KEY
# url: https://$REVIEW_HOST
# on_stop: review_stop
#
#review_start:
# <<: *DEFAULT_REVIEW
# stage: review
# dependencies:
# - build_ci
# image: registry.gitlab.com/ekylibre/helm-charts/ci-tool:master
# variables:
# GIT_STRATEGY: none
# script:
# - (cd /apps/eky-ci && helm dep update)
# - helm tiller run "$KUBE_NAMESPACE" -- helm upgrade
# --install
# --namespace "$KUBE_NAMESPACE"
# --set eky.image.tag=$CI_COMMIT_REF_SLUG
# --set eky.postgres.database=$CI_COMMIT_REF_SLUG
# --set eky.ingress.domain=${REVIEW_HOST}
# --set eky.rails.init.tenants[0]=demo1
# --set eky.rails.load.tenants[0]=demo
# --set eky.rails.load.lexicon=true
# ci-eky-${CI_COMMIT_REF_SLUG} /apps/eky-ci
# when: manual
#
#review_stop:
# <<: *REVIEW_BRANCHES
# environment:
# <<: *REVIEW_KEY
# action: stop
# stage: review
# image: registry.gitlab.com/ekylibre/docker-base-images/tools/deploy:1
# variables:
# GIT_STRATEGY: none
# script:
# - helm tiller run "$KUBE_NAMESPACE" -- helm delete --purge ci-eky-${CI_COMMIT_REF_SLUG}
# when: manual
doc_build:
image: registry.gitlab.com/ekylibre/docker-base-images/tools/deploy:1
stage: doc
only:
- tags
dependencies:
- build_test
services:
- docker:19.03-dind
before_script:
- echo "${CI_JOB_TOKEN}" | docker login --username $CI_REGISTRY_USER $CI_REGISTRY --password-stdin
script:
- /exec ruby /build.rb -v -a TEST_IMAGE -r $CI_COMMIT_REF_SLUG -b $CI_REGISTRY_IMAGE -f docker/doc/Dockerfile -i doc
deploy_doc:
image: registry.gitlab.com/ekylibre/helm-charts/ci-tool:master
stage: deploy
only:
- tags
when: manual
variables:
GIT_STRATEGY: none
KUBE_DOC_NAMESPACE: ekylibre-doc
script:
- helm --kube-context ekylibre-doc tiller run "$KUBE_DOC_NAMESPACE" --
helm upgrade
--install
--namespace "$KUBE_DOC_NAMESPACE"
--set doc.component=ekylibre
--set doc.version=latest
--set image.repository=registry.gitlab.com/ekylibre/eky/doc
--set image.tag=${CI_COMMIT_REF_SLUG}
ekylibre-latest
/apps/doc
#########################################
# LINT #
#########################################
rubocop:
stage: lint
image: registry.gitlab.com/ekylibre/tools/rubocop/rubocop:0.2.0
variables:
GIT_DEPTH: 1
script:
- rubocop --parallel
eslint:
stage: lint
image: node:14-alpine
variables:
GIT_DEPTH: 1
script:
- apk add git
- yarn
- yarn eslint .
hamllint:
stage: lint
image: ruby:2.6-buster
script:
- rm Gemfile
- bundle init
- echo "gem 'haml_lint', '0.40.1'" >> Gemfile
- echo "gem 'rubocop', '~> 1.11.0'" >> Gemfile
- bundle install
- haml-lint -c .haml-lint.yml
#########################################
# TEMPLATES #
#########################################
test:
stage: test
image: $TEST_IMAGE
variables:
REDIS_URL: redis://redis:6379/
DB_HOST: postgres
DB_USERNAME: ekylibre
DB_TEST_NAME: ekylibre_test
POSTGRES_HOST: postgres
POSTGRES_USER: ekylibre
POSTGRES_DB: ekylibre_test
TZ: Europe/Paris
GIT_STRATEGY: none
services:
# TODO switch to postgis/postgis:13-3.1-alpine when ready
- name: mdillon/postgis:9.6-alpine
alias: postgres
- name: redis:5.0-alpine
alias: redis
except:
- tags
script:
- bash /app/test/ci/run_tests "$ENV"
after_script:
- mv /app/coverage/ ./coverage/
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: coverage/coverage.xml
coverage: '/\(\d+.\d+\%\) covered/'
#########################################
# TESTS #
#########################################
#test_fast:
# <<: *test_task
# variables:
# <<: *test_task_variables
# SELECT: lower
#test_long:
# <<: *test_task
# variables:
# <<: *test_task_variables
# SELECT: higher