stove 1.1.2 → 2.0.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +1 -2
  3. data/CHANGELOG.md +16 -0
  4. data/README.md +41 -29
  5. data/Rakefile +15 -0
  6. data/bin/bake +1 -2
  7. data/features/actions/bump.feature +22 -0
  8. data/features/actions/changelog.feature +45 -0
  9. data/features/actions/dev.feature +18 -0
  10. data/features/actions/upload.feature +48 -0
  11. data/features/plugins/git.feature +24 -0
  12. data/features/rake.feature +1 -2
  13. data/features/step_definitions/cli_steps.rb +1 -27
  14. data/features/step_definitions/{community_site_steps.rb → community_steps.rb} +9 -5
  15. data/features/step_definitions/config_steps.rb +24 -0
  16. data/features/step_definitions/cookbook_steps.rb +28 -6
  17. data/features/step_definitions/cucumber_steps.rb +12 -0
  18. data/features/step_definitions/git_steps.rb +10 -7
  19. data/features/support/env.rb +12 -28
  20. data/features/support/stove/git.rb +48 -0
  21. data/lib/stove.rb +102 -19
  22. data/lib/stove/actions/base.rb +21 -0
  23. data/lib/stove/actions/bump.rb +25 -0
  24. data/lib/stove/actions/changelog.rb +71 -0
  25. data/lib/stove/actions/dev.rb +22 -0
  26. data/lib/stove/actions/finish.rb +8 -0
  27. data/lib/stove/actions/start.rb +7 -0
  28. data/lib/stove/actions/upload.rb +27 -0
  29. data/lib/stove/cli.rb +107 -79
  30. data/lib/stove/community.rb +124 -0
  31. data/lib/stove/config.rb +62 -13
  32. data/lib/stove/cookbook.rb +76 -238
  33. data/lib/stove/cookbook/metadata.rb +16 -11
  34. data/lib/stove/error.rb +13 -107
  35. data/lib/stove/filter.rb +59 -0
  36. data/lib/stove/jira.rb +74 -30
  37. data/lib/stove/middlewares/chef_authentication.rb +60 -0
  38. data/lib/stove/middlewares/exceptions.rb +17 -0
  39. data/lib/stove/mixins/filterable.rb +11 -0
  40. data/lib/stove/mixins/insideable.rb +13 -0
  41. data/lib/stove/mixins/instanceable.rb +23 -0
  42. data/lib/stove/mixins/loggable.rb +32 -0
  43. data/lib/stove/mixins/optionable.rb +41 -0
  44. data/lib/stove/mixins/validatable.rb +7 -0
  45. data/lib/stove/packager.rb +23 -22
  46. data/lib/stove/plugins/base.rb +35 -0
  47. data/lib/stove/plugins/git.rb +71 -0
  48. data/lib/stove/plugins/github.rb +108 -0
  49. data/lib/stove/plugins/jira.rb +72 -0
  50. data/lib/stove/rake_task.rb +56 -37
  51. data/lib/stove/runner.rb +84 -0
  52. data/lib/stove/util.rb +56 -0
  53. data/lib/stove/validator.rb +67 -0
  54. data/lib/stove/version.rb +1 -1
  55. data/locales/en.yml +231 -0
  56. data/stove.gemspec +11 -11
  57. metadata +85 -67
  58. data/features/changelog.feature +0 -22
  59. data/features/cli.feature +0 -11
  60. data/features/devodd.feature +0 -19
  61. data/features/git.feature +0 -34
  62. data/features/upload.feature +0 -40
  63. data/lib/stove/community_site.rb +0 -85
  64. data/lib/stove/formatter.rb +0 -7
  65. data/lib/stove/formatter/base.rb +0 -32
  66. data/lib/stove/formatter/human.rb +0 -9
  67. data/lib/stove/formatter/silent.rb +0 -10
  68. data/lib/stove/git.rb +0 -82
  69. data/lib/stove/github.rb +0 -43
  70. data/lib/stove/logger.rb +0 -56
  71. data/lib/stove/uploader.rb +0 -64
  72. data/spec/support/community_site.rb +0 -33
  73. data/spec/support/git.rb +0 -52
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fb680ed6abba285ad793a197007f945ff29c3325
4
- data.tar.gz: 3eb82731cdbdd0f27ad30f5cc1eb0afe05480a41
3
+ metadata.gz: 9e3e8effc89249cc85ef1bbb409edc1b17ae623b
4
+ data.tar.gz: a01bd5570bc5651d738a5e31c36ed032e3ce1c75
5
5
  SHA512:
