edestecd / puppet-software

Puppet Module to install various Desktop Software
GNU General Public License v3.0
8 stars 7 forks source link

Convert to Puppet 4 conventions #9

Closed edestecd closed 6 years ago

edestecd commented 7 years ago

Use a puppetlabs module as an example and for god sakes use module sync!

bittner commented 7 years ago
$ pdk new module software

References

edestecd commented 7 years ago

Yea, I learned all about pdk at puppetconf! It looks nice and should solve some of our problems.

bittner commented 7 years ago

When you use PDK to generate an example Puppet module (e.g. pdk new module software) you can use the generated Gemfile with the generated Puppet version requirement. That will make pdk validate work immediately. I just tried it.

diff --git a/metadata.json b/metadata.json
index 1556c97..7bf2975 100644
--- a/metadata.json
+++ b/metadata.json
@@ -43,7 +43,7 @@
   "requirements": [
     {
       "name": "puppet",
-      "version_requirement": ">= 3.0.0 < 5.0.0"
+      "version_requirement": ">= 4.5.0 < 6.0.0"
     }
   ]
 }

The main complaint is "software not in autoload module layout", which goes away when I rename the puppet-software folder that I have cloned your repo into to just software. Then only a few validation complaints remain:

Linting

$ pdk validate
pdk (INFO): Running all available validators...
[✔] Checking metadata syntax (metadata.json tasks/*.json).
[✔] Checking module metadata style (metadata.json).
[✔] Checking Puppet manifest syntax (**/**.pp).
[✔] Checking Puppet manifest style (**/*.pp).
[✔] Checking Ruby code style (**/**.rb).
info: task-metadata-lint: ./: Target does not contain any files to validate (tasks/*.json).
warning: puppet-lint: manifests/social/skype.pp:37:33: arrow should be on the right operand's line
warning: puppet-lint: manifests/social/slack.pp:31:33: arrow should be on the right operand's line
warning: puppet-lint: manifests/virtualization/virtualbox.pp:48:33: arrow should be on the right operand's line
warning: puppet-lint: manifests/virtualization/virtualbox.pp:50:27: arrow should be on the right operand's line
warning: puppet-lint: manifests/editors/atom.pp:46:9: arrow should be on the right operand's line
warning: puppet-lint: manifests/editors/atom.pp:68:33: arrow should be on the right operand's line
warning: puppet-lint: manifests/browsers/chrome.pp:46:33: arrow should be on the right operand's line
warning: puppet-lint: manifests/drivers/lanier_mpc5503.pp:32:9: arrow should be on the right operand's line
warning: puppet-lint: manifests/storage/drive.pp:39:33: arrow should be on the right operand's line
warning: puppet-lint: manifests/utilities/iterm.pp:31:9: arrow should be on the right operand's line
warning: puppet-lint: manifests/utilities/alfred.pp:35:9: arrow should be on the right operand's line
warning: puppet-lint: manifests/utilities/alfred.pp:55:33: arrow should be on the right operand's line
warning: puppet-lint: manifests/utilities/controlplane.pp:31:9: arrow should be on the right operand's line
warning: puppet-lint: manifests/utilities/onyx.pp:30:11: arrow should be on the right operand's line

Tests

Tests work all out of the box: (A little more verbosity wouldn't hurt, but they all seem to be executed and pass.)

$ pdk test unit
[✔] Preparing to run the unit tests.
[✔] Running unit tests.
  Evaluated 165 tests in 5.57427871 seconds: 0 failures, 0 pending.
[✔] Cleaning up after running unit tests.

Travis CI

I have described in https://github.com/puppetlabs/pdk/issues/324#issuecomment-339023142 how to download and install PDK for CI builds. Afterwards, all there is to do, clearly, is run the two commands pdk validate and pdk test unit, and optionally silence stderr (as discussed in https://github.com/puppetlabs/pdk/issues/323).

bittner commented 6 years ago

NOTE: We're now using the mathow/centos-puppet-pdk Docker image for GitLab CI builds with PDK, as long as there is no official PDK Docker image yet, which is still in the making according to Puppetlabs officials:

# FILE: .gitlab-ci.yml

validate:
  stage: build
  image: mathow/centos-puppet-pdk
  script:
    - pdk validate 2> /dev/null

rspec:
  stage: test
  image: mathow/centos-puppet-pdk
  script:
    - pdk test unit 2> /dev/null
edestecd commented 6 years ago

very cool! Were also using gitlab ci with docker and this would be great!

bittner commented 6 years ago

I've now added a similar configuration for Travis to PR #15. Would you mind merging?