From ad8590488cc16c0aa22c29131cb35d0b18481233 Mon Sep 17 00:00:00 2001 From: Chris Tessmer Date: Mon, 20 Jul 2020 15:47:34 -0400 Subject: [PATCH] (SIMP-7974) Add new GLCI pipeline features The patch adds enhanced features to SIMP Puppet modules' standardized GitLab CI pipeline: * spec and acceptance tests _only_ run when relevant files have changed * The CI variable `SIMP_FULL_MATRIX` is replaced by `SIMP_MATRIX_LEVEL` * spec and acceptance tests run at or above their `SIMP_MATRIX_LEVEL` * Jobs and the pipeline default to `SIMP_MATRIX_LEVEL` 1 * The pipeline's `SIMP_MATRIX_LEVEL` can be changed via CI variable (via triggers, group/project settings, etc) * In the pipeline-triggering commit message, adding a line that starts with `CI: MATRIX LEVEL 0` or `CI: SKIP MATRIX` will suppress all steps with `SIMP_MATRIX_LEVEL` 1-3 There is an important caveat: because of the way GitLab CI pipelines determine `changes`, a file that hasn't changed between `--amend` + force-pushed updates _will not trigger the matrix again_. This affects scheduled and triggered pipelines. * To solve this scenario, setting the CI variable `SIMP_FORCE_MATRIX = yes` in a scheduled pipeline or pipeline trigger will ensure that all jobs at the current `SIMP_MATRIX_LEVEL` are run, regardless of what has changed (or not). SIMP-8004 #close [SIMP-7974] #comment Add file-match CI runs to pupmod-simp-simpkv [SIMP-7975] #comment Add `SIMP_MATRIX_LEVEL` checks to pupmod-simp-simpkv [SIMP-7974]: https://simp-project.atlassian.net/browse/SIMP-7974 [SIMP-7975]: https://simp-project.atlassian.net/browse/SIMP-7975 --- .gitlab-ci.yml | 171 +++++++++++++++++++++++++++++++++++++++++-------- .travis.yml | 163 ++++++++++++++++++++++++++++------------------ Gemfile | 32 +++++++-- 3 files changed, 267 insertions(+), 99 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 09249a9..d896b89 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,15 +1,16 @@ +# ------------------------------------------------------------------------------ +# NOTICE: **This file is maintained with puppetsync** +# ------------------------------------------------------------------------------ # The testing matrix considers ruby/puppet versions supported by SIMP and PE: # -# https://puppet.com/docs/pe/2019.0/component_versions_in_recent_pe_releases.html +# 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 -# SIMP 6.3 5.5.10 2.4.5 TBD*** -# PE 2018.1 5.5.8 2.4.5 2020-05 (LTS)*** -# PE 2019.0 6.0 2.5.1 2019-08-31^^^ -# -# *** = Modules created for SIMP 6.3+ are not required to support Puppet < 5.5 +# Release Puppet Ruby EOL +# SIMP 6.4 5.5 2.4.10 TBD +# PE 2018.1 5.5 2.4.10 2021-01 (LTS overlap) +# PE 2019.8 6.16 2.5.7 2021-11 (LTS) --- stages: - 'sanity' @@ -21,6 +22,8 @@ stages: variables: PUPPET_VERSION: 'UNDEFINED' # <- Matrixed jobs MUST override this (or fail) BUNDLER_VERSION: '1.17.1' + 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.) @@ -38,7 +41,6 @@ variables: # -------------------------------------- .setup_bundler_env: &setup_bundler_env cache: - untracked: true key: "${CI_PROJECT_NAMESPACE}_ruby-${MATRIX_RUBY_VERSION}_bundler" paths: - '.vendor' @@ -52,12 +54,85 @@ variables: - '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 ; }' -# 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 == "yes" +# Assign a matrix level when your test will run. Heavier jobs get higher numbers +# NOTE: To skip all jobs with a SIMP_MATRIX_LEVEL, set SIMP_MATRIX_LEVEL=0 + +.meets_spec_test_criteria: &meets_spec_test_criteria + changes: + - .gitlab-ci.yml + - .fixtures.yml + - "spec/spec_helper.rb" + - "spec/{classes,unit,defines,type_aliases,types,hosts}/**/*.rb" + - "{manifests,files,types}/**/*" + - "templates/*.{erb,epp}" + - "lib/**/*" + exists: + - "spec/{classes,unit,defines,type_aliases,types,hosts}/**/*_spec.rb" + +.meets_acceptance_test_criteria: &meets_acceptance_test_criteria + changes: + - .gitlab-ci.yml + - "spec/spec_helper_acceptance.rb" + - "spec/acceptance/**/*" + - "{manifests,files,types}/**/*" + - "templates/*.{erb,epp}" + - "lib/**/*" + exists: + - "spec/acceptance/**/*_spec.rb" + +# SIMP_MATRIX_LEVEL=1: Intended to run every commit +.with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1: &with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1 + rules: + - when: on_success + if: '$CI_COMMIT_MESSAGE =~ /^CI: MATRIX LEVEL [123]/' + - when: on_success + if: '$SIMP_FORCE_RUN_MATRIX == "yes" && $SIMP_MATRIX_LEVEL =~ /^[123]$/' + - when: on_success + if: '$SIMP_MATRIX_LEVEL =~ /^[123]$/ && $CI_COMMIT_MESSAGE !~ /^CI: (SKIP MATRIX|MATRIX LEVEL 0)/' + <<: *meets_acceptance_test_criteria + +.with_SIMP_SPEC_MATRIX_LEVEL_1: &with_SIMP_SPEC_MATRIX_LEVEL_1 + rules: + - when: on_success + if: '$CI_COMMIT_MESSAGE =~ /^CI: MATRIX LEVEL [123]/' + - when: on_success + if: '$SIMP_FORCE_RUN_MATRIX == "yes" && $SIMP_MATRIX_LEVEL =~ /^[123]$/' + - when: on_success + if: '$SIMP_MATRIX_LEVEL =~ /^[123]$/ && $CI_COMMIT_MESSAGE !~ /^CI: (SKIP MATRIX|MATRIX LEVEL 0)/' + <<: *meets_spec_test_criteria + +# SIMP_MATRIX_LEVEL=2: Resource-heavy or redundant jobs +.with_SIMP_ACCEPTANCE_MATRIX_LEVEL_2: &with_SIMP_ACCEPTANCE_MATRIX_LEVEL_2 + rules: + - when: on_success + if: '$CI_COMMIT_MESSAGE =~ /^CI: MATRIX LEVEL [23]/' + - when: on_success + if: '$SIMP_FORCE_RUN_MATRIX == "yes" && $SIMP_MATRIX_LEVEL =~ /^[23]$/' + - when: on_success + if: '$SIMP_MATRIX_LEVEL =~ /^[23]$/ && $CI_COMMIT_MESSAGE !~ /^CI: (SKIP MATRIX|MATRIX LEVEL 0)/' + <<: *meets_acceptance_test_criteria + +.with_SIMP_SPEC_MATRIX_LEVEL_2: &with_SIMP_SPEC_MATRIX_LEVEL_2 + rules: + - when: on_success + if: '$CI_COMMIT_MESSAGE =~ /^CI: MATRIX LEVEL [23]/' + - when: on_success + if: '$SIMP_FORCE_RUN_MATRIX == "yes" && $SIMP_MATRIX_LEVEL =~ /^[23]$/' + - when: on_success + if: '$SIMP_MATRIX_LEVEL =~ /^[23]$/ && $CI_COMMIT_MESSAGE !~ /^CI: (SKIP MATRIX|MATRIX LEVEL 0)/' + <<: *meets_spec_test_criteria + +# SIMP_MATRIX_LEVEL=3: Reserved for FULL matrix testing +.with_SIMP_ACCEPTANCE_MATRIX_LEVEL_3: &with_SIMP_ACCEPTANCE_MATRIX_LEVEL_3 + rules: + - when: on_success + if: '$CI_COMMIT_MESSAGE =~ /^CI: MATRIX LEVEL 3/' + - when: on_success + if: '$SIMP_FORCE_RUN_MATRIX == "yes" && $SIMP_MATRIX_LEVEL == "3"' + - when: on_success + if: '$SIMP_MATRIX_LEVEL =~ /^3$/ && $CI_COMMIT_MESSAGE !~ /^CI: (SKIP MATRIX|MATRIX LEVEL 0)/' + <<: *meets_acceptance_test_criteria + # Puppet Versions #----------------------------------------------------------------------- @@ -69,10 +144,10 @@ variables: BEAKER_PUPPET_COLLECTION: 'puppet5' MATRIX_RUBY_VERSION: '2.4' -.pup_5_5_10: &pup_5_5_10 +.pup_5_5_17: &pup_5_5_17 image: 'ruby:2.4' variables: - PUPPET_VERSION: '5.5.10' + PUPPET_VERSION: '5.5.17' BEAKER_PUPPET_COLLECTION: 'puppet5' MATRIX_RUBY_VERSION: '2.4' @@ -83,6 +158,13 @@ variables: BEAKER_PUPPET_COLLECTION: 'puppet6' MATRIX_RUBY_VERSION: '2.5' +.pup_6_16_0: &pup_6_16_0 + image: 'ruby:2.5' + variables: + PUPPET_VERSION: '6.16.0' + BEAKER_PUPPET_COLLECTION: 'puppet6' + MATRIX_RUBY_VERSION: '2.5' + # Testing Environments #----------------------------------------------------------------------- @@ -99,6 +181,7 @@ variables: stage: 'validation' tags: ['docker'] <<: *setup_bundler_env + <<: *with_SIMP_SPEC_MATRIX_LEVEL_1 script: - 'bundle exec rake spec' @@ -106,11 +189,13 @@ variables: stage: 'acceptance' tags: ['beaker'] <<: *setup_bundler_env + <<: *with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1 .compliance_base: &compliance_base stage: 'compliance' tags: ['beaker'] <<: *setup_bundler_env + <<: *with_SIMP_ACCEPTANCE_MATRIX_LEVEL_1 # Pipeline / testing matrix @@ -149,38 +234,43 @@ pup5-unit: <<: *pup_5 <<: *unit_tests -pup5.5.10-unit: - <<: *pup_5_5_10 +pup5.5.17-unit: + <<: *pup_5_5_17 <<: *unit_tests pup6-unit: <<: *pup_6 <<: *unit_tests -# Acceptance tests +pup6.16.0-unit: + <<: *pup_6_16_0 + <<: *unit_tests + +# Repo-specific content # ============================================================================== -pup5.5.10: - <<: *pup_5_5_10 + +pup5.5.17: + <<: *pup_5_5_17 <<: *acceptance_base script: - 'bundle exec rake beaker:suites' -pup5.5.10-fips: - <<: *pup_5_5_10 +pup5.5.17-fips: + <<: *pup_5_5_17 <<: *acceptance_base script: - 'BEAKER_fips=yes bundle exec rake beaker:suites' -pup5.5.10-oel: - <<: *pup_5_5_10 +pup5.5.17-oel: + <<: *pup_5_5_17 <<: *acceptance_base script: - 'bundle exec rake beaker:suites[default,oel]' -pup5.5.10-oel-fips: - <<: *pup_5_5_10 +pup5.5.17-oel-fips: + <<: *pup_5_5_17 <<: *acceptance_base - <<: *only_with_SIMP_FULL_MATRIX + <<: *with_SIMP_ACCEPTANCE_MATRIX_LEVEL_3 script: - 'BEAKER_fips=yes bundle exec rake beaker:suites[default,oel]' @@ -195,3 +285,28 @@ pup6-fips: <<: *acceptance_base script: - 'BEAKER_fips=yes bundle exec rake beaker:suites' + +pup6.16.0: + <<: *pup_6_16_0 + <<: *acceptance_base + script: + - 'bundle exec rake beaker:suites' + +pup6.16.0-fips: + <<: *pup_6_16_0 + <<: *acceptance_base + script: + - 'BEAKER_fips=yes bundle exec rake beaker:suites' + +pup6.16.0-oel: + <<: *pup_6_16_0 + <<: *acceptance_base + script: + - 'bundle exec rake beaker:suites[default,oel]' + +pup6.16.0-oel-fips: + <<: *pup_6_16_0 + <<: *acceptance_base + <<: *with_SIMP_ACCEPTANCE_MATRIX_LEVEL_3 + script: + - 'BEAKER_fips=yes bundle exec rake beaker:suites[default,oel]' diff --git a/.travis.yml b/.travis.yml index fdf6dfc..df9f2a0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,28 +1,55 @@ # The testing matrix considers ruby/puppet versions supported by SIMP and PE: +# ------------------------------------------------------------------------------ +# Release Puppet Ruby EOL +# SIMP 6.4 5.5 2.4 TBD +# PE 2018.1 5.5 2.4 2020-11 (LTS) +# PE 2019.2 6.10 2.5 2019-08 (STS) # # https://puppet.com/docs/pe/2018.1/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 +# ============================================================================== +# +# Travis CI Repo options for this pipeline: +# +# Travis CI Env Var Type Notes +# --------------------- -------- ------------------------------------------- +# GITHUB_OAUTH_TOKEN Secure Required for automated GitHub releases +# PUPPETFORGE_API_TOKEN Secure Required for automated Forge releases +# SKIP_GITHUB_PUBLISH Optional Skips publishing GitHub releases if "true" +# SKIP_FORGE_PUBLISH Optional Skips publishing to Puppet Forge if "true" +# +# The secure env vars will be filtered in Travis CI log output, and aren't +# provided to untrusted builds (i.e, triggered by PR from another repository) +# # ------------------------------------------------------------------------------ -# Release Puppet Ruby EOL -# PE 2017.3 5.3 2.4.5 2018-12-31 -# SIMP 6.3 5.5 2.4.5 TBD*** -# PE 2018.1 5.5 2.4.5 2020-05 (LTS)*** -# PE 2019.0 6.0 2.5.1 2019-08-31^^^ # -# *** = Modules created for SIMP 6.3+ are not required to support Puppet < 5.5 -# ^^^ = SIMP doesn't support 6 yet; tests are info-only and allowed to fail - +# Travis CI Trigger options for this pipeline: +# +# To validate if $GITHUB_OAUTH_TOKEN is able to publish a GitHub release, +# trigger a custom Travis CI build for this branch using the CUSTOM CONFIG: +# +# env: VALIDATE_TOKENS=yes +# +# ------------------------------------------------------------------------------ +# +# Release Engineering notes: +# +# To automagically publish a release to GitHub and PuppetForge: +# +# - Set GITHUB_OAUTH_TOKEN and PUPPETFORGE_API_TOKEN as secure env variables +# in this repo's Travis CI settings +# - Push a git tag that matches the version in the module's `metadata.json` +# - The tag SHOULD be annotated with release notes, but nothing enforces this +# convention at present +# +# ------------------------------------------------------------------------------ --- + language: ruby cache: bundler -sudo: false - -stages: - - check - - spec - - name: deploy - if: 'tag IS present' +version: ~> 1.0 +os: linux bundler_args: --without development system_tests --path .vendor @@ -35,16 +62,29 @@ addons: - rpm before_install: + - for x in ${HOME}/.rvm/gems/*; do gem uninstall -I -x -i "${x}" -v '>= 1.17' bundler || true; gem uninstall -I -x -i "${x}@global" -v '>= 1.17' bundler || true; done + - gem install -v '~> 1.17' bundler - rm -f Gemfile.lock -global: - - STRICT_VARIABLES=yes +env: + global: + - 'FORGE_USER_AGENT="TravisCI-ForgeReleng-Script/0.3.3 (Purpose/forge-ops-for-${TRAVIS_REPO_SLUG})"' + +stages: + - name: 'validate tokens' + if: 'env(VALIDATE_TOKENS) = yes' + - name: check + if: 'NOT env(VALIDATE_TOKENS) = yes' + - name: spec + if: 'NOT env(VALIDATE_TOKENS) = yes' + - name: deploy + if: 'tag IS present AND NOT env(VALIDATE_TOKENS) = yes' jobs: include: - stage: check name: 'Syntax, style, and validation checks' - rvm: 2.4.5 + rvm: 2.4.9 env: PUPPET_VERSION="~> 5" script: - bundle exec rake check:dot_underscore @@ -57,75 +97,70 @@ jobs: - bundle exec puppet module build - stage: spec - name: 'Puppet 5.3 (PE 2017.3)' - rvm: 2.4.5 - env: PUPPET_VERSION="~> 5.3.0" -# commented out lines are for broken consul tests, which -# will be addressed in a separate ticket -# services: -# - docker -# - vagrant -# before_script: -# - spec/support/prep_ci.sh - script: - - bundle exec rake spec - - - stage: spec - rvm: 2.4.5 - name: 'Puppet 5.5 (SIMP 6.3, PE 2018.1)' + rvm: 2.4.9 + name: 'Puppet 5.5 (SIMP 6.4, PE 2018.1)' env: PUPPET_VERSION="~> 5.5.0" -# services: -# - docker -# - vagrant -# before_script: -# - spec/support/prep_ci.sh script: - bundle exec rake spec - stage: spec - name: 'Latest Puppet 5.x' - rvm: 2.4.5 + name: 'Puppet 5.x (Latest)' + rvm: 2.4.9 env: PUPPET_VERSION="~> 5.0" -# services: -# - docker -# - vagrant -# before_script: -# - spec/support/prep_ci.sh script: - bundle exec rake spec - stage: spec - name: 'Latest Puppet 6.x' - rvm: 2.5.1 - env: PUPPET_VERSION="~> 6.0" -# services: -# - docker -# - vagrant -# before_script: -# - spec/support/prep_ci.sh + name: 'Puppet 6.10 (PE 2019.2)' + rvm: 2.5.7 + env: PUPPET_VERSION="~> 6.10.0" script: - bundle exec rake spec - stage: deploy - rvm: 2.4.5 + rvm: 2.4.9 + env: PUPPET_VERSION="~> 5.5.0" script: - true before_deploy: - "export PUPMOD_METADATA_VERSION=`ruby -r json -e \"puts JSON.parse(File.read('metadata.json')).fetch('version')\"`" - '[[ $TRAVIS_TAG =~ ^simp-${PUPMOD_METADATA_VERSION}$|^${PUPMOD_METADATA_VERSION}$ ]]' - + - 'gem install -v "~> 5.5.0" puppet' + - 'git clean -f -x -d' + - 'puppet module build' + - 'find pkg -name ''*.tar.gz''' deploy: - - provider: releases - api_key: - secure: "i+u85G01GnlkMxA7lu9l/qiUPXufobrEplZ8D0zCxOW6ZnqbfAOFPyNSbCwywnqw0lSdmm4Pxj7ZQFQhkoAKAaIW1B9T/I4Zj+C4YBO43/VnM9DTiJVxD4zXIddTnFAHr7gkXIV/87YVPehk+9qrP9LnkUlVABNw4UfIphsrKKYcpiUCUCC+ckr8triMzkHQIPPQzwlFVkxn8GCgWAxSIvqxaSP6xPV2rXj8WHlIt2wQzdvK0LTJscrQN4dwcVTkm/76JIzgj6YmAbcnRZ7PFwuPraMKqMmzEk9JRNn4dPJXGzRWL+uUj+O3EuncqdcvglDDcDGRWxQMpSFL3r00jgF0vL6xvK6nFtEJZIAIQGCDvWLY6+AkHQ1LnbIGDh0JJjRm5OXj3J5k6F9byHGGt//lyjk2XkT4Ps+npwBjIJPu5bZ7yRw650NCt+5yTzq/aJcomiY88P2T7xU/wCVeiTZbCvMqrIL+BFbEGpKOFG709oT5rIS9q85DnF/D/7kwJvm2pGviKua50IhIG4/Z/tED0Wyprvc+G3c6KTpQkGpKkKJU5rG+DSGF1L52c13XLdW1me3jeaDbWMahWAFNjPd8jfF8EE7sO0bupQMxK6UAg/1qdLZ+h3Rxgo1t+v0Y9YjWKpVXOTJV/b2t2WipNa+UKK7LjB+ljpkiLjyGs3o=" + - provider: script skip_cleanup: true + script: 'curl -sS --fail -A "$FORGE_USER_AGENT" -H "Authorization: Bearer ${PUPPETFORGE_API_TOKEN}" -X POST -F "file=@$(find $PWD/pkg -name ''*.tar.gz'')" https://forgeapi.puppet.com/v3/releases' on: tags: true condition: '($SKIP_FORGE_PUBLISH != true)' - - provider: puppetforge - user: simp - password: - secure: "JJzYG4y54kvOS6utZpBKlUxRTKjjjeAViPD7/r8NKxvOhpPwXpWra7s9PuSka2EXL++5kDjeT7yIQa9vLSGW7FUwjC+mnpPuCvSP9vW8iTw18vrMjOfGMCJXS9IlOaZRL8vN+8BZ1tOxId8pwlakhrOVIHp9z7lew5Aa1rgH7aSaGFjPYe1lmdTlb1kodUJZJGwuToKBQJHchbcHq08tmaSx06Z7HcuG/Ali/y94o9m1IMeXyjXnV+GHcxFGCK60nQWNQB2DXZgQfl13/Eg3G5z1Xty8rPmW+zXSbqcDqpJtiqz3r9pcPb1tdvSLxz5OgVunLBWDBwUbHAL1RhldUIV1tV3Gm0HGhndrA5tWtNCE271mC7zp7c5CeX8YcAuxl4Fv87Zpit6MATsdweWTsYLxixBuorMdpa/H5zqHbxo8uc4frkaro4904474XSLXh3DwLzpUuNnUR7RXo37U07DimZWf4S1gr6MYHOutbZHHcTNV+BXo25heKgbL+0Ou72nQsEmoNVEm4LF0a4kRiG6EfwHWizXLCNlsEoZDZq+eyfmx/mOkpiXICYVorf5uPPnPL+GEwJ9Z0HRD0RYuqdgsfc6CxSUfkpwZtrdJZUzLB5osOWuqArj+J8E0WQ2dfNBHmydezaex2Se4tyELumM53utS5qW/N008Er4grCk=" + - provider: releases + token: $GITHUB_OAUTH_TOKEN on: tags: true - condition: '($SKIP_FORGE_PUBLISH != true)' + condition: '($SKIP_GITHUB_PUBLISH != true)' + + - stage: 'validate tokens' + language: shell + before_install: skip + install: skip + name: 'validate CI GitHub OAuth token has sufficient scope to release' + script: + - 'echo; echo "===== GITHUB_OAUTH_TOKEN validation";echo " (TRAVIS_SECURE_ENV_VARS=$TRAVIS_SECURE_ENV_VARS)"; echo' + - 'OWNER="$(echo $TRAVIS_REPO_SLUG | cut -d/ -f1)"' + - 'curl -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" + "https://api.github.com/users/$OWNER" + -I | grep ^X-OAuth-Scopes | egrep -w "repo|public_repo"' + + - stage: 'validate tokens' + name: 'validate CI Puppet Forge token authenticates with API' + language: shell + before_install: skip + install: skip + script: + - 'echo; echo "===== PUPPETFORGE_API_TOKEN validation"; echo " (TRAVIS_SECURE_ENV_VARS=$TRAVIS_SECURE_ENV_VARS)"; echo' + - 'curl -sS --fail -A "$FORGE_USER_AGENT" + -H "Authorization: Bearer ${PUPPETFORGE_API_TOKEN:-default_content_to_cause_401_response}" + https://forgeapi.puppet.com/v3/users > /dev/null' diff --git a/Gemfile b/Gemfile index 5977941..0eb52f2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,30 +1,48 @@ -gem_sources = ENV.fetch('GEM_SERVERS','https://rubygems.org').split(/[, ]+/) +gem_sources = ENV.fetch('GEM_SERVERS','https://rubygems.org').split(/[, ]+/) + +ENV['PDK_DISABLE_ANALYTICS'] ||= 'true' gem_sources.each { |gem_source| source gem_source } group :test do + puppet_version = ENV['PUPPET_VERSION'] || '~> 5.5' + major_puppet_version = puppet_version.scan(/(\d+)(?:\.|\Z)/).flatten.first.to_i gem 'rake' - gem 'puppet', ENV.fetch('PUPPET_VERSION', '~> 5.5') + gem 'puppet', puppet_version gem 'rspec' gem 'rspec-puppet' - gem 'puppet-strings' gem 'hiera-puppet-helper' gem 'puppetlabs_spec_helper' gem 'metadata-json-lint' + gem 'puppet-strings' gem 'puppet-lint-empty_string-check', :require => false gem 'puppet-lint-trailing_comma-check', :require => false - gem 'simp-rspec-puppet-facts', ENV.fetch('SIMP_RSPEC_PUPPET_FACTS_VERSION', '~> 2.3') - gem 'simp-rake-helpers', ENV.fetch('SIMP_RAKE_HELPERS_VERSION', '~> 5.8') + gem 'simp-rspec-puppet-facts', ENV['SIMP_RSPEC_PUPPET_FACTS_VERSION'] || '~> 3.1' + gem 'simp-rake-helpers', ENV['SIMP_RAKE_HELPERS_VERSION'] || ['> 5.11', '< 6'] + gem( 'pdk', ENV['PDK_VERSION'] || '~> 1.0', :require => false) if major_puppet_version > 5 end group :development do gem 'pry' - gem 'pry-doc' gem 'pry-byebug' + gem 'pry-doc' end group :system_tests do gem 'beaker' gem 'beaker-rspec' - gem 'simp-beaker-helpers', ENV.fetch('SIMP_BEAKER_HELPERS_VERSION', '~> 1.13') + gem 'simp-beaker-helpers', ENV['SIMP_BEAKER_HELPERS_VERSION'] || ['>= 1.18.7', '< 2'] +end + +# Evaluate extra gemfiles if they exist +extra_gemfiles = [ + ENV['EXTRA_GEMFILE'] || '', + "#{__FILE__}.project", + "#{__FILE__}.local", + File.join(Dir.home, '.gemfile'), +] +extra_gemfiles.each do |gemfile| + if File.file?(gemfile) && File.readable?(gemfile) + eval(File.read(gemfile), binding) + end end