6
- metadata.gz: 3d9ca773a3064120898b78d89c96c195bdaee6a687261238d3f813dafba37507c704199e0d15ff146403ab4f750db8c33971c6e844987bfba16d0ca91e74e343
7
- data.tar.gz: f410e99c3a7de4ed4684840fc42889b708d997c9d3cf7ea4649042c201fe13544ef475adf3488b2a137821ed767dad76c64ffc1794f63e944b3216473681d38c
6
+ metadata.gz: 2cae616ad8cd9526e80365f4590640152afa2c411eac9a5c3b0c6028afcb7a710e3cf6549947b0e19ffd18eb16872cec997a3cdafbab172c2d79ff69ba0f0a6c
7
+ data.tar.gz: ef5adf673f387952bba98a73d5ea8875fb1bb9610feb9841c15d02b431934fff20124b82cbcd845995aa940589de110c6f1de3b9f8aaad23a3838842b6792c69
data/.travis.yml CHANGED
@@ -1,8 +1,7 @@
1
1
  rvm:
2
2
  - 1.9.3
3
3
  - 2.0.0
4
+ - 2.1.0
4
5
  before_script:
5
6
  - git config --global user.email "ci@traivs-ci.org"
6
7
  - git config --global user.name "Travis CI"
7
- script:
8
- - bundle exec cucumber --color --format progress --strict
data/CHANGELOG.md CHANGED
@@ -2,6 +2,22 @@ Stove CHANGELOG
2
2
  ===============
3
3
  This is the Changelog for the Stove gem.
4
4
 
5
+ v2.0.0 (unreleased)
6
+ -------------------
7
+ - Completely refactor the runner for speed optimizations
8
+ - Introduce a new configuration file format
9
+ - Add i18n support
10
+ - Add Filters and validations that execute before any commands are run
11
+ - Autoload plugins and actions
12
+ - Improve help output by grouping options
13
+ - Trap Signal interrupts cleanly
14
+ - Remove formatters
15
+ - Switch to log4r
16
+ - Introduce significantly more logging and log levels
17
+ - Remove HTTParty & Jiralicious in favor or Faraday
18
+ - Improve rake task to automatically perfom a minor bump when no version if given
19
+ - Persist data across the cookbook object
20
+ - Use singleton classes to save memory and loadtime
5
21
 
6
22
  v1.1.0
7
23
  ------
data/README.md CHANGED
@@ -33,36 +33,38 @@ Alternatively, you may install it as a gem:
33
33
 
34
34
  $ gem install stove
35
35
 
36
- Create a special JIRA credentials file at '~/.stove' that has the following JSON:
36
+ The use of some plugins (such as GitHub and JIRA) require a Stove configuration file. The Stove config is a JSON file stored at `~/.stove` on your local hard drive. The schema looks like this:
37
37
 
38
38
  ```javascript
39
39
  {
40
- "jira_username": "JIRA_USERNAME",
41
- "jira_password": "JIRA_PASSWORD",
42
- "opscode_username": "OPSCODE_USERNAME",
43
- "opscode_pem_file": "OPSCODE_PEM_FILE",
44
- "github_access_token": "PERSONAL_API_TOKEN"
40
+ "field": {
41
+ "option": "value"
42
+ }
45
43
  }
46
44
  ```
47
45
 
48
- - `jira_username` - The username used to login to Opscode's JIRA
49
- - `jira_password` - The password used to login to Opscode's JIRA
50
- - `opscode_username` - The username used to login to Opscode's Community Site
51
- - `opscode_password` - The password used to login to Opscode's Community Site
52
- - `github_access_token` - Your personal access token for the GitHub API
53
-
54
- For example:
46
+ For example, my local Stove configuration looks like this:
55
47
 
