poise-boiler 1.1.11 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c57f0874cd6f3de21e85242546d75f7697155947
4
- data.tar.gz: 45f94bce4cfea5c06202a51cdc09c04dddaaa26b
3
+ metadata.gz: 72e3c9430dc7859ededecfbd2c4ada39ec9e7434
4
+ data.tar.gz: bf5924d728d0f96841d5c0fa88594444666fac4a
5
5
  SHA512:
6
- metadata.gz: 59f322469323237e2b8069aecd7e2c37b50209f174593d4d530735d3a8520a1cb428e85ef5ed1914c3fc60528284ec946eb062fa974077d5f78bc91d40e2cd87
7
- data.tar.gz: 58ed212f372a7a488459f9d555c9b8fe7a206748c55688e138f589a043c76dcf287360b829430f1e0fadf07a0145ceee28f599ae301a98c44f2958a3136d3c3b
6
+ metadata.gz: 63e59107f784622d23f813785a6924e449aeb842f11496dfed5dc22e8156ab905f887b08dcfd39389aa20640640c14c0bd0cd4b408831c856e0952125fcd26a0
7
+ data.tar.gz: ab1c13de56d88922fb0a1a9f861d7e5ac5e5f6f9d63785be34bd52020622560915bcdd55cc2d58b10347b795eab464b4911cff197afb1f047245ea77c814bf3c
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## v1.2.0
4
+
5
+ * A full suite of release automation commands.
6
+ * Re-add the `travis` gem as a dependency now that it has removed the ancient
7
+ `pry` it depended on.
8
+ * Improved handling for setting test verbosity in a unified way.
9
+
3
10
  ## v1.1.11
4
11
 
5
12
  * Make sure `ss` is available on EL7 for `port` resources in Serverspec.
data/README.md CHANGED
@@ -46,6 +46,41 @@ and a `spec` task to run unit tests.
46
46
  require 'poise_boiler/rakefile'
