simp-beaker-helpers 1.21.3 → 1.23.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/.fips_fixtures +1 -0
  3. data/.fixtures.yml +6 -1
  4. data/.github/workflows.local.json +6 -0
  5. data/.github/workflows/pr_acceptance.yml +55 -0
  6. data/.github/workflows/pr_glci.yml +190 -0
  7. data/.github/workflows/pr_glci_cleanup.yml +105 -0
  8. data/.github/workflows/pr_glci_manual.yml +143 -0
  9. data/.github/workflows/pr_tests.yml +90 -0
  10. data/.github/workflows/tag_deploy_rubygem.yml +192 -0
  11. data/.gitlab-ci.yml +37 -37
  12. data/CHANGELOG.md +56 -0
  13. data/Gemfile +1 -1
  14. data/README.md +63 -5
  15. data/lib/simp/beaker_helpers.rb +164 -61
  16. data/lib/simp/beaker_helpers/inspec.rb +16 -12
  17. data/lib/simp/beaker_helpers/ssg.rb +36 -12
  18. data/lib/simp/beaker_helpers/version.rb +1 -1
  19. data/lib/simp/rake/beaker.rb +14 -2
  20. data/simp-beaker-helpers.gemspec +5 -1
  21. data/spec/acceptance/nodesets/docker.yml +12 -10
  22. data/spec/acceptance/suites/default/enable_fips_spec.rb +6 -4
  23. data/spec/acceptance/suites/default/install_simp_deps_repo_spec.rb +17 -5
  24. data/spec/acceptance/suites/fips_from_fixtures/00_default_spec.rb +11 -3
  25. data/spec/acceptance/suites/inspec/00_default_spec.rb +54 -0
  26. data/spec/acceptance/suites/inspec/metadata.yml +2 -0
  27. data/spec/acceptance/suites/inspec/nodesets +1 -0
  28. data/spec/acceptance/suites/puppet_collections/00_default_spec.rb +1 -1
  29. data/spec/acceptance/suites/ssg/00_default_spec.rb +40 -0
  30. data/spec/acceptance/suites/ssg/metadata.yml +2 -0
  31. data/spec/acceptance/suites/ssg/nodesets +1 -0
  32. data/spec/lib/simp/beaker_helpers_spec.rb +1 -3
  33. metadata +54 -40
  34. data/.travis.yml +0 -42
