forked from simp/simp-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
282 lines (242 loc) · 9.71 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
# ------------------------------------------------------------------------------
# The testing matrix considers ruby/puppet versions supported by SIMP and PE:
#
# https://puppet.com/docs/pe/2019.8/component_versions_in_recent_pe_releases.html
# https://puppet.com/misc/puppet-enterprise-lifecycle
# https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html
# ------------------------------------------------------------------------------
# Release Puppet Ruby EOL
# PE 2019.8 6.22 2.5.7 2022-12 (LTS)
---
stages:
- 'validation'
- 'acceptance'
- 'compliance'
- 'deployment'
variables:
# PUPPET_VERSION is a canary variable!
#
# The value `UNDEFINED` will (intentionally) cause `bundler install|update` to
# fail. The intended value for PUPPET_VERSION is provided by the `pup_#` YAML
# anchors. If it is still `UNDEFINED`, all the other setting from the job's
# anchor are also missing.
PUPPET_VERSION: 'UNDEFINED' # <- Matrixed jobs MUST override this (or fail)
BUNDLER_VERSION: '2.2.19'
SIMP_MATRIX_LEVEL: '1'
SIMP_FORCE_RUN_MATRIX: 'no'
# Force dependencies into a path the gitlab-runner user can write to.
# (This avoids some failures on Runners with misconfigured ruby environments.)
GEM_HOME: .vendor/gem_install
BUNDLE_CACHE_PATH: .vendor/bundle
BUNDLE_PATH: .vendor/bundle
BUNDLE_BIN: .vendor/gem_install/bin
BUNDLE_NO_PRUNE: 'true'
# bundler dependencies and caching
#
# - Cache bundler gems between pipelines foreach Ruby version
# - Try to use cached and local resources before downloading dependencies
# --------------------------------------
.setup_bundler_env: &setup_bundler_env
cache:
key: "${CI_PROJECT_NAMESPACE}_ruby-${MATRIX_RUBY_VERSION}_bundler"
paths:
- '.vendor'
before_script:
# Print important environment variables that may affect this job
- 'ruby -e "puts %(\n\n), %q(=)*80, %(\nSIMP-relevant Environment Variables:\n\n#{e=ENV.keys.grep(/^PUPPET|^SIMP|^BEAKER|MATRIX/); pad=((e.map{|x| x.size}.max||0)+1); e.map{|v| %( * #{%(#{v}:).ljust(pad)} #{39.chr + ENV[v] + 39.chr}\n)}.join}\n), %q(=)*80, %(\n\n)" || :'
- echo -e "\e[0Ksection_start:`date +%s`:before_script10[collapsed=true]\r\e[0KDiagnostic ruby & gem information"
# Diagnostic ruby & gem information
- 'which ruby && ruby --version || :'
- "[[ $- == *i* ]] && echo 'Interactive shell session' || echo 'Non-interactive shell session'"
- "shopt -q login_shell && echo 'Login shell' || echo 'Not a login shell'"
- 'rvm ls || :'
- echo -e "\e[0Ksection_end:`date +%s`:before_script10\r\e[0K"
# If RVM is available, make SURE it's using the right Ruby:
# * Source rvm (to run in non-login shells)
# * Use $MATRIX_RUBY_VERSION ruby, install if not present
- echo -e "\e[0Ksection_start:`date +%s`:before_script20[collapsed=true]\r\e[0KEnsure RVM & ruby is installed"
- "if command -v rvm; then if declare -p rvm_path &> /dev/null; then source \"${rvm_path}/scripts/rvm\"; else source \"$HOME/.rvm/scripts/rvm\" || source /etc/profile.d/rvm.sh; fi; fi"
- "if command -v rvm && ! grep rvm_install_on_use_flag=1 ~/.rvmrc; then echo rvm_install_on_use_flag=1 >> ~/.rvmrc || echo '== WARNING: ~/.rvmrc is missing rvm_install_on_use_flag=1 and I failed to add it'; fi"
- "if command -v rvm; then rvm use \"$MATRIX_RUBY_VERSION\"; else echo \"rvm not detected; skipping 'rvm use'\"; fi"
- 'ruby --version || :'
- 'gem list sync || :'
- echo -e "\e[0Ksection_end:`date +%s`:before_script20\r\e[0K"
# Bundle gems (preferring cached > local > downloaded resources)
# * Try to use cached and local resources before downloading dependencies
- echo -e "\e[0Ksection_start:`date +%s`:before_script30[collapsed=true]\r\e[0KBundle gems (preferring cached > local > downloaded resources)"
- 'declare GEM_BUNDLER_VER=(-v "~> ${BUNDLER_VERSION:-2.2.6}")'
- 'declare GEM_INSTALL_CMD=(gem install --no-document)'
- 'declare BUNDLER_INSTALL_CMD=(bundle install --no-binstubs --jobs $(nproc) "${FLAGS[@]}")'
- 'mkdir -p ${GEM_HOME} ${BUNDLER_BIN}'
- 'gem list -ie "${GEM_BUNDLER_VER[@]}" --silent bundler || "${GEM_INSTALL_CMD[@]}" --local "${GEM_BUNDLER_VER[@]}" bundler || "${GEM_INSTALL_CMD[@]}" "${GEM_BUNDLER_VER[@]}" bundler'
- 'rm -rf pkg/ || :'
- 'bundle check || rm -f Gemfile.lock && ("${BUNDLER_INSTALL_CMD[@]}" --local || "${BUNDLER_INSTALL_CMD[@]}" || bundle pristine || "${BUNDLER_INSTALL_CMD[@]}") || { echo "PIPELINE: Bundler could not install everything (see log output above)" && exit 99 ; }'
- echo -e "\e[0Ksection_end:`date +%s`:before_script30\r\e[0K"
# Diagnostic bundler, ruby, and gem checks:
- echo -e "\e[0Ksection_start:`date +%s`:before_script40[collapsed=true]\r\e[0KDiagnostic bundler, ruby, and gem checks"
- 'bundle exec rvm ls || :'
- 'bundle exec which ruby || :'
- 'bundle show sync || :'
- 'bundle exec gem list sync || :'
- echo -e "\e[0Ksection_end:`date +%s`:before_script40\r\e[0K"
# Puppet Versions
#-----------------------------------------------------------------------
.pup_6_x: &pup_6_x
image: 'ruby:2.5'
variables:
PUPPET_VERSION: '~> 6.0'
BEAKER_PUPPET_COLLECTION: 'puppet6'
MATRIX_RUBY_VERSION: '2.5'
.pup_6_pe: &pup_6_pe
image: 'ruby:2.5'
variables:
PUPPET_VERSION: '6.22.1'
BEAKER_PUPPET_COLLECTION: 'puppet6'
MATRIX_RUBY_VERSION: '2.5'
.pup_7_x: &pup_7_x
image: 'ruby:2.7'
variables:
PUPPET_VERSION: '~> 7.0'
BEAKER_PUPPET_COLLECTION: 'puppet7'
MATRIX_RUBY_VERSION: '2.7'
# Testing Environments
#-----------------------------------------------------------------------
.lint_tests: &lint_tests
stage: 'validation'
tags: ['docker']
<<: *setup_bundler_env
script:
- 'bundle exec rake metadata_lint'
.unit_tests: &unit_tests
stage: 'validation'
tags: ['docker']
<<: *setup_bundler_env
script:
- 'bundle exec rake spec'
.acceptance_base: &acceptance_base
stage: 'acceptance'
tags: ['beaker']
<<: *setup_bundler_env
.compliance_base: &compliance_base
stage: 'compliance'
tags: ['beaker']
<<: *setup_bundler_env
# Pipeline / testing matrix
#=======================================================================
releng_checks:
<<: *pup_6_x
<<: *setup_bundler_env
stage: 'validation'
tags: ['docker']
script:
- 'command -v rpm || if command -v apt-get; then apt-get update; apt-get install -y rpm; fi ||:'
- 'SIMP_RPM_dist=.el7 bundle exec rake check:dot_underscore'
- 'SIMP_RPM_dist=.el7 bundle exec rake check:test_file'
- 'bundle exec rake metadata_lint'
- 'bundle exec pdk build --force --target-dir=dist'
# Project-specific test control variables
#=======================================================================
#
# Anchor to disable release flavored tests, and run them only when
# the environment variable SIMP_RELEASE_TESTS is set in the GitLab repo settings
.only_with_SIMP_RELEASE_TESTS: &only_with_SIMP_RELEASE_TESTS
only:
variables:
- $SIMP_RELEASE_TESTS
# To avoid running a prohibitive number of tests every commit,
# don't set this env var in your gitlab instance
.only_with_SIMP_FULL_MATRIX: &only_with_SIMP_FULL_MATRIX
only:
variables:
- $SIMP_FULL_MATRIX
# When you want to run the ipa suite tests along with the default suite tests
# or run the full matrix
.only_with_SIMP_FULL_MATRIX_or_SIMP_IPA_TEST: &only_with_SIMP_FULL_MATRIX_or_SIMP_IPA_TEST
only:
variables:
- $SIMP_FULL_MATRIX
- $SIMP_IPA_TEST
# When you want to run the simp_lite suite tests along with the default suite tests
# or run the full matrix
.only_with_SIMP_FULL_MATRIX_or_SIMP_LITE_TEST: &only_with_SIMP_FULL_MATRIX_or_SIMP_LITE_TEST
only:
variables:
- $SIMP_FULL_MATRIX
- $SIMP_LITE_TEST
# Acceptance tests
# ==============================================================================
pup6.pe-default_el7:
<<: *acceptance_base
<<: *pup_6_pe
script:
- bundle exec rake beaker:suites[default,el7_server]
retry: 1
pup6.pe-default_el8:
<<: *acceptance_base
<<: *pup_6_pe
script:
- bundle exec rake beaker:suites[default,el8_server]
retry: 1
pup6.pe-ipa_el7:
<<: *acceptance_base
<<: *only_with_SIMP_FULL_MATRIX_or_SIMP_IPA_TEST
<<: *pup_6_pe
script:
- bundle exec rake beaker:suites[ipa,el7_server]
retry: 1
# IPA for EL8 not yet supported
#pup6.pe-ipa_el8:
# <<: *acceptance_base
# <<: *only_with_SIMP_FULL_MATRIX_or_SIMP_IPA_TEST
# <<: *pup_6_pe
# script:
# - bundle exec rake beaker:suites[ipa,el8_server]
# retry: 1
pup6.pe-simp_lite_el7:
<<: *acceptance_base
<<: *pup_6_pe
<<: *only_with_SIMP_FULL_MATRIX_or_SIMP_LITE_TEST
script:
- bundle exec rake beaker:suites[simp_lite,el7_server]
retry: 1
pup6.pe-simp_lite_el8:
<<: *acceptance_base
<<: *pup_6_pe
<<: *only_with_SIMP_FULL_MATRIX_or_SIMP_LITE_TEST
script:
- bundle exec rake beaker:suites[simp_lite,el8_server]
retry: 1
pup6.pe-rpm_el7:
<<: *acceptance_base
<<: *only_with_SIMP_RELEASE_TESTS
<<: *pup_6_pe
script:
- bundle exec rake beaker:suites[install_from_rpm,el7_server]
retry: 1
pup6.pe-rpm_el8:
<<: *acceptance_base
<<: *only_with_SIMP_RELEASE_TESTS
<<: *pup_6_pe
script:
- bundle exec rake beaker:suites[install_from_rpm,el8_server]
retry: 1
pup6.pe-forge_install_el7:
<<: *acceptance_base
<<: *only_with_SIMP_RELEASE_TESTS
<<: *pup_6_pe
script:
- bundle exec rake beaker:suites[install_from_core_module,el7_server]
retry: 1
pup6.pe-forge_install_el8:
<<: *acceptance_base
<<: *only_with_SIMP_RELEASE_TESTS
<<: *pup_6_pe
script:
- bundle exec rake beaker:suites[install_from_core_module,el8_server]
retry: 1
pup7.pe-default_el7:
<<: *acceptance_base
<<: *pup_7_x
script:
- bundle exec rake beaker:suites[default,el7_server]
retry: 1