47
47
  ```
48
48
 
49
+ ### Rake Tasks
50
+
51
+ #### `test`
52
+
53
+ Run all tests, specs, foodcritic, and kitchen.
54
+
55
+ #### `spec`
56
+
57
+ Run Rspec tests.
58
+
59
+ #### `badges`
60
+
61
+ Generate README badges for a project.
62
+
63
+ #### `debug`, `quiet`, `verbose`
64
+
65
+ Set the relevant mode environment variables. Can be abbreviated `d`, `q`, and `v`.
66
+
67
+ #### `check`
68
+
69
+ List uncommitted file changes and commits since the last release.
70
+
71
+ #### `checkall`
72
+
73
+ Run `quiet check` for all projects. This is specific to my folder layout and is
74
+ less likely to work for others.
75
+
76
+ #### `travis`
77
+
78
+ Run tests for Travis CI. This does some setup and then runs `rake test`.
79
+
80
+ #### `release`, `release:minor`, `release:major`
81
+
82
+ Create a new release and push toe RubyGems and Supermarket.
83
+
49
84
  ## `.kitchen.yml`
50
85
 
51
86
  The `.kitchen.yml` helper sets up a default driver and default values for
@@ -0,0 +1,126 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'git'
18
+
19
+ require 'halite/helper_base'
20
+
21
+
22
+ module PoiseBoiler
23
+ module Helpers
24
+ class Rake
25
+ # Helper methods for bumping gem versions.
26
+ #
27
+ # @api private
28
+ # @since 1.2.0
29
+ module BumpHelpers
30
+ VERSION_CONST = /(^\s*VERSION = ['"])([^'"]+)(['"]\s*$)/
31
+
32
+ def latest_tag
33
+ git = Git.open(base)
34
+ if git.tags.empty?
35
+ nil
36
+ else
37
+ tag_name = git.tags.last.name
38
+ if tag_name =~ /^v(.*)$/
39
+ $1
40
+ else
41
+ tag_name
42
+ end
43
+ end
44
+ end
45
+
46
+ def bumped_version(type: :patch, release: false)
47
+ current_version = latest_tag
48
+ next_version = if current_version
49
+ parts = current_version.split(/\./).map(&:to_i)
50
+ bump_index = {major: 0, minor: 1, patch: 2}[type]
51
+ parts[bump_index] += 1
52
+ (bump_index+1..2).each {|n| parts[n] = 0 }
53
+ parts.map(&:to_s).join('.')
54
+ else
55
+ '1.0.0'
56
+ end
57
+ # Release mode means plain, otherwise .pre.
58
+ if release
59
+ next_version
60
+ else
61
+ next_version + '.pre'
62
+ end
63
+ end
64
+
65
+ def find_version_rb
66
+ candidates = Dir[File.join(base, 'lib', '**', 'version.rb')]
67
+ candidates.min_by {|path| path.size }
68
+ end
69
+
70
+ def bump_version!(type: :patch, release: false, &block)
71
+ version_rb_path = find_version_rb
72
+ raise "Unable to find a version.rb in #{base}" unless version_rb_path
73
+ shell.say("Bumping version in #{version_rb_path}") if ENV['DEBUG']
74
+ content = IO.read(version_rb_path)
75
+ raise "Unable to find current version in #{version_rb_path}" unless VERSION_CONST =~ content
76
+ current_version = $2
77
+ version = bumped_version(type: type, release: release)
78
+ shell.say("Bumping gem version from #{current_version} to #{version}")
79
+ new_content = content.gsub(VERSION_CONST, "\\1#{version}\\3")
80
+ IO.write(version_rb_path, new_content)
81
+ begin
82
+ block.call if block
83
+ rescue Exception
84
+ # Restore the original version if anything goes wrong.
85
+ IO.write(version_rb_path, content)
86
+ raise
87
+ end
88
+ end
89
+ end
90
+
91
+ # Helper for a Rakefile to install tasks for bumping gem versions.
92
+ #
93
+ # @since 1.2.0
94
+ # @example Installing tasks
95
+ # require 'poise_boiler/helpers/rake/bump'
96
+ # PoiseBoiler::Helpers::Rake::Bump.install
97
+ # @example Bumping a patch version
98
+ # $ rake release:bump
99
+ # @example Bumping a minor version
100
+ # $ rake release:bump:minor
101
+ class Bump < Halite::HelperBase
102
+ include BumpHelpers
103
+
104
+ # Install the rake tasks.
105
+ #
106
+ # @return [void]
107
+ def install
108
+ # Delayed so that Rake doesn't need to be loaded to run this file.
109
+ extend ::Rake::DSL
110
+
111
+ task 'release:bump' do
112
+ bump_version!(type: :patch)
113
+ end
114
+
115
+ task 'release:bump:minor' do
116
+ bump_version!(type: :minor)
117
+ end
118
+
119
+ task 'release:bump:major' do
120
+ bump_version!(type: :major)
121
+ end
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,166 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'git'
18
+
19
+ require 'halite/helper_base'
20
+
21
+
22
+ module PoiseBoiler
23
+ module Helpers
24
+ class Rake
25
+ # Helper for a Rakefile to install tasks for checking the state of projects.
26
+ #
27
+ # @since 1.2.0
28
+ # @example Installing tasks
29
+ # require 'poise_boiler/helpers/rake/check'
30
+ # PoiseBoiler::Helpers::Rake::Check.install
31
+ # @example Checking the current project
32
+ # $ rake release:check
33
+ class Check < Halite::HelperBase
34
+ # Install the rake tasks.
35
+ #
36
+ # @return [void]
37
+ def install
38
+ # Delayed so that Rake doesn't need to be loaded to run this file.
39
+ extend ::Rake::DSL
40
+
41
+ desc 'Check for unreleased commits'
42
+ task 'release:check' do
43
+ check_project(base, summary: !!ENV['QUIET'])
44
+ end
45
+
46
+ desc 'Check for unreleased commits in all projects'
47
+ task 'release:checkall' do
48
+ base_path = File.expand_path(ENV['POISE_ROOT'] || '~/src')
49
+ Dir.foreach(base_path) do |entry|
50
+ next unless entry =~ /^(poise|application|halite)/
51
+ next if entry =~ /^(application_examples|poise-docker|poise-dash|poise\.io|poise-repomgr)/
52
+ path = File.join(base_path, entry)
53
+ next unless Dir.exist?(File.join(path, '.git'))
54
+ check_project(path, header: "# #{entry}", summary: !ENV['VERBOSE'])
55
+ end
56
+ end
57
+
58
+ # Aliases for less typing.
59
+ task 'check' => %w{release:check}
60
+ task 'checkall' => %w{release:checkall}
61
+ end
62
+
63
+ private
64
+
65
+ # Check a project for changes.
66
+ #
67
+ # @param path [String] Path to the project's git repository.
68
+ # @return [void]
69
+ def check_project(path, header: nil, summary: false)
70
+ git = Git.open(path)
71
+ # Some checks for repos that aren't full projects.
72
+ return unless git.branches['master']
73
+ return unless git.remote('origin').url
74
+ changed = check_changed_files(git)
75
+ commits = check_commits(git)
76
+ shell.say(header, :blue) unless !header || (changed.empty? && commits.empty?)
77
+ display_changed_files(changed, summary: summary) unless changed.empty?
78
+ display_commits(commits, summary: summary) unless commits.empty?
79
+ end
80
+
81
+ # Check for changed files, including new/untracked files.
82
+ #
83
+ # @params git [Git::Base] Git repository to operate on.
84
+ # @return [Array]
85
+ def check_changed_files(git)
86
+ git.status.select {|file| file.type || file.untracked }
87
+ end
88
+
89
+ # Display changed files.
90
+ #
91
+ # @params changed [Array] Output from {#check_changed_file}
92
+ # @return [void]
93
+ def display_changed_files(changed, summary: false)
94
+ shell.say("#{changed.size} file#{changed.size > 1 ? 's' : ''} with pending changes", :yellow)
95
+ return if summary
96
+ changed.each do |file|
97
+ color = if file.type == 'A' || file.untracked
98
+ :green
99
+ elsif file.type == 'D'
100
+ :red
101
+ end
102
+ shell.say("#{file.type || 'U'} #{file.path}", color)
103
+ end
104
+ end
105
+
106
+ # Check for any commits that are not part of a release. Unpushed commits
107
+ # are displayed in red.
108
+ #
109
+ # @params git [Git::Base] Git repository to operate on.
110
+ # @return [Array]
111
+ def check_commits(git)
112
+ # Find either the latest tag (release) or the first commit in the repo.
113
+ last_release = if git.tags.empty?
114
+ git.log.last
115
+ else
116
+ git.tags.last
117
+ end
118
+
119
+ # Find all commits since the last release that are not only version bumps.
120
+ commits = git.log.between(last_release.sha, 'master').select do |commit|
121
+ if commit.message !~ /^bump.*for/i
122
+ changed_files = commit.diff_parent.stats[:files].keys
123
+ if changed_files.size != 1 || changed_files.first !~ /lib\/.*\/version\.rb/
124
+ true
125
+ end
126
+ end
127
+ end
128
+
129
+ # Find all pushed commits since the last release.
130
+ pushed_commits = git.log.between(last_release.sha, 'origin/master').inject(Set.new) do |memo, commit|
131
+ memo << commit.sha
132
+ memo
133
+ end
134
+
135
+ commits.map {|commit| [commit, pushed_commits.include?(commit.sha), last_release] }
136
+ end
137
+
138
+ # Display commits.
139
+ #
140
+ # @params changed [Array] Output from {#check_commits}
141
+ # @return [void]
142
+ def display_commits(commits, summary: false)
143
+ unpushed_count = commits.inject(0) {|memo, (_, pushed)| memo + (pushed ? 0 : 1) }
144
+ shell.say("#{commits.size} commit#{commits.size > 1 ? 's' : ''} #{unpushed_count > 0 ? "(#{unpushed_count} unpushed) " : ''}since #{commits.first[2].name}", unpushed_count > 0 ? :red : :yellow)
145
+ return if summary
146
+ commits.each do |commit, pushed|
147
+ color = pushed ? nil : :red
148
+ message = commit.message.strip
149
+ if message.empty?
150
+ shell.say("* #{commit.sha}", color)
151
+ else
152
+ message_lines = commit.message.strip.split(/\n/)
153
+ first_line = message_lines.shift
154
+ shell.say("* #{first_line}", color)
155
+ # Filter down to only the first para and indent to match the '* '.
156
+ message_lines = message_lines.take_while {|line| !line.strip.empty? }.map! {|line| ' '+line }
157
+ shell.say(message_lines.join("\n"), color) unless message_lines.empty?
158
+ end
159
+ end
160
+
161
+ end
162
+
163
+ end
164
+ end
165
+ end
166
+ end
@@ -46,7 +46,7 @@ module PoiseBoiler
46
46
  t.rspec_opts = [].tap do |a|
47
47
  a << '--color'
48
48
  a << "--format #{ENV['CI'] ? 'documentation' : 'Fuubar'}"
49
- a << '--backtrace' if ENV['DEBUG']
49
+ a << '--backtrace' if ENV['VERBOSE'] || ENV['DEBUG']
50
50
  a << "--seed #{ENV['SEED']}" if ENV['SEED']
51
51
  a << "--tag #{args[:tag]}" if args[:tag]
52
52
  a << "--default-path test"
@@ -0,0 +1,71 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'halite/helper_base'
18
+
19
+
20
+ module PoiseBoiler
21
+ module Helpers
22
+ class Rake
23
+ # Helper for a Rakefile to install tasks for managing verbose/debug output.
24
+ #
25
+ # @since 1.2.0
26
+ # @example Installing tasks
27
+ # require 'poise_boiler/helpers/rake/debug'
28
+ # PoiseBoiler::Helpers::Rake::Debug.install
29
+ # @example Runng a task in verbose mode
30
+ # $ rake verbose release
31
+ # @example Runng a task in debug mode
32
+ # $ rake debug release
33
+ class Debug < Halite::HelperBase
34
+ # Install the rake tasks.
35
+ #
36
+ # @return [void]
37
+ def install
38
+ # Delayed so that Rake doesn't need to be loaded to run this file.
39
+ extend ::Rake::DSL
40
+
41
+ desc 'Run further tasks in verbose mode'
42
+ task 'verbose' do
43
+ ENV['VERBOSE'] = '1'
44
+ ENV['DEBUG'] = nil
45
+ ENV['QUIET'] = nil
46
+ end
47
+
48
+ desc 'Run further tasks in debug mode'
49
+ task 'debug' do
50
+ ENV['VERBOSE'] = '1'
51
+ ENV['DEBUG'] = '1'
52
+ ENV['QUIET'] = nil
53
+ end
54
+
55
+ desc 'Run further tasks in quiet mode'
56
+ task 'quiet' do
57
+ ENV['VERBOSE'] = nil
58
+ ENV['DEBUG'] = nil
59
+ ENV['QUIET'] = '1'
60
+ end
61
+
62
+ # Short alises.
63
+ task 'v' => %w{verbose}
64
+ task 'd' => %w{debug}
65
+ task 'q' => %w{quiet}
66
+ end
67
+
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,148 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'halite/helper_base'
18
+
19
+ require_relative 'bump'
20
+
21
+ module PoiseBoiler
22
+ module Helpers
23
+ class Rake
24
+ # Helper for a Rakefile to install tasks for managing verbose/debug output.
25
+ #
26
+ # @since 1.2.0
27
+ # @example Installing tasks
28
+ # require 'poise_boiler/helpers/rake/debug'
29
+ # PoiseBoiler::Helpers::Rake::Debug.install
30
+ # @example Runng a task in verbose mode
31
+ # $ rake verbose release
32
+ # @example Runng a task in debug mode
33
+ # $ rake debug release
34
+ class Release < Halite::HelperBase
35
+ include BumpHelpers
36
+
37
+ # Install the rake tasks.
38
+ #
39
+ # @return [void]
40
+ def install
41
+ # Delayed so that Rake doesn't need to be loaded to run this file.
42
+ extend ::Rake::DSL
43
+
44
+ # Rename the original release task.
45
+ release_task = ::Rake.application.lookup('release')
46
+ if release_task
47
+ release_actions = release_task.actions.dup
48
+ task 'release:original' => release_task.prerequisites.dup do
49
+ release_actions.map(&:call)
50
+ end
51
+ release_task.clear
52
+ end
53
+
54
+ # No-op Bundler's release:source_control_push task.
55
+ source_control_push_task = ::Rake.application.lookup('release:source_control_push')
56
+ source_control_push_task.clear if source_control_push_task
57
+
58
+ # Tag the release.
59
+ task 'release:tag' do
60
+ tag_release!(commit: false)
61
+ end
62
+
63
+ # Make the new release tasks.
64
+ desc "Bump, tag, and release #{gem_name}"
65
+ task 'release' do
66
+ release_gem!(:patch)
67
+ end
68
+
69
+ desc "Bump minor, tag, and release #{gem_name}"
70
+ task 'release:minor' do
71
+ release_gem!(:minor)
72
+ end
73
+
74
+ desc "Bump major, tag, and release #{gem_name}"
75
+ task 'release:major' do
76
+ release_gem!(:major)
77
+ end
78
+ end
79
+
80
+ private
81
+
82
+ def use_signed_tags?
83
+ !!sh('git config user.signingkey >/dev/null', verbose: false) {|ok, status| ok }
84
+ end
85
+
86
+ def find_current_version
87
+ version_rb = find_version_rb
88
+ if version_rb
89
+ (IO.read(version_rb) =~ Bump::VERSION_CONST) && $2
90
+ else
91
+ nil
92
+ end
93
+ end
94
+
95
+ def git_commit!(message)
96
+ sh(*['git', 'add', find_version_rb])
97
+ commit_cmd = ['git', 'commit', '-m', message]
98
+ sh(*commit_cmd)
99
+ end
100
+
101
+ def tag_release!(commit: true, &block)
102
+ # I can't use the gemspec because we might have changed the version.
103
+ current_version = find_current_version
104
+ unless current_version
105
+ raise "Unable to find current version of #{gem_name}"
106
+ end
107
+ if Gem::Version.create(current_version).prerelease?
108
+ raise "#{gem_name} has a prerelease version: #{current_version}"
109
+ end
110
+ unless File.exist?('CHANGELOG.md') && IO.read('CHANGELOG.md').include?("## v#{current_version}\n")
111
+ raise "No changelog entry found for #{current_version}"
112
+ end
113
+ answer = shell.ask("Are you certain you want to release #{gem_name} v#{current_version}?", limited_to: %w{y n})
114
+ if answer == 'n'
115
+ raise 'Aborting release'
116
+ end
117
+ git_commit!('Bump version for release.') if commit
118
+ tag_cmd = %w{git tag -a}
119
+ tag_cmd << '-s' if use_signed_tags?
120
+ tag_cmd.concat(['-m', "Release #{current_version}", "v#{current_version}"])
121
+ sh(*tag_cmd)
122
+ begin
123
+ block.call if block
124
+ rescue Exception
125
+ sh(*['git', 'tag', '-d', "v#{current_version}"])
126
+ raise
127
+ end
128
+ end
129
+
130
+ def release_gem!(bump_type)
131
+ ::Rake::Task['release:guard_clean'].invoke
132
+ bump_version!(type: bump_type, release: true) do
133
+ tag_release! do
134
+ # Run this as a subproc so it reloads the gemspec. Probably not
135
+ # as reliable as invoke, but safer.
136
+ sh(*['rake', 'release:original'], verbose: false)
137
+ end
138
+ end
139
+ bump_version!(type: :patch)
140
+ git_commit!('Bump version for dev.')
141
+ sh(*['git', 'push'])
142
+ sh(*['git', 'push', '--tags'])
143
+ end
144
+
145
+ end
146
+ end
147
+ end
148
+ end
@@ -27,7 +27,11 @@ module PoiseBoiler
27
27
  # @see Travis
28
28
  class Rake < Halite::HelperBase
29
29
  autoload :Badges, 'poise_boiler/helpers/rake/badges'
30
+ autoload :Bump, 'poise_boiler/helpers/rake/bump'
31
+ autoload :Check, 'poise_boiler/helpers/rake/check'
30
32
  autoload :Core, 'poise_boiler/helpers/rake/core'
33
+ autoload :Debug, 'poise_boiler/helpers/rake/debug'
34
+ autoload :Release, 'poise_boiler/helpers/rake/release'
31
35
  autoload :Travis, 'poise_boiler/helpers/rake/travis'
32
36
 
33
37
  # Install all rake tasks.
@@ -36,6 +40,10 @@ module PoiseBoiler
36
40
  def install
37
41
  Core.install(gem_name: gem_name, base: base, **options)
38
42
  Badges.install(gem_name: gem_name, base: base, **options)
43
+ Bump.install(gem_name: gem_name, base: base, **options)
44
+ Check.install(gem_name: gem_name, base: base, **options)
45
+ Debug.install(gem_name: gem_name, base: base, **options)
46
+ Release.install(gem_name: gem_name, base: base, **options)
39
47
  Travis.install(gem_name: gem_name, base: base, **options)
40
48
  end
41
49
  end
@@ -72,6 +72,10 @@ module PoiseBoiler
72
72
  config.include Halite::SpecHelper(gem_name ? gemspec : nil)
73
73
  # Hide the spec helper from RSpec traces by default.
74
74
  config.backtrace_exclusion_patterns << %r{/halite/spec_helper}
75
+ # In verbose mode, set Chef to log level debug by default.
76
+ if ENV['DEBUG']
77
+ config.before { chefspec_options[:log_level] ||= :debug }
78
+ end
75
79
  end
76
80
  end
77
81
  end # /def install
@@ -15,7 +15,6 @@
15
15
  #
16
16
 
17
17
  require 'kitchen'
18
- require 'kitchen-sync'
19
18
 
20
19
 
21
20
  module PoiseBoiler
@@ -89,8 +88,8 @@ module PoiseBoiler
89
88
  # Run some installs at provision so they are cached in the image.
90
89
  # Install net-tools for netstat which is used by serverspec, and
91
90
  # iproute for ss (only used on EL7).
92
- "test ! -f /etc/debian_version || apt-get install -y net-tools",
93
- "test ! -f /etc/redhat-release || yum -y install net-tools iproute",
91
+ "test ! -f /etc/debian_version || apt-get install -y net-tools rsync",
92
+ "test ! -f /etc/redhat-release || yum -y install net-tools iproute rsync",
94
93
  # Make sure the hostname utilitiy is installed on CentOS 7. The
95
94
  # ||true is for EL6 which has no hostname package. Sigh.
96
95
  "test ! -f /etc/redhat-release || yum -y install hostname || true",
@@ -106,6 +105,14 @@ module PoiseBoiler
106
105
  'name' => 'sftp',
107
106
  'ssh_key' => docker_enabled ? File.expand_path('.kitchen/docker_id_rsa', root) : nil,
108
107
  },
108
+ 'provisioner' => {
109
+ 'attributes' => {
110
+ 'POISE_DEBUG' => !!((ENV['POISE_DEBUG'] && ENV['POISE_DEBUG'] != 'false') ||
111
+ (ENV['poise_debug'] && ENV['poise_debug'] != 'false') ||
112
+ (ENV['DEBUG'] && ENV['DEBUG'] != 'false')
113
+ ),
114
+ },
115
+ },
109
116
  'platforms' => expand_kitchen_platforms(platforms).map {|p| platform_definition(p) },
110
117
  }.to_yaml.gsub(/---[ \n]/, '')
111
118
  end
@@ -16,5 +16,5 @@
16
16
 
17
17
 
18
18
  module PoiseBoiler
19
- VERSION = '1.1.11'
19
+ VERSION = '1.2.0'
20
20
  end
data/poise-boiler.gemspec CHANGED
@@ -37,13 +37,14 @@ Gem::Specification.new do |spec|
37
37
  # Development gems
38
38
  spec.add_dependency 'addressable', '~> 2.3'
39
39
  spec.add_dependency 'rake', '~> 10.4'
40
- # spec.add_dependency 'travis', '~> 1.8'
40
+ spec.add_dependency 'travis', '~> 1.8', '>= 1.8.1'
41
41
  spec.add_dependency 'yard', '~> 0.8'
42
42
  spec.add_dependency 'yard-classmethods', '~> 1.0'
43
43
  spec.add_dependency 'halite', '~> 1.0' # This is a circular dependency
44
44
  spec.add_dependency 'mixlib-shellout', '>= 1.4', '< 3.0' # Chef 11 means shellout 1.4 :-(
45
- spec.add_dependency 'pry' # Travis depends on old-ass pry, see https://github.com/travis-ci/travis.rb/issues/245
45
+ spec.add_dependency 'pry'
46
46
  spec.add_dependency 'pry-byebug'
47
+ spec.add_dependency 'git', '~> 1.2'
47
48
 
48
49
  # Test gems
49
50
  spec.add_dependency 'rspec', '~> 3.2'
@@ -58,7 +59,7 @@ Gem::Specification.new do |spec|
58
59
  spec.add_dependency 'kitchen-vagrant'
59
60
  spec.add_dependency 'vagrant-wrapper'
60
61
  spec.add_dependency 'kitchen-docker'
61
- spec.add_dependency 'kitchen-sync', '~> 1.1'
62
+ spec.add_dependency 'kitchen-sync', '~> 2.0'
62
63
  spec.add_dependency 'berkshelf', '~> 4.0'
63
64
 
64
65
  # Travis gems
File without changes
@@ -0,0 +1,100 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'spec_helper'
18
+
19
+ describe PoiseBoiler::Helpers::Rake::Bump do
20
+ rakefile "require 'poise_boiler/helpers/rake/bump'\nPoiseBoiler::Helpers::Rake::Bump.install"
21
+ before { command('git init && git config user.email "you@example.com" && git config user.name "Your Name" && git add Rakefile && git commit -m "first commit" && git tag -a v2.3.4 -m "Release 2.3.4"') }
22
+ file 'lib/mygem/version.rb', <<-EOH
23
+ module MyGem
24
+ VERSION = '1.0.0.pre'
25
+ end
26
+ EOH
27
+ def file_content
28
+ IO.read(File.join(temp_path, 'lib/mygem/version.rb'))
29
+ end
30
+
31
+ describe 'release:bump' do
32
+ rake_task 'release:bump'
33
+
34
+ it { is_expected.to eq "Bumping gem version from 1.0.0.pre to 2.3.5.pre\n" }
35
+ it { subject; expect(file_content).to eq <<-EOH }
36
+ module MyGem
37
+ VERSION = '2.3.5.pre'
38
+ end
39
+ EOH
40
+ end # /describe release:bump
41
+
42
+ describe 'release:bump:minor' do
43
+ rake_task 'release:bump:minor'
44
+
45
+ it { is_expected.to eq "Bumping gem version from 1.0.0.pre to 2.4.0.pre\n" }
46
+ it { subject; expect(file_content).to eq <<-EOH }
47
+ module MyGem
48
+ VERSION = '2.4.0.pre'
49
+ end
50
+ EOH
51
+ end # /describe release:bump:minor
52
+
53
+ describe 'release:bump:major' do
54
+ rake_task 'release:bump:major'
55
+
56
+ it { is_expected.to eq "Bumping gem version from 1.0.0.pre to 3.0.0.pre\n" }
57
+ it { subject; expect(file_content).to eq <<-EOH }
58
+ module MyGem
59
+ VERSION = '3.0.0.pre'
60
+ end
61
+ EOH
62
+ end # /describe release:bump:major
63
+
64
+ describe '#bumped_version' do
65
+ let(:instance) { described_class.new(gem_name: 'test') }
66
+ let(:bump_type) { :patch }
67
+ let(:bump_release) { false }
68
+ let(:bump_current) { nil }
69
+ subject { instance.send(:bumped_version, type: bump_type, release: bump_release) }
70
+ before do
71
+ allow(instance).to receive(:latest_tag).and_return(bump_current)
72
+ end
73
+
74
+ context 'with no existing version' do
75
+ it { is_expected.to eq '1.0.0.pre' }
76
+ end # /context with no existing version
77
+
78
+ context 'with release mode' do
79
+ let(:bump_release) { true }
80
+ it { is_expected.to eq '1.0.0' }
81
+ end # /context with release mode
82
+
83
+ context 'with 1.2.3 and patch' do
84
+ let(:bump_current) { '1.2.3' }
85
+ it { is_expected.to eq '1.2.4.pre' }
86
+ end # /context with 1.2.3 and patch
87
+
88
+ context 'with 1.2.3 and minor' do
89
+ let(:bump_type) { :minor }
90
+ let(:bump_current) { '1.2.3' }
91
+ it { is_expected.to eq '1.3.0.pre' }
92
+ end # /context with 1.2.3 and minor
93
+
94
+ context 'with 1.2.3 and major' do
95
+ let(:bump_type) { :major }
96
+ let(:bump_current) { '1.2.3' }
97
+ it { is_expected.to eq '2.0.0.pre' }
98
+ end # /context with 1.2.3 and major
99
+ end # /describe #bumped_version
100
+ end
@@ -0,0 +1,123 @@
1
+ #
2
+ # Copyright 2015, Noah Kantrowitz
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ #
16
+
17
+ require 'spec_helper'
18
+
19
+ describe PoiseBoiler::Helpers::Rake::Check do
20
+ rakefile "require 'poise_boiler/helpers/rake/check'\nPoiseBoiler::Helpers::Rake::Check.install"
21
+ CHECK_INITIALIZER = 'git init && git config user.email "you@example.com" && git config user.name "Your Name" && git add main.rb Rakefile && git commit -m "first commit" && git tag -a v1.0.0 -m "Release 1.0.0" && git remote add origin http://example.com/ && git branch -f origin/master'
22
+
23
+ describe 'check' do
24
+ rake_task 'release:check'
25
+ file 'main.rb'
26
+ before { command(CHECK_INITIALIZER) }
27
+
28
+ context 'with no files' do
29
+ its(:stdout) { is_expected.to eq '' }
30
+ end # /context with no files
31
+
32
+ context 'with an uncommitted file' do
33
+ file 'other.rb'
34
+
35
+ its(:stdout) { is_expected.to eq "1 file with pending changes\nU other.rb\n" }
36
+ end # /context with an uncommitted file
37
+
38
+ context 'with a new file' do
39
+ file 'other.rb'
40
+ before { command('git add other.rb') }
41
+
42
+ its(:stdout) { is_expected.to eq "1 file with pending changes\nA other.rb\n" }
43
+ end # /context with a new file
44
+
45
+ context 'with a modified file' do
46
+ file 'main.rb', 'content'
47
+
48
+ its(:stdout) { is_expected.to eq "1 file with pending changes\nM main.rb\n" }
49
+ end # /context with a modified file
50
+
51
+ context 'with a deleted file' do
52
+ before { command('rm main.rb') }
53
+
54
+ its(:stdout) { is_expected.to eq "1 file with pending changes\nD main.rb\n" }
55
+ end # /context with a deleted file
56
+
57
+ context 'with multiple files' do
58
+ file 'main.rb', 'content'
59
+ file 'other.rb'
60
+
61
+ its(:stdout) { is_expected.to eq "2 files with pending changes\nM main.rb\nU other.rb\n" }
62
+ end # /context with multiple files
63
+
64
+ context 'with a new commit' do
65
+ file 'other.rb'
66
+ before { command('git add other.rb && git commit -m "second commit" && git branch -f origin/master') }
67
+
68
+ its(:stdout) { is_expected.to eq "1 commit since v1.0.0\n* second commit\n" }
69
+ end # /context with a new commit
70
+
71
+ context 'with an unpushed commit' do
72
+ file 'other.rb'
73
+ before { command('git add other.rb && git commit -m "second commit"') }
74
+
75
+ its(:stdout) { is_expected.to eq "1 commit (1 unpushed) since v1.0.0\n* second commit\n" }
76
+ end # /context with an unpushed commit
77
+
78
+ context 'with multiple commits' do
79
+ file 'other.rb'
80
+ file 'third.rb'
81
+ before { command('git add other.rb && git commit -m "second commit" && git add third.rb && git commit -m "moar commits" && git branch -f origin/master') }
82
+
83
+ its(:stdout) { is_expected.to eq "2 commits since v1.0.0\n* moar commits\n* second commit\n" }
84
+ end # /context with multiple commits
85
+
86
+ context 'with quiet mode' do
87
+ file 'other.rb'
88
+ file 'third.rb'
89
+ before { command('git add other.rb && git commit -m "second commit" && git add third.rb') }
90
+ environment QUIET: 1
91
+
92
+ its(:stdout) { is_expected.to eq "1 file with pending changes\n1 commit (1 unpushed) since v1.0.0\n" }
93
+ end # /context with quiet mode
94
+ end # /describe check
95
+
96
+ describe 'checkall' do
97
+ rake_task 'release:checkall'
98
+ file 'poise/Rakefile'
99
+ file 'poise/main.rb'
100
+ before { command(CHECK_INITIALIZER, cwd: File.join(temp_path, 'poise')) }
101
+ around do |ex|
102
+ begin
103
+ ENV['POISE_ROOT'] = temp_path
104
+ ex.run
105
+ ensure
106
+ ENV['POISE_ROOT'] = nil
107
+ end
108
+ end
109
+
110
+ context 'with one changed repo' do
111
+ file 'poise/other.rb'
112
+
113
+ its(:stdout) { is_expected.to eq "# poise\n1 file with pending changes\n" }
114
+ end # /context with one changed repo
115
+
116
+ context 'with verbose mode' do
117
+ file 'poise/other.rb'
118
+ environment VERBOSE: 1
119
+
120
+ its(:stdout) { is_expected.to eq "# poise\n1 file with pending changes\nU other.rb\n" }
121
+ end # /context with verbose mode
122
+ end # /describe checkall
123
+ end
@@ -17,7 +17,7 @@
17
17
  require 'spec_helper'
18
18
 
19
19
  describe 'poise_boiler/rake' do
20
- file 'Rakefile', 'require "poise_boiler/rakefile"'
20
+ file 'Rakefile', 'require "poise_boiler/rake"'
21
21
  file 'test.gemspec', <<-EOH
22
22
  Gem::Specification.new do |spec|
23
23
  spec.name = 'test'
@@ -35,6 +35,11 @@ EOH
35
35
  its(:stdout) { is_expected.to include('rake release') }
36
36
  its(:stdout) { is_expected.to include('rake spec') }
37
37
  its(:stdout) { is_expected.to include('rake travis') }
38
+ its(:stdout) { is_expected.to include('rake debug') }
39
+ its(:stdout) { is_expected.to include('rake quiet') }
40
+ its(:stdout) { is_expected.to include('rake verbose') }
41
+ its(:stdout) { is_expected.to include('rake release:check') }
42
+ its(:stdout) { is_expected.to include('rake release:checkall') }
38
43
  end # /describe list of tasks
39
44
 
40
45
  describe 'specs in spec/' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: poise-boiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.11
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Noah Kantrowitz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-26 00:00:00.000000000 Z
11
+ date: 2016-01-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -38,6 +38,26 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: travis
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 1.8.1
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '1.8'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 1.8.1
41
61
  - !ruby/object:Gem::Dependency
42
62
  name: yard
43
63
  requirement: !ruby/object:Gem::Requirement
@@ -128,6 +148,20 @@ dependencies:
128
148
  - - ">="
129
149
  - !ruby/object:Gem::Version
130
150
  version: '0'
151
+ - !ruby/object:Gem::Dependency
152
+ name: git
153
+ requirement: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - "~>"
156
+ - !ruby/object:Gem::Version
157
+ version: '1.2'
158
+ type: :runtime
159
+ prerelease: false
160
+ version_requirements: !ruby/object:Gem::Requirement
161
+ requirements:
162
+ - - "~>"
163
+ - !ruby/object:Gem::Version
164
+ version: '1.2'
131
165
  - !ruby/object:Gem::Dependency
132
166
  name: rspec
133
167
  requirement: !ruby/object:Gem::Requirement
@@ -274,14 +308,14 @@ dependencies:
274
308
  requirements:
275
309
  - - "~>"
276
310
  - !ruby/object:Gem::Version
277
- version: '1.1'
311
+ version: '2.0'
278
312
  type: :runtime
279
313
  prerelease: false
280
314
  version_requirements: !ruby/object:Gem::Requirement
281
315
  requirements:
282
316
  - - "~>"
283
317
  - !ruby/object:Gem::Version
284
- version: '1.1'
318
+ version: '2.0'
285
319
  - !ruby/object:Gem::Dependency
286
320
  name: berkshelf
287
321
  requirement: !ruby/object:Gem::Requirement
@@ -366,7 +400,11 @@ files:
366
400
  - lib/poise_boiler/helpers.rb
367
401
  - lib/poise_boiler/helpers/rake.rb
368
402
  - lib/poise_boiler/helpers/rake/badges.rb
403
+ - lib/poise_boiler/helpers/rake/bump.rb
404
+ - lib/poise_boiler/helpers/rake/check.rb
369
405
  - lib/poise_boiler/helpers/rake/core.rb
406
+ - lib/poise_boiler/helpers/rake/debug.rb
407
+ - lib/poise_boiler/helpers/rake/release.rb
370
408
  - lib/poise_boiler/helpers/rake/travis.rb
371
409
  - lib/poise_boiler/helpers/spec_helper.rb
372
410
  - lib/poise_boiler/kitchen.rb
@@ -376,12 +414,14 @@ files:
376
414
  - lib/poise_boiler/spec_helper.rb
377
415
  - lib/poise_boiler/version.rb
378
416
  - poise-boiler.gemspec
379
- - spec/helpers/badge_spec.rb
380
- - spec/helpers/travis_spec.rb
417
+ - spec/helpers/rake/badge_spec.rb
418
+ - spec/helpers/rake/bump_spec.rb
419
+ - spec/helpers/rake/check_spec.rb
420
+ - spec/helpers/rake/travis_spec.rb
421
+ - spec/helpers/rake_spec.rb
422
+ - spec/helpers/spec_helper_spec.rb
381
423
  - spec/kitchen_spec.rb
382
- - spec/rakefile_spec.rb
383
424
  - spec/spec_helper.rb
384
- - spec/spec_helper_spec.rb
385
425
  homepage: https://github.com/poise/poise-boiler
386
426
  licenses:
387
427
  - Apache 2.0
@@ -408,10 +448,12 @@ signing_key:
408
448
  specification_version: 4
409
449
  summary: Boilerplate-reduction helpers for Poise/Halite-style gemss.
410
450
  test_files:
411
- - spec/helpers/badge_spec.rb
412
- - spec/helpers/travis_spec.rb
451
+ - spec/helpers/rake/badge_spec.rb
452
+ - spec/helpers/rake/bump_spec.rb
453
+ - spec/helpers/rake/check_spec.rb
454
+ - spec/helpers/rake/travis_spec.rb
455
+ - spec/helpers/rake_spec.rb
456
+ - spec/helpers/spec_helper_spec.rb
413
457
  - spec/kitchen_spec.rb
414
- - spec/rakefile_spec.rb
415
458
  - spec/spec_helper.rb
416
- - spec/spec_helper_spec.rb
417
459
  has_rdoc: