Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix newline warning in updated spec_helper and improve pre-merge CI testing #100

Merged
merged 4 commits into from
May 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
---
sudo: false
dist: trusty
language: c
language: generic
before_install:
- wget https://apt.puppetlabs.com/puppet5-release-trusty.deb
- sudo dpkg -i puppet5-release-trusty.deb
- sudo apt-get -qq update
- sudo apt-get install pdk
script:
- '.travis/test_script.sh'
branches:
only:
- master
notifications:
email: false
hipchat:
rooms:
secure: pXZo1noFzXPz4PN+f2jNUjBGxRnv3TBFh6n673/Rp6GO0RVh1zOAv7udzR9Pj84kOfFnRVg8zH98GR8rNLXZkNWhrwxXKiF8YzZhDfdm9EXUW05LY9AfJUw0Sc8iqPqtawBNzAMQolXFOnCMdVCl481b3vsKVyyh9HvfNe3eOPvQs7TsTpcvUPZQvMptIUDEYJQYBOklDVFYoT/mzTYFOTmVTtfzif6orYfzxEeDgN1gy/OcS6Ben66tKS4rzpxTLxKjg8mTUsBlOpx0hOy9KXcGErSpYMiRTwpTsftO02+c5xANobF4tVt6c8uSicZZ0yTLZEAUnnT1F0L4L/DKVH5fygDNgqt8bBNE5jt4QXAWQqBeNP9gKHGSSn15eMrhGRWNpp8wxzDwgFQ1byHWR83TW0/uH2nVdqVKdwSV8QAyD/pd3F5wh7uCaHdJulsFkdgMh7fC9GvLaNbyxosTUNtDTFUO/UN1ZUsWPbBBz28mIx50iIp03oLbN4LrDbTJqRPZ+etPqYJ292FC8ifiRQI7V9zpNMcIBO26EgboeNTqE7GQ403tYMG/L5XdVhGl7tEBqfFCEIQBWwywDa5xTpBjBex0IGb0mqsdHJ1iK8Qy2yJwXIfcsFkIto0Hq65Zm+HvMm+1ep/v6DAsyYVmNbwDGj7hXBVC8WHyxejnxeM=
template:
- '%{repository}#%{build_number} (%{branch} - %{commit} : %{author}): %{message}
(<a href="%{build_url}">Details</a> | <a href="%{compare_url}">PR/Diff</a>)'
format: html
7 changes: 7 additions & 0 deletions .travis/fixtures/new_provider_sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
Gemfile:
optional:
':development':
- gem: 'puppet-resource_api'
spec/spec_helper.rb:
mock_with: ':rspec'
43 changes: 34 additions & 9 deletions .travis/test_script.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,40 @@
PR_DIR=$PWD
#!/bin/bash
set -x # echo commands with vars expanded
set -e # exit immediately on error

pdk new module pr_new_modules --template-url=$PR_DIR --skip-interview
TEMPLATE_PR_DIR=$PWD

pdk new module normal_module --skip-interview
cd normal_module
pdk convert --template-url=$PR_DIR --skip-interview --force
# This tricks PDK into testing this commit instead of whatever master is on this repo
git update-ref refs/heads/master "$TRAVIS_COMMIT"

pdk new module new_module --template-url="file://$TEMPLATE_PR_DIR" --skip-interview
pushd new_module
grep template < metadata.json
cp "$TEMPLATE_PR_DIR/.travis/fixtures/new_provider_sync.yml" ./.sync.yml
pdk update --force
pdk new class new_module
pdk new defined_type testtype
pdk new provider testprovider
pdk new task testtask
pdk validate
pdk test unit
popd

rm -f ~/.pdk/cache/answers.json

pdk new module convert_from_release_tag --skip-interview
pushd convert_from_release_tag
grep template < metadata.json
pdk convert --template-url="file://$TEMPLATE_PR_DIR" --skip-interview --force
cat convert_report.txt
popd

rm -f ~/.pdk/cache/answers.json

cd $PR_DIR
git clone --depth=1 --branch=master https://github.com/puppetlabs/pdk-templates.git ../master-pdk-templates
pdk new module pr_diff --template-url=$PR_DIR/../master-pdk-templates --skip-interview
cd pr_diff
pdk convert --template-url=$PR_DIR --skip-interview --force
pdk new module convert_from_master --template-url="file://$TEMPLATE_PR_DIR/../master-pdk-templates" --skip-interview
pushd convert_from_master
grep template < metadata.json
pdk convert --template-url="file://$TEMPLATE_PR_DIR" --skip-interview --force
cat convert_report.txt
popd
18 changes: 5 additions & 13 deletions moduleroot/spec/spec_helper.rb.erb
Original file line number Diff line number Diff line change
Expand Up @@ -45,22 +45,14 @@ RSpec.configure do |c|
<%- end -%>
end

def ensure_module_defined(name)
name_parts = name.split('::')

lastmod = Object

name_parts.each do |modname|
lastmod = if lastmod.const_defined?(modname)
lastmod.const_get(modname)
else
lastmod.const_set(modname, Module.new)
end
def ensure_module_defined(module_name)
module_name.split('::').reduce(Object) do |last_module, next_module|
last_module.const_set(next_module, Module.new) unless last_module.const_defined?(next_module)
last_module.const_get(next_module)
end

lastmod
end

# 'spec_overrides' from sync.yml will appear below this line
<%- [@configs['spec_overrides']].flatten.compact.each do |line| -%>
<%= line %>
<%- end -%>