Skip to content

Instantly share code, notes, and snippets.

@cruelsmith
Last active September 6, 2023 18:31
Show Gist options
  • Save cruelsmith/3a5214730d1abb1ec4ebd3d01215c89f to your computer and use it in GitHub Desktop.
Save cruelsmith/3a5214730d1abb1ec4ebd3d01215c89f to your computer and use it in GitHub Desktop.
Puppet PDK 3.0 - manuell updated because puppetlabs/pdk-templates!524
---
stages:
- validation
- unit
default:
image: ruby
cache:
paths:
- vendor/bundle
.parallel_matrix:
parallel:
matrix:
- PUPPET_GEM_VERSION: ['~> 7']
RUBY_VERSION: ['2.7']
- PUPPET_GEM_VERSION: ['~> 8']
RUBY_VERSION: ['3.2']
image: ruby:${RUBY_VERSION}
cache:
key: "${CI_JOB_IMAGE}-Puppet ${PUPPET_GEM_VERSION}"
paths:
- vendor/bundle
before_script:
- rm -f Gemfile.lock || true
- ruby --version
- gem --version
- bundle -v
- bundle config set --local path 'vendor/bundle'
- bundle config set --local without 'system_tests'
- bundle config set --local jobs $(nproc)
- bundle install
- bundle clean
- bundle env
rules:
- if: $CI_COMMIT_TAG == null
'Puppet / validation':
extends: .parallel_matrix
stage: validation
script:
- bundle exec rake validate lint check rubocop
'Puppet / unit':
extends: .parallel_matrix
stage: unit
script:
- bundle exec rake parallel_spec
# This file can be used to customize the files managed by PDK.
#
# See https://github.com/puppetlabs/pdk-templates/blob/main/README.md
# for more information.
#
# See https://github.com/puppetlabs/pdk-templates/blob/main/config_defaults.yml
# for the default values.
---
Rakefile:
linter_fail_on_warnings: true
Gemfile:
optional:
':development':
- gem: 'puppet-strings' # needed since pdk has no auto reference for it
version: '>= 3.0.1'
@cruelsmith
Copy link
Author

cruelsmith commented Aug 22, 2023

Note that the .sync.yml is optional but i do like it when lint warnings will fail the job since else nobody will look at it.
When the puppet-strings gem is included the in the Gemfile the validate job will also check if the REFERNECE.md and will fail the job if it is outdated.

Run a pdk update to apply the changes of your .sync.yml.

💡 Note: Do not forget to remove all dropped feature files from puppetlabs/pdk-templates#510 that you will not maintain on your own and also not need:

rm -ir .devcontainer .editorconfig .gitpod.Dockerfile .gitpot.yml .travis.yml appveyor.yml

@cruelsmith
Copy link
Author

Revision 2 : Updated the .gitlab-ci.yaml to a parallel matrix setup for the validation and unit test. Make the code more readable, understandable and can easier be compared to github actions setups.

Revision 3: Added rules that prevent the GitLab CI to be run on tags. Per default in GitLab CI every event trigger create a pipeline. In the edge case where you push a commit and a tag pointing to the same commit GitLab would create to pipelines with the same content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment