-
Notifications
You must be signed in to change notification settings - Fork 183
/
.gitlab-ci.yml
370 lines (347 loc) · 8.45 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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
# GitLab CI configuration - https://docs.gitlab.com/ce/ci/yaml/README.html
# Example for a Puppet deployment workflow with Feature branches making
# MR directly to production. (can be skipped by setting CI variable SKIP_MR=yes
# Requires a fully configured Puppet-GitLab-CI runners
# environment to work.
# Without SKIP_MR=yes it expects Puppet code deployment to be done
# automatically when changes are pushed to a branch via Code Manager,
# r10k or similar.
# Workaround for fatal: git fetch-pack: expected shallow list error
# See: https://gitlab.com/gitlab-org/gitlab-foss/issues/60466
variables:
GIT_STRATEGY: clone
stages:
- merge request
- checks
- unit
- integration
- canary
- promote
- production runs
- documentation
# Create WIP Merge request
Create WIP MR:
stage: merge request
script:
- "bin/gitlab_create_merge_request.rb ${CI_BUILD_REF_NAME} production \"WIP: Works on ${CI_BUILD_REF_NAME}\""
when: on_success
tags:
- deploy_puppet
except:
refs:
- production
- schedules
variables:
- $SKIP_MR == "yes"
allow_failure: true
# Run Syntax Checks on Feature/Personal Branch
Syntax checks:
stage: checks
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
script: "bin/puppet_check_syntax_fast.sh all_but_chars"
cache:
untracked: true
paths:
- modules/
tags:
- test_puppet
except:
- production
only:
- branches
Puppet Lint:
stage: checks
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
script: "bin/puppet_lint.sh"
cache:
untracked: true
paths:
- modules/
tags:
- test_puppet
except:
- production
only:
- branches
allow_failure: true
Hidden chars check:
stage: checks
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
script: "bin/puppet_check_syntax_fast.sh chars"
cache:
untracked: true
paths:
- modules/
tags:
- test_puppet
except:
- production
only:
- branches
allow_failure: true
Danger BOT:
stage: checks
before_script:
- "bin/gitlab_before.sh"
script: "bin/gitlab_danger.sh"
cache:
untracked: true
paths:
- modules/
tags:
- deploy_puppet
except:
- production
- schedules
only:
- branches_disabled
allow_failure: true
# Version Deploy check for every branch with environment creation
# It will try by default 6 times with 10 second between each try
# so that Puppet has time to get the new version of the repository
Verify code deploy:
stage: checks
script: "bin/codemanager_check_deploy.sh ${CI_BUILD_REF_NAME}"
tags:
- deploy_puppet
when: on_success
allow_failure: true
environment:
name: ${CI_BUILD_REF_NAME}
url: https://puppet.lab.psick.io/
# UNIT TESTS
Local site modules:
stage: unit
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
script:
- "bin/puppet_check_rake.sh site bundle"
cache:
untracked: true
paths:
- modules/
- vagrant/environments/ci/.vagrant/
tags:
- test_puppet
except:
- production
only:
- branches
allow_failure: true
control-repo:
stage: unit
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
script:
- "bin/puppet_check_rake.sh controlrepo"
cache:
untracked: true
paths:
- modules/
- vagrant/environments/ci/.vagrant/
tags:
- test_puppet
except:
- production
only:
- branches
allow_failure: true
Public modules:
stage: unit
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
script:
- "bin/puppet_check_rake.sh modules bundle"
cache:
untracked: true
paths:
- modules/
- vagrant/environments/ci/.vagrant/
tags:
- test_puppet
except:
- production
only:
- branches
allow_failure: true
when: manual
Catalog preview:
stage: integration
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
script: "bin/gitlab_catalog_preview.sh ${CI_BUILD_REF_NAME}"
cache:
untracked: true
paths:
- modules/
tags:
- deploy_puppet
allow_failure: true
except:
- production
when: manual
# Can be duplicated to use different images (using different --image)
# or with custom facts --facts. Check docker_run.sh for all the options.
Docker tests:
stage: integration
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
script: "bin/docker_run.sh --image centos-7"
cache:
untracked: true
paths:
- modules/
allow_failure: true
tags:
- test_puppet
only:
- schedules
- branches
except:
- production
when: manual
Beaker tests:
stage: integration
before_script:
- "bin/gitlab_before.sh ${CI_BUILD_REF_NAME}"
- "/opt/puppetlabs/puppet/bin/bundle install --with=integration --path=vendor"
script: "/opt/puppetlabs/puppet/bin/rake beaker_roles:psick"
cache:
untracked: true
paths:
- modules/
allow_failure: true
tags:
- test_puppet
except:
- production
when: manual
only:
- schedules
- branches
Canary no-noop runs:
stage: canary
before_script:
- "bin/puppet_ci.sh job_run --no-noop --environment ${CI_BUILD_REF_NAME} --description '[CI] Canary no-noop run with ${CI_BUILD_REF_NAME}'"
script:
- "bin/puppetdb_env_query.sh ${CI_BUILD_REF_NAME}"
tags:
- deploy_puppet
when: manual
only:
- branches
- schedules
except:
- production
allow_failure: true
Canary noop runs:
stage: canary
before_script:
- "bin/puppet_ci.sh job_run --noop --environment ${CI_BUILD_REF_NAME} --description '[CI] Canary noop run with ${CI_BUILD_REF_NAME}'"
script:
- "bin/puppetdb_env_query.sh ${CI_BUILD_REF_NAME}"
tags:
- deploy_puppet
when: on_success
only:
- branches
- schedules
except:
- production
allow_failure: true
Accept MR:
stage: promote
script: "bin/gitlab_accept_merge_request.rb ${CI_BUILD_REF_NAME} production"
tags:
- deploy_puppet
when: manual
except:
refs:
- production
variables:
- $SKIP_MR == "yes"
allow_failure: true
only:
- branches_disabled
# Production Rollout
Trigger noop runs:
stage: production runs
before_script:
- "bin/puppet_ci.sh job_run --noop --environment production --description '[CI] Production noop run'"
script: "bin/puppetdb_env_query.sh production"
tags:
- deploy_puppet
when: on_success
only:
- production
allow_failure: true # TOREMOVE when fixed
Trigger no_noop runs:
stage: production runs
before_script:
- "bin/puppet_ci.sh job_run --no-noop --environment production --description '[CI] Production no-noop run'"
script: "bin/puppetdb_env_query.sh production"
tags:
- deploy_puppet
when: manual
only:
- production
allow_failure: true # TOREMOVE when fixed
# Documentation
control-repo docs:
stage: documentation
before_script:
- rm -rf doc public .yardoc README.md
- bin/docs_classlistgenerate.sh site/profile docs/classes.md
- for f in $(cat docs/toc.txt); do cat docs/$f >> README.md ; echo >> README.md ; done
- bin/gitlab_before.sh
script:
- puppet strings generate site/**/**/*{.pp\,.rb} site/**/**/**/*{.pp\,.rb} modules/psick/**/*{.pp\,.rb} modules/psick/**/**/*{.pp\,.rb} modules/psick/**/**/**/*{.pp\,.rb} manifests/site.pp
- mv doc public
tags:
- deploy_puppet
artifacts:
paths:
- public
expire_in: '30 day'
only:
- production
modules docs:
stage: documentation
before_script:
- bin/gitlab_before.sh
- rm -f README.md
- bin/docs_classlistgenerate.sh modules docs/classes_modules.md
- for f in $(cat docs/toc-modules.txt); do cat docs/$f >> README.md ; done
- bin/gitlab_before.sh
script:
- puppet strings generate modules/**/**/*{.pp\,.rb} modules/**/**/**/*{.pp\,.rb}
# - rake strings:generate["modules/**/**/*{.pp\,.rb} modules/**/**/**/*{.pp\,.rb}, false, false, markdown,-r docs/PsickGuide.md"]
- mv doc public/modules
tags:
- deploy_puppet
artifacts:
paths:
- public
expire_in: '30 day'
when: manual
only:
- production
Generate pdf:
stage: documentation
before_script:
- bin/docs_classlistgenerate.sh docs/classes.md
- mkdir public
- for f in $(cat docs/toc.txt); do cat docs/$f >> public/PsickGuide.md ; done
script:
- docker run -v $(pwd):/puppet -i jagregory/pandoc -f markdown /puppet/public/PsickGuide.md -o /puppet/public/PsickGuide.pdf --latex-engine=xelatex -s --toc -V geometry:margin=2cm
tags:
- test_puppet
artifacts:
paths:
- public
expire_in: '30 day'
only:
- production