puppetlabs / control-repo

A control repository template
Apache License 2.0
204 stars 510 forks source link

Add validation and test configuration #52

Open bittner opened 6 years ago

bittner commented 6 years ago

As proposed in https://github.com/puppetlabs/pdk/issues/333 this repository should serve as a default setup for control repositories generated by PDK.

Hence, we should add a Gemfile, .gitignore, .rubocop.yml (and optionally proposed CI configuration and other files?) that allow running validation and testing in a simple fashion via PDK (see below). Sample files are included in the Puppet Labs pdk-module-template repository.

Example Workflow (PDK)

# create control repo
$ pdk new control
# run static analysis tools
$ pdk validate
# run tests
$ pdk test unit
bschonec commented 4 months ago

How about adding some simple spec test examples? I'm stumped as to how to add spec testing to my control-repo as the manifest aren't in 'standard' locations.

garrettrowell commented 4 months ago

@bschonec generally speaking when spec testing in a control-repo there are two paths to choose from:

Personally, I prefer going the onceover route over the 'roll your own' approach. With that being said I've implemented it both ways before.

Going back to your previous comment, I do find value leveraging the pdk in this scenario as well.

Any files that you don't want the pdk to add in can always be removed by adding something along the lines of this (picking on appveyor):

appveyor.yml:
  delete: true

to a .sync.yml file before running a pdk convert or if this has already been done running pdk update.

If using the pdk I also recommend setting the PDK_FEATURE_FLAGS=controlrepo environment variable, and using the latest version of the pdk.

To leverage onceover a .sync.yml file might look similar to this:

Gemfile:
  optional:
    ':development':
      - gem: 'onceover'
Rakefile:
  requires:
    - require: 'onceover/rake_tasks'
      conditional: "Gem.loaded_specs.key? 'onceover'"
.fixtures.yml:
  unmanaged: true
spec/spec_helper.rb:
  delete: true
.gitignore:
  paths:
    - '.onceover'

We do also have a community slack: https://slack.puppet.com/

There's a testing channel which would be the best place for queries such as this, or if you'd prefer feel free to DM me :)