56
48
  ```javascript
57
49
  {
58
- "jira_username": "sethvargo",
59
- "jira_password": "bAc0ñ",
60
- "opscode_username": "sethvargo",
61
- "opscode_pem_file": "~/.chef/sethvargo.pem",
62
- "github_access_token": "abcdefg1234567"
50
+ "community": {
51
+ "username": "sethvargo",
52
+ "key": "~/.chef/sethvargo.pem"
53
+ },
54
+ "github": {
55
+ "access_token": "..."
56
+ },
57
+ "jira": {
58
+ "username": "sethvargo",
59
+ "password": "..."
60
+ }
63
61
  }
64
62
  ```
65
63
 
64
+ If you are using Stove 1.0, you need to update your configuration file syntax.
65
+
66
+ **It is recommended that the permissions on this file be 0600 to prevent unauthorized reading!**
67
+
66
68
 
67
69
  Usage
68
70
  -----
@@ -70,19 +72,29 @@ The gem is packaged as a binary. It should be run from _inside the cookbook to r
70
72
 
71
73
  (~/cookbooks/bacon) $ bake 1.2.3
72
74
 
75
+ You can always use the `--help` flag to get information:
76
+
73
77
  ```text
74
78
  Usage: bake x.y.z
75
- -l, --log-level [LEVEL] Ruby log level
76
- -c, --category [CATEGORY] The category for the cookbook (optional for existing cookbooks)
77
- -p, --path [PATH] The path to the cookbook to release (default: PWD)
78
- --[no-]git Automatically tag and push to git (default: true)
79
- --[no-]github Automatically release to GitHub (default: true)
80
- -r, --remote The name of the git remote to push to
81
- -b, --branch The name of the git branch to push to
82
- --[no-]devodd Automatically bump the metadata for devodd releases
83
- --[no-]jira Automatically populate the CHANGELOG from JIRA tickets and close them (default: false)
84
- --[no-]upload Upload the cookbook to the Opscode Community Site (default: true)
85
- --[no-]changelog Automatically generate a CHANGELOG (default: true)
79
+
80
+ Actions:
81
+ --no-bump Perform a version bump the local version automatically
82
+ --no-changelog Generate and prompt for a CHANGELOG
83
+ --no-dev Bump a minor version release for development purposes
84
+ --no-upload Upload the cookbook to the community site
85
+
86
+ Plugins:
87
+ --no-git Tag and push to a git remote
88
+ --no-github Publish the release to GitHub
89
+ --no-jira Resolve JIRA issues
90
+
91
+ Global Options:
92
+ --locale [LANGUAGE] Change the language to output messages
93
+ --log-level [LEVEL] Set the log verbosity
94
+ --category [CATEGORY] Set category for the cookbook
95
+ --path [PATH] Change the path to a cookbook
96
+ --remote [REMOTE] The name of the git remote to push to
97
+ --branch [BRANCH] The name of the git branch to push to
86
98
  -h, --help Show this message
87
99
  -v, --version Show version
88
100
  ```
data/Rakefile CHANGED
@@ -1 +1,16 @@
1
1
  require 'bundler/gem_tasks'
2
+
3
+ require 'cucumber/rake/task'
4
+ Cucumber::Rake::Task.new(:acceptance) do |t|
5
+ t.cucumber_opts = [].tap do |a|
6
+ a.push('--color')
7
+ a.push('--format progress')
8
+ a.push('--strict')
9
+ a.push('--tags ~@wip')
10
+ end.join(' ')
11
+ end
12
+
13
+ desc 'Run all tests'
14
+ task :test => [:acceptance]
15
+
16
+ task :default => [:test]
data/bin/bake CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- $:.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))
4
- require 'stove/cli'
3
+ require 'stove'
5
4
  Stove::Cli.new(ARGV.dup).execute!
@@ -0,0 +1,22 @@
1
+ Feature: Bump
2
+ Background:
3
+ * the Stove config is empty
4
+ * the CLI options are all off
5
+ * I have a cookbook named "bacon" at version "1.0.0"
6
+
7
+ Scenario: When the version has not changed
8
+ * I run `bake 1.0.0 --bump`
9
+ * it should fail with "version you are trying to bump already exists"
10
+
11
+ Scenario: When the version is not greater than the current
12
+ * I run `bake 0.1.0 --bump`
13
+ * it should fail with "bump to is less than the existing version"
14
+
15
+ Scenario: In isolation
16
+ * I successfully run `bake 2.0.0 --bump`
17
+ * the file "metadata.rb" should contain "2.0.0"
18
+
19
+ Scenario: With the git plugin
20
+ * I have a cookbook named "bacon" with git support
21
+ * I successfully run `bake 1.0.0 --bump --git`
22
+ * the git remote should have the commit "Version bump to 1.0.0"
@@ -0,0 +1,45 @@
1
+ Feature: Changelog
2
+ Background:
3
+ * the Stove config is empty
4
+ * the CLI options are all off
5
+ * I have a cookbook named "bacon"
6
+
7
+ Scenario: When the Changelog does not exist
8
+ * I remove the file "CHANGELOG.md"
9
+ * I run `bake --changelog`
10
+ * it should fail with "There is no `CHANGELOG.md' found"
11
+
12
+ Scenario: When the Changelog is not a proper format
13
+ * I write to "CHANGELOG.md" with:
14
+ """
15
+ This can't possibly be a valid Changelog
16
+ """
17
+ * I run `bake --changelog`
18
+ * it should fail with "does not appear to be a valid format"
19
+
20
+ Scenario: When the $EDITOR is not set
21
+ * the environment variable "EDITOR" is unset
22
+ * I run `bake --changelog`
23
+ * it should fail with "The `$EDITOR' environment variable is not set"
24
+
25
+ Scenario: In isolation
26
+ * the environment variable "EDITOR" is "cat"
27
+ * I successfully run `bake --changelog`
28
+ * the file "CHANGELOG.md" should contain "v0.0.0"
29
+
30
+ Scenario: With bump
31
+ * the environment variable "EDITOR" is "cat"
32
+ * I successfully run `bake 1.0.0 --changelog --bump`
33
+ * the file "CHANGELOG.md" should contain "v1.0.0"
34
+
35
+ Scenario: With the git plugin
36
+ * I have a cookbook named "bacon" with git support
37
+ * the environment variable "EDITOR" is "cat"
38
+ * I successfully run `bake --changelog --git`
39
+ * the git remote should have the commit "Publish 0.0.0 Changelog"
40
+
41
+ @wip
42
+ Scenario: With the GitHub plugin
43
+
44
+ @wip
45
+ Scenario: With the JIRA plugin
@@ -0,0 +1,18 @@
1
+ Feature: Dev
2
+ Background:
3
+ * the Stove config is empty
4
+ * the CLI options are all off
5
+ * I have a cookbook named "bacon" at version "1.0.0"
6
+
7
+ Scenario: In isolation
8
+ * I successfully run `bake --dev`
9
+ * the file "metadata.rb" should contain "1.0.1"
10
+
11
+ Scenario: With bump
12
+ * I successfully run `bake 2.0.0 --bump --dev`
13
+ * the file "metadata.rb" should contain "2.0.1"
14
+
15
+ Scenario: With the git plugin
16
+ * I have a cookbook named "bacon" with git support
17
+ * I successfully run `bake --dev --git`
18
+ * the git remote should have the commit "Version bump to 0.0.1 (for development)"
@@ -0,0 +1,48 @@
1
+ Feature: Upload
2
+ Background:
3
+ * the Stove config is empty
4
+ * the CLI options are all off
5
+ * I have a cookbook named "bacon"
6
+ * I am using the community server
7
+
8
+ Scenario: When the configuration does not exist
9
+ * I run `bake --upload`
10
+ * it should fail with "configuration for the Chef community site does not exist"
11
+
12
+ Scenario: When the username does not exist
13
+ * the Stove config at "community._" is ""
14
+ * I run `bake --upload`
15
+ * it should fail with "does not contain a username"
16
+
17
+ Scenario: When the key does not exist
18
+ * the Stove config at "community.username" is "bobo"
19
+ * I run `bake --upload`
20
+ * it should fail with "does not contain a key"
21
+
22
+ Scenario: When the category does not exist
23
+ * the Stove config at "community.username" is "bobo"
24
+ * the Stove config at "community.key" is "../../features/support/stove.pem"
25
+ * I run `bake --upload`
26
+ * it should fail with "You did not specify a category"
27
+
28
+ Scenario: In isolation
29
+ * the Stove config at "community.username" is "bobo"
30
+ * the Stove config at "community.key" is "../../features/support/stove.pem"
31
+ * the community server has the cookbook:
32
+ | bacon | 1.2.3 | Application |
33
+ * I successfully run `bake --upload`
34
+
35
+ Scenario: With the git plugin
36
+ * I have a cookbook named "bacon" with git support
37
+ * the Stove config at "community.username" is "bobo"
38
+ * the Stove config at "community.key" is "../../features/support/stove.pem"
39
+ * the community server has the cookbook:
40
+ | bacon | 1.2.3 | Application |
41
+ * I successfully run `bake --git --upload`
42
+ * the git remote should have the tag "v0.0.0"
43
+
44
+ @wip
45
+ Scenario: With the GitHub plugin
46
+
47
+ @wip
48
+ Scenario: With the JIRA plugin
@@ -0,0 +1,24 @@
1
+ Feature: git Plugin
2
+ Background:
3
+ * the Stove config is empty
4
+ * the CLI options are all off
5
+ * I have a cookbook named "bacon"
6
+
7
+ Scenario: When the directory is not a git repository
8
+ * I run `bake --git`
9
+ * it should fail with "does not appear to be a valid git repository"
10
+
11
+ Scenario: When the directory is dirty
12
+ * I have a cookbook named "bacon" with git support
13
+ * I write to "new" with:
14
+ """
15
+ This is new content
16
+ """
17
+ * I run `bake --git`
18
+ * it should fail with "has untracked files"
19
+
20
+ Scenario: When the local is out of date with the remote
21
+ * I have a cookbook named "bacon" with git support
22
+ * the remote repository has additional commits
23
+ * I run `bake --git`
24
+ * it should fail with "out of sync with the remote repository"
@@ -1,4 +1,3 @@
1
- @spawn
2
1
  Feature: Rake Task
3
2
  Background:
4
3
  * I have a cookbook named "bacon"
@@ -12,5 +11,5 @@ Feature: Rake Task
12
11
  * I successfully run `rake -T`
13
12
  * the output should contain:
14
13
  """
15
- rake publish # Publish this cookbook
14
+ rake publish[version] # Publish this cookbook
16
15
  """
@@ -1,29 +1,3 @@
1
- Given /^the environment variable (.+) is "(.+)"$/ do |variable, value|
2
- set_env(variable, value)
3
- end
4
-
5
- Then /^the exit status will be "(.+)"$/ do |error|
6
- # Ruby 1.9.3 sucks
7
- klass = error.split('::').inject(Stove) { |c, n| c.const_get(n) }
8
- assert_exit_status(klass.exit_code)
9
- end
10
-
11
1
  When /^the CLI options are all off$/ do
12
- class Stove::Cli
13
- private
14
- def options
15
- @options ||= {
16
- path: Dir.pwd,
17
- git: false,
18
- github: false,
19
- devodd: false,
20
- remote: 'origin',
21
- branch: 'master',
22
- jira: false,
23
- upload: false,
24
- changelog: false,
25
- log_level: :fatal,
26
- }
27
- end
28
- end
2
+ set_env('CLI_DEFAULT', 'false')
29
3
  end
@@ -1,19 +1,23 @@
1
- Given /^the Community Site has the cookbooks?:$/ do |table|
1
+ Given /^I am using the community server$/ do
2
+ set_env('COMMUNITY_URL', CommunityZero::RSpec.url)
3
+ end
4
+
5
+ Given /^the community server has the cookbooks?:$/ do |table|
2
6
  table.raw.each do |name, version, category|