@@ -0,0 +1,90 @@
1
+ # Run Puppet checks and test matrix on Pull Requests
2
+ # ------------------------------------------------------------------------------
3
+ # NOTICE: **This file is maintained with puppetsync**
4
+ #
5
+ # This file is updated automatically as part of a puppet module baseline.
6
+ #
7
+ # The next baseline sync will overwrite any local changes to this file!
8
+ #
9
+ # ==============================================================================
10
+ #
11
+ # The testing matrix considers ruby/puppet versions supported by SIMP and PE:
12
+ # ------------------------------------------------------------------------------
13
+ # Release Puppet Ruby EOL
14
+ # SIMP 6.4 5.5 2.40 TBD
15
+ # PE 2018.1 5.5 2.40 2021-01 (LTS overlap)
16
+ # PE 2019.8 6.18 2.5 2022-12 (LTS)
17
+ #
18
+ # https://puppet.com/docs/pe/2018.1/component_versions_in_recent_pe_releases.html
19
+ # https://puppet.com/misc/puppet-enterprise-lifecycle
20
+ # https://puppet.com/docs/pe/2018.1/overview/getting_support_for_pe.html
21
+ # ==============================================================================
22
+ #
23
+ # https://docs.github.com/en/actions/reference/events-that-trigger-workflows
24
+ #
25
+
26
+ name: PR Tests
27
+ on:
28
+ push:
29
+ branches:
30
+ # A test branch for seeing if your tests will pass in your personal fork
31
+ - test_me_github
32
+ pull_request:
33
+ types: [opened, reopened, synchronize]
34
+
35
+ env:
36
+ PUPPET_VERSION: '~> 6'
37
+
38
+ jobs:
39
+ ruby-style:
40
+ if: false # TODO Modules will need: rubocop in Gemfile, .rubocop.yml
41
+ name: 'Ruby Style (experimental)'
42
+ runs-on: ubuntu-18.04
43
+ continue-on-error: true
44
+ steps:
45
+ - uses: actions/checkout@v2
46
+ - name: "Install Ruby ${{matrix.puppet.ruby_version}}"
47
+ uses: ruby/setup-ruby@v1
48
+ with:
49
+ ruby-version: 2.5
50
+ bundler-cache: true
51
+ - run: |
52
+ bundle show
53
+ bundle exec rake rubocop
54
+
55
+ spec-tests:
56
+ name: 'Spec'
57
+ runs-on: ubuntu-18.04
58
+ strategy:
59
+ matrix:
60
+ puppet:
61
+ - label: 'Puppet 6.18 [SIMP 6.5/PE 2019.8]'
62
+ puppet_version: '~> 6.18.0'
63
+ ruby_version: '2.5'
64
+ - label: 'Puppet 5.5 [SIMP 6.4/PE 2018.1]'
65
+ puppet_version: '~> 5.5.22'
66
+ ruby_version: '2.4'
67
+ - label: 'Puppet 7.x'
68
+ puppet_version: '~> 7.0'
69
+ ruby_version: '2.7'
70
+ env:
71
+ PUPPET_VERSION: '${{matrix.puppet.puppet_version}}'
72
+ steps:
73
+ - uses: actions/checkout@v2
74
+ - name: 'Install Ruby ${{matrix.puppet.ruby_version}}'
75
+ uses: ruby/setup-ruby@v1
76
+ with:
77
+ ruby-version: ${{matrix.puppet.ruby_version}}
78
+ bundler-cache: true
79
+ - run: 'command -v rpm || if command -v apt-get; then sudo apt-get update; sudo apt-get install -y rpm; fi ||:'
80
+ - run: 'bundle exec rake spec'
81
+
82
+ # dump_contexts:
83
+ # name: 'Examine Context contents'
84
+ # runs-on: ubuntu-16.04
85
+ # steps:
86
+ # - name: Dump contexts
87
+ # env:
88
+ # GITHUB_CONTEXT: ${{ toJson(github) }}
89
+ # run: echo "$GITHUB_CONTEXT"
90
+ #
@@ -0,0 +1,192 @@
1
+ # Build & Deploy RubyGem & GitHub release when a SemVer tag is pushed
2
+ #
3
+ # This workflow's jobs are only triggered in repos under the `simp` organization
4
+ # ------------------------------------------------------------------------------
5
+ #
6
+ # NOTICE: **This file is maintained with puppetsync**
7
+ #
8
+ # This file is updated automatically as part of a standardized asset baseline.
9
+ #
10
+ # The next baseline sync will overwrite any local changes to this file!
11
+ #
12
+ # ==============================================================================
13
+ #
14
+ # This pipeline uses the following GitHub Action Secrets:
15
+ #
16
+ # GitHub Secret variable Type Notes
17
+ # ------------------------ -------- ----------------------------------------
18
+ # RUBYGEMS_API_KEY Required
19
+ #
20
+ # ------------------------------------------------------------------------------
21
+ #
22
+ # NOTES:
23
+ #
24
+ # * The CHANGLOG text is altered to remove RPM-style date headers, which don't
25
+ # render well as markdown on the GitHub release pages
26
+ #
27
+ # * By default, the gem is built and released using the standard rake tasks
28
+ # from "bundler/gem_tasks". To override these, create a JSON file at
29
+ # `.github/workflows.local.json`, using the following format:
30
+ #
31
+ # {
32
+ # "gem_build_command": "bundle exec rake build",
33
+ # "gem_release_command": "bundle exec rake build release:rubygem_push",
34
+ # "gem_pkg_dir": "pkg"
35
+ # }
36
+ #
37
+ # All keys are optional.
38
+ #
39
+ ---
40
+ name: 'Tag: Release to GitHub & rubygems.org'
41
+
42
+ on:
43
+ push:
44
+ tags:
45
+ - '[0-9]+\.[0-9]+\.[0-9]+'
46
+
47
+ env:
48
+ PUPPET_VERSION: '~> 6'
49
+ LOCAL_WORKFLOW_CONFIG_FILE: .github/workflows.local.json
50
+
51
+ jobs:
52
+ releng-checks:
53
+ name: "RELENG checks"
54
+ if: github.repository_owner == 'simp'
55
+ runs-on: ubuntu-18.04
56
+ outputs:
57
+ build_command: ${{ steps.commands.outputs.build_command }}
58
+ release_command: ${{ steps.commands.outputs.release_command }}
59
+ pkg_dir: ${{ steps.commands.outputs.pkg_dir }}
60
+ steps:
61
+ - name: "Assert '${{ github.ref }}' is a tag"
62
+ run: '[[ "$GITHUB_REF" =~ ^refs/tags/ ]] || { echo "::error ::GITHUB_REF is not a tag: ${GITHUB_REF}"; exit 1 ; }'
63
+ - uses: actions/checkout@v2
64
+ with:
65
+ ref: ${{ github.ref }}
66
+ clean: true
67
+ - name: Determing build and release commands
68
+ id: commands
69
+ run: |
70
+ # By default, these are the standard tasks from "bundler/gem_tasks"
71
+ # To override them in the LOCAL_WORKFLOW_CONFIG_FILE
72
+ GEM_BUILD_COMMAND='bundle exec rake build'
73
+ GEM_RELEASE_COMMAND='bundle exec rake build release:rubygem_push'
74
+ GEM_PKG_DIR='pkg'
75
+ if jq -r '. | keys' "$LOCAL_WORKFLOW_CONFIG_FILE" 2>/dev/null | \
76
+ grep -w '"gem_pkg_dir"' &> /dev/null; then
77
+ GEM_PKG_DIR="$(jq -r .gem_pkg_dir "$LOCAL_WORKFLOW_CONFIG_FILE" )"
78
+ fi
79
+ if jq -r '. | keys' "$LOCAL_WORKFLOW_CONFIG_FILE" 2>/dev/null | \
80
+ grep -w '"gem_build_command"' &> /dev/null; then
81
+ GEM_BUILD_COMMAND="$(jq -r .gem_build_command "$LOCAL_WORKFLOW_CONFIG_FILE" )"
82
+ fi
83
+ if jq -r '. | keys' "$LOCAL_WORKFLOW_CONFIG_FILE" 2>/dev/null | \
84
+ grep -w '"gem_release_command"' &> /dev/null; then
85
+ GEM_RELEASE_COMMAND="$(jq -r .gem_release_command "$LOCAL_WORKFLOW_CONFIG_FILE" )"
86
+ fi
87
+ echo "::set-output name=build_command::${GEM_BUILD_COMMAND}"
88
+ echo "::set-output name=pkg_dir::${GEM_PKG_DIR}"
89
+ echo "::set-output name=release_command::${GEM_RELEASE_COMMAND}"
90
+ - uses: ruby/setup-ruby@v1
91
+ with:
92
+ ruby-version: 2.5
93
+ bundler-cache: true
94
+ - name: Test build the package
95
+ env:
96
+ GEM_BUILD_COMMAND: ${{ steps.commands.outputs.build_command }}
97
+ run: "$GEM_BUILD_COMMAND"
98
+ - name: "Assert '${{ github.ref }}' matches the package version"
99
+ run: |
100
+ tag="${GITHUB_REF/refs\/tags\//}"
101
+ [ -d "${{ steps.commands.outputs.pkg_dir }}" ] || \
102
+ { echo "::error ::No directory found at ${{ steps.commands.outputs.pkg_dir }}/" ; exit 3 ; }
103
+ ls -1 "${{ steps.commands.outputs.pkg_dir }}"/*.gem || \
104
+ { echo "::error ::No gem file found at ${{ steps.commands.outputs.pkg_dir }}/*.gem" ; exit 2 ; }
105
+ [ -f "${{ steps.commands.outputs.pkg_dir }}"/*-${tag}.gem ] || \
106
+ { echo "::error ::tag '${tag}' does not match package $(ls -1 ${{ steps.commands.outputs.pkg_dir }}/*.gem)"; exit 1 ; }
107
+
108
+ create-github-release:
109
+ name: Deploy GitHub Release
110
+ needs: [ releng-checks ]
111
+ if: github.repository_owner == 'simp'
112
+ runs-on: ubuntu-18.04
113
+ steps:
114
+ - name: Checkout code
115
+ uses: actions/checkout@v2
116
+ with:
117
+ ref: ${{ github.ref }}
118
+ clean: true
119
+ fetch-depth: 0
120
+ - name: Get tag & annotation info (${{github.ref}})
121
+ id: tag-check
122
+ run: |
123
+ tag="${GITHUB_REF/refs\/tags\//}"
124
+ annotation="$(git for-each-ref "$GITHUB_REF" --format='%(contents)' --count=1)"
125
+ annotation_title="$(echo "$annotation" | head -1)"
126
+
127
+ echo "::set-output name=tag::${tag}"
128
+ echo "::set-output name=annotation_title::${annotation_title}"
129
+
130
+ # Prepare annotation body as a file for the next step
131
+ #
132
+ # * The GitHub Release render the text in this file as markdown
133
+ # * The file is needed because :set-output only supports single lines
134
+ # * The `perl -pe` removes RPM-style date headers from the CHANGELOG,
135
+ # because they don't render well as markdown on the Release page
136
+ #
137
+ echo "$annotation" | tail -n +2 | \
138
+ perl -pe 'BEGIN{undef $/;} s/\n\* (Mon|Tue|Wed|Thu|Fri|Sat|Sun) .*?\n//smg;' > /tmp/annotation.body
139
+
140
+ - name: Create Release
141
+ uses: actions/create-release@v1
142
+ id: create_release
143
+ env:
144
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
145
+ with:
146
+ tag_name: ${{ github.ref }}
147
+ release_name: ${{ steps.tag-check.outputs.annotation_title }}
148
+ body_path: /tmp/annotation.body
149
+ draft: false
150
+ prerelease: false
151
+
152
+ deploy-rubygem:
153
+ name: Deploy RubyGem Release
154
+ needs: [ releng-checks ]
155
+ if: github.repository_owner == 'simp'
156
+ runs-on: ubuntu-18.04
157
+ env:
158
+ RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
159
+ BUILD_COMMAND: ${{ needs.releng-checks.outputs.build_command }}
160
+ RELEASE_COMMAND: ${{ needs.releng-checks.outputs.release_command }}
161
+ PKG_DIR: ${{ needs.releng-checks.outputs.pkg_dir }}
162
+ steps:
163
+ - name: Checkout code
164
+ uses: actions/checkout@v2
165
+ with:
166
+ ref: ${{ github.ref }}
167
+ clean: true
168
+ - uses: ruby/setup-ruby@v1
169
+ with:
170
+ ruby-version: 2.5
171
+ bundler-cache: true
172
+ - name: Build RubyGem
173
+ run: |
174
+ echo "Setting up file permissions..."
175
+ chmod -R go=u-w .
176
+
177
+ echo "Running '$BUILD_COMMAND'..."
178
+ $BUILD_COMMAND
179
+
180
+ - name: Release RubyGem
181
+ run: |
182
+ echo "Setting up gem credentials..."
183
+ mkdir -p ~/.gem
184
+
185
+ cat << EOF > ~/.gem/credentials
186
+ ---
187
+ :rubygems_api_key: ${RUBYGEMS_API_KEY}
188
+ EOF
189
+ chmod 0600 ~/.gem/credentials
190
+
191
+ echo "Running '$RELEASE_COMMAND'..."
192
+ $RELEASE_COMMAND
data/.gitlab-ci.yml CHANGED
@@ -1,11 +1,4 @@
1
1
  # ------------------------------------------------------------------------------
2
- # NOTICE: **This file is maintained with puppetsync**
3
- #
4
- # This file is updated automatically as part of a puppet module baseline.
5
- #
6
- # The next baseline sync will overwrite any local changes to everything above
7
- # the line "# Repo-specific content"
8
- # ------------------------------------------------------------------------------
9
2
  # The testing matrix considers ruby/puppet versions supported by SIMP and PE:
10
3
  #
11
4
  # https://puppet.com/docs/pe/2019.8/component_versions_in_recent_pe_releases.html
@@ -216,28 +209,28 @@ variables:
216
209
  # Puppet Versions
217
210
  #-----------------------------------------------------------------------
218
211
 
219
- .pup_5: &pup_5
212
+ .pup_5_x: &pup_5_x
220
213
  image: 'ruby:2.4'
221
214
  variables:
222
215
  PUPPET_VERSION: '~> 5.0'
223
216
  BEAKER_PUPPET_COLLECTION: 'puppet5'
224
217
  MATRIX_RUBY_VERSION: '2.4'
225
218
 
226
- .pup_6: &pup_6
219
+ .pup_6_x: &pup_6_x
227
220
  image: 'ruby:2.5'
228
221
  variables:
229
222
  PUPPET_VERSION: '~> 6.0'
230
223
  BEAKER_PUPPET_COLLECTION: 'puppet6'
231
224
  MATRIX_RUBY_VERSION: '2.5'
232
225
 
233
- .pup_6_18_0: &pup_6_18_0
226
+ .pup_6_pe: &pup_6_pe
234
227
  image: 'ruby:2.5'
235
228
  variables:
236
229
  PUPPET_VERSION: '6.18.0'
237
230
  BEAKER_PUPPET_COLLECTION: 'puppet6'
238
231
  MATRIX_RUBY_VERSION: '2.5'
239
232
 
240
- .pup_7: &pup_7
233
+ .pup_7_x: &pup_7_x
241
234
  image: 'ruby:2.7'
242
235
  variables:
243
236
  PUPPET_VERSION: '~> 7.0'
@@ -280,24 +273,18 @@ variables:
280
273
  # Unit Tests
281
274
  #-----------------------------------------------------------------------
282
275
 
283
- pup5-unit:
284
- <<: *pup_5
276
+ pup5.x-unit:
277
+ <<: *pup_5_x
285
278
  <<: *unit_tests
286
279
 
287
- pup6-unit:
288
- <<: *pup_6
280
+ pup6.x-unit:
281
+ <<: *pup_6_x
289
282
  <<: *unit_tests
290
283
 
291
- pup7-unit:
292
- <<: *pup_7
284
+ pup7.x-unit:
285
+ <<: *pup_7_x
293
286
  <<: *unit_tests
294
287
 
295
- # ------------------------------------------------------------------------------
296
- # NOTICE: **This file is maintained with puppetsync**
297
- #
298
- # Everything above the "Repo-specific content" comment will be overwritten by
299
- # the next puppetsync.
300
- # ------------------------------------------------------------------------------
301
288
 
302
289
  # Repo-specific content
303
290
  # ==============================================================================
@@ -305,70 +292,83 @@ pup7-unit:
305
292
  #=======================================================================
306
293
  # Packaging test
307
294
 
308
- pup5-pkg:
309
- <<: *pup_5
295
+ pup5.x-pkg:
296
+ <<: *pup_5_x
310
297
  <<: *unit_tests
311
298
  script:
312
299
  'bundle exec rake pkg:gem'
313
300
 
314
- pup6-pkg:
315
- <<: *pup_6
301
+ pup6.x-pkg:
302
+ <<: *pup_6_x
316
303
  <<: *unit_tests
317
304
  script:
318
305
  'bundle exec rake pkg:gem'
319
306
 
320
- pup7-pkg:
321
- <<: *pup_7
307
+ pup7.x-pkg:
308
+ <<: *pup_7_x
322
309
  <<: *unit_tests
323
310
  script:
324
311
  'bundle exec rake pkg:gem'
325
312
 
326
313
  #=======================================================================
327
314
  # Acceptance tests
315
+
316
+ # Verify a suite fails when an explicitly-specified nodeset does not exist.
317
+ # It is significantly quicker to test here (where rvm is already installed
318
+ # and the bundle is configured with this version of simp-beaker-helpers)
319
+ # than in an acceptance test with a build user.
320
+ default-bad-nodeset:
321
+ <<: *pup_6_x
322
+ <<: *acceptance_base
323
+ script:
324
+ - 'RESULT=`bundle exec rake beaker:suites[default,oops] 1>/dev/null; echo $?`; (test $RESULT == "1")'
325
+ - echo 'beaker:suites correctly failed with unknown nodeset'
326
+
328
327
  default:
329
- <<: *pup_6
328
+ <<: *pup_6_x
330
329
  <<: *acceptance_base
331
330
  script:
332
331
  - bundle exec rake beaker:suites[default]
333
332
 
334
333
  default-fips:
335
- <<: *pup_6
334
+ <<: *pup_6_x
336
335
  <<: *acceptance_base
337
336
  script:
338
337
  - BEAKER_fips=yes bundle exec rake beaker:suites[default]
339
338
 
340
339
  fips_from_fixtures:
341
- <<: *pup_6
340
+ <<: *pup_6_x
342
341
  <<: *acceptance_base
343
342
  script:
344
343
  - bundle exec rake beaker:suites[fips_from_fixtures]
345
344
 
346
345
  puppet5_collections:
347
- <<: *pup_5
346
+ <<: *pup_5_x
348
347
  <<: *acceptance_base
349
348
  script:
350
349
  - bundle exec rake beaker:suites[puppet_collections]
351
350
 
352
351
  puppet6_collections:
353
- <<: *pup_6
352
+ <<: *pup_6_x
354
353
  <<: *acceptance_base
355
354
  script:
356
355
  - bundle exec rake beaker:suites[puppet_collections]
357
356
 
358
357
  puppet7_collections:
359
- <<: *pup_7
358
+ <<: *pup_7_x
360
359
  <<: *acceptance_base
361
360
  script:
362
361
  - bundle exec rake beaker:suites[puppet_collections]
363
362
 
364
363
  windows:
365
- <<: *pup_6
364
+ <<: *pup_6_x
366
365
  <<: *acceptance_base
366
+ allow_failure: true
367
367
  script:
368
368
  - bundle exec rake beaker:suites[windows]
369
369
 
370
370
  snapshot:
371
- <<: *pup_6
371
+ <<: *pup_6_x
372
372
  <<: *acceptance_base
373
373
  # This is prone to breakage in the underlying system
374
374
  allow_failure: true