-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
254 lines (237 loc) · 6.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
stages:
- build
- test
- release
.php_template: &php_template
image: registry.gitlab.com/eternaltwin/mush/mush/api:latest
cache:
paths:
- "Api/vendor/"
- "Api/.php-cs-fixer.cache"
- "Api/.psalm/"
before_script:
- php -v
- cd Api
# Install all project dependencies
- composer install --ignore-platform-req=ext-protobuf
- cp .env.gitlab .env
.php_with_db_template: &php_with_db_template
extends: .php_template
services:
- postgres:16.3-alpine
variables:
POSTGRES_DB: emush_test
POSTGRES_USER: runner
POSTGRES_PASSWORD: "password"
before_script:
- php -v
- cd Api
# Install all project dependencies
- composer install --ignore-platform-req=ext-protobuf
- cp .env.gitlab .env.test
- cp .env.gitlab .env
- bin/console doctrine:schema:update --complete -f
- bin/console doctrine:fixtures:load -n --env=test
- openssl genpkey -out config/jwt/private.pem -aes256 -algorithm rsa -pkeyopt rsa_keygen_bits:4096 -pass pass:mush
- openssl pkey -in config/jwt/private.pem -out config/jwt/public.pem -pubout -passin pass:mush
- chmod go+r config/jwt/private.pem
.node_template: &node_template
image: node:20-slim
cache:
paths:
- node_modules/
before_script:
- cd App
- yarn install
# dummy job to check if the pipeline is valid or if there is no job to run
check:
stage: build
image: alpine:latest
script:
- echo "Pipeline is valid"
build-front:
stage: build
needs:
- job: check
optional: true
<<: *node_template
script:
- yarn build
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["App/**/*.vue", "App/**/*.ts", "App/**/*.scss", "App/**/*.css"]
- if: '$CI_COMMIT_BRANCH == "develop"'
api-test-1:
<<: *php_with_db_template
stage: test
tags:
- saas-linux-large-amd64
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- php vendor/bin/codecept run --shard 1/5
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["Api/**/*.php", "Api/**/*.xlf"]
api-test-2:
<<: *php_with_db_template
stage: test
tags:
- saas-linux-large-amd64
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- php vendor/bin/codecept run --shard 2/5
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["Api/**/*.php", "Api/**/*.xlf"]
api-test-3:
<<: *php_with_db_template
stage: test
tags:
- saas-linux-large-amd64
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- php vendor/bin/codecept run --shard 3/5
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["Api/**/*.php", "Api/**/*.xlf"]
api-test-4:
<<: *php_with_db_template
stage: test
tags:
- saas-linux-large-amd64
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- php vendor/bin/codecept run --shard 4/5
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["Api/**/*.php", "Api/**/*.xlf"]
api-test-5:
<<: *php_with_db_template
stage: test
tags:
- saas-linux-large-amd64
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- php vendor/bin/codecept run --shard 5/5
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["Api/**/*.php", "Api/**/*.xlf"]
api-lint:
<<: *php_template
stage: test
tags:
- saas-linux-large-amd64
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- sh linters.sh
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["Api/**/*.php"]
translations-lint:
<<: *php_template
stage: test
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- php bin/console lint:xliff translations
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["Api/**/*.xlf"]
api-test-develop:
<<: *php_with_db_template
stage: test
tags:
- saas-linux-large-amd64
needs:
- job: check
optional: true
- job: build-front
script:
- pecl install pcov && docker-php-ext-enable pcov
- php -dpcov.enabled=1 -dpcov.directory=src vendor/bin/codecept run --xml --html --coverage --coverage-html --no-colors
coverage: '/^\s+Lines:\s+(\d+\.\d+)%/'
artifacts:
when: always
expire_in: 1 week
paths:
- Api/tests/_output
# make the report available in Gitlab UI. see https://docs.gitlab.com/ee/ci/unit_test_reports.html
reports:
junit: Api/tests/_output/report.xml
only:
- develop
front-lint:
<<: *node_template
stage: test
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- yarn lint --no-fix
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["App/**/*.vue", "App/**/*.ts", "App/**/*.scss", "App/**/*.css"]
front-test:
<<: *node_template
stage: test
needs:
- job: check
optional: true
- job: build-front
optional: true
script:
- yarn test-ci
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
changes: ["App/**/*.vue", "App/**/*.ts", "App/**/*.scss", "App/**/*.css"]
- if: '$CI_COMMIT_BRANCH == "develop"'
# Generate a CHANGELOG.md file and create a new release on GitLab while merging to master
release:
image: node:lts
stage: release
before_script:
- npm install -g semantic-release @semantic-release/commit-analyzer @semantic-release/changelog @semantic-release/release-notes-generator @semantic-release/gitlab
variables:
GIT_AUTHOR_NAME: AI-NERON
GIT_AUTHOR_EMAIL: $NERON_EMAIL
GIT_COMMITTER_NAME: AI-NERON
GIT_COMMITTER_EMAIL: $NERON_EMAIL
GITLAB_TOKEN: $semantic_release_token
version: '${version}'
artifacts:
expire_in: 1 week
paths:
- CHANGELOG.md
script:
- semantic-release --branches master -t $version -p @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/release-notes-generator @semantic-release/gitlab
only:
- master