3
7
  version ||= '0.0.0'
4
8
  category ||= 'Other'
5
9
 
6
- CommunityZero::Cookbook.create({
10
+ CommunityZero::RSpec.store.add(CommunityZero::Cookbook.new(
7
11
  name: name,
8
12
  version: version,
9
13
  category: category,
10
- })
14
+ ))
11
15
  end
12
16
  end
13
17
 
14
- Then /^the Community Site will( not)? have the cookbooks?:$/ do |negate, table|
18
+ Then /^the community server will( not)? have the cookbooks?:$/ do |negate, table|
15
19
  table.raw.each do |name, version, category|
16
- cookbook = CommunityZero::Store.find(name, version)
20
+ cookbook = CommunityZero::RSpec.store.find(name, version)
17
21
 
18
22
  if negate
19
23
  expect(cookbook).to be_nil
@@ -0,0 +1,24 @@
1
+ Given /^the Stove config is empty$/ do
2
+ path = File.join(tmp_path, '_config.rb')
3
+
4
+ write_file(path, '{}')
5
+ set_env('STOVE_CONFIG', path)
6
+ end
7
+
8
+ Given /^the Stove config at "(.+)" is "(.*)"$/ do |path, value|
9
+ parts = path.split('.').map(&:to_sym)
10
+ parents = parts[0...-1]
11
+
12
+ path = ENV['STOVE_CONFIG']
13
+ config = JSON.parse(File.read(path), symbolize_names: true)
14
+
15
+ # Vivify the hash
16
+ parent = parents.inject(config) do |config, parent|
17
+ config[parent] ||= {}
18
+ config[parent]
19
+ end
20
+
21
+ parent[parts.last] = value
22
+
23
+ File.open(path, 'w') { |f| f.write(JSON.generate(config)) }
24
+ end
@@ -1,23 +1,45 @@
1
- Given /^I have a cookbook named "(.+)"(?: (?:at|with) version "(.+)")?$/ do |name, version|
1
+ Given /^I have a cookbook named "(\w+)" at version "([\d\.]+)"$/ do |name, version|
2
2
  create_cookbook(name, version)
3
3
  end
4
4
 
5
- Given /^I have a cookbook named "(.+)"(?: (?:at|with) version "(.+)")? with git support$/ do |name, version|
6
- create_cookbook(name, version, git: true)
5
+ Given /^I have a cookbook named "(\w+)"$/ do |name|
6
+ create_cookbook(name, '0.0.0')
7
+ end
8
+
9
+ Given /^I have a cookbook named "(\w+)" with git support$/ do |name|
10
+ create_cookbook(name, '0.0.0', git: true)
7
11
  end
8
12
 
9
13
 
14
+ #
10
15
  # Create a new cookbook with the given name and version.
11
16
  #
12
17
  # @param [String] name
13
18
  # @param [String] version (default: 0.0.0.0)
14
19
  # @param [Hash] options
20
+ #
15
21
  def create_cookbook(name, version, options = {})
16
22
  create_dir(name)
17
23
  cd(name)
18
- write_file('CHANGELOG.md', "#{name} Cookbook CHANGELOG\n=====\n\nv0.0.0\n-----")
19
- write_file('README.md', 'This is a README')
20
- write_file('metadata.rb', "name '#{name}'\nversion '#{version || '0.0.0'}'")
24
+
25
+ write_file('CHANGELOG.md', <<-EOH.gsub(/^ {4}/, ''))
26
+ Changelog
27
+ =========
28
+
29
+ v#{version} (#{Time.now.to_date})
30
+ ----------------------------
31
+ - This is an entry
32
+ - This is another entry
33
+ EOH
34
+
35
+ write_file('README.md', <<-EOH.gsub(/^ {4}/, ''))
36
+ This is the README for #{name}
37
+ EOH
38
+
39
+ write_file('metadata.rb', <<-EOH.gsub(/^ {4}/, ''))
40
+ name '#{name}'
41
+ version '#{version}'
42
+ EOH
21
43
 
22
44
  if options[:git]
23
45
  git_init(current_dir)