Skip to content

Commit

Permalink
Make community site interaction into a plugin
Browse files Browse the repository at this point in the history
This makes it possible to release to any combination of upload
destinations, e.g. for someone who's ready to tag a release in GitHub,
but doesn't necessarily want to do a community site upload.
  • Loading branch information
hartmantis authored and sethvargo committed Jan 23, 2014
1 parent 81c78fd commit d601a32
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 61 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,16 @@ You can always use the `--help` flag to get information:
Usage: bake x.y.z
Actions:
--no-bump Perform a version bump the local version automatically
--no-changelog Generate and prompt for a CHANGELOG
--no-dev Bump a minor version release for development purposes
--no-upload Upload the cookbook to the community site
--[no-]bump [Don't] Perform a version bump the local version automatically
--[no-]changelog [Don't] Generate and prompt for a CHANGELOG
--[no-]dev [Don't] Bump a minor version release for development purposes
--[no-]upload [Don't] Execute upload stages of enabled plugins
Plugins:
--no-git Tag and push to a git remote
--no-github Publish the release to GitHub
--no-jira Resolve JIRA issues
--[no-]community [Don't] Upload to the community site
--[no-]git [Don't] Tag and push to a git remote
--[no-]github [Don't] Publish the release to GitHub
--[no-]jira [Don't] Resolve JIRA issues
Global Options:
--locale [LANGUAGE] Change the language to output messages
Expand Down
34 changes: 6 additions & 28 deletions features/actions/upload.feature
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,20 @@ Feature: Upload
* I have a cookbook named "bacon"
* I am using the community server

Scenario: When the configuration does not exist
* I run `bake --upload`
* it should fail with "configuration for the Chef community site does not exist"

Scenario: When the username does not exist
* the Stove config at "community._" is ""
* I run `bake --upload`
* it should fail with "does not contain a username"

Scenario: When the key does not exist
* the Stove config at "community.username" is "bobo"
* I run `bake --upload`
* it should fail with "does not contain a key"

Scenario: When the category does not exist
* the Stove config at "community.username" is "bobo"
* the Stove config at "community.key" is "../../features/support/stove.pem"
* I run `bake --upload`
* it should fail with "You did not specify a category"

Scenario: In isolation
* the Stove config at "community.username" is "bobo"
* the Stove config at "community.key" is "../../features/support/stove.pem"
* the community server has the cookbook:
| bacon | 1.2.3 | Application |
* I successfully run `bake --upload`

Scenario: With the git plugin
* I have a cookbook named "bacon" with git support
* the Stove config at "community.username" is "bobo"
* the Stove config at "community.key" is "../../features/support/stove.pem"
* the community server has the cookbook:
| bacon | 1.2.3 | Application |
* I successfully run `bake --git --upload`
* I successfully run `bake --git --upload --community`
* the git remote should have the tag "v0.0.0"

Scenario: With the git plugin and the upload action disabled
* I have a cookbook named "bacon" with git support
* I successfully run `bake --git --no-upload`
* the git remote should not have the tag "v0.0.0"

@wip
Scenario: With the GitHub plugin

Expand Down
40 changes: 40 additions & 0 deletions features/plugins/community.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Feature: Community
Background:
* the Stove config is empty
* the CLI options are all off
* I have a cookbook named "bacon"
* I am using the community server

Scenario: When the configuration does not exist
* I run `bake --upload --community`
* it should fail with "configuration for the Chef community site does not exist"

Scenario: When the username does not exist
* the Stove config at "community._" is ""
* I run `bake --upload --community`
* it should fail with "does not contain a username"

Scenario: When the key does not exist
* the Stove config at "community.username" is "bobo"
* I run `bake --upload --community`
* it should fail with "does not contain a key"

Scenario: When the category does not exist
* the Stove config at "community.username" is "bobo"
* the Stove config at "community.key" is "../../features/support/stove.pem"
* I run `bake --upload --community`
* it should fail with "You did not specify a category"

Scenario: In isolation
* the Stove config at "community.username" is "bobo"
* the Stove config at "community.key" is "../../features/support/stove.pem"
* the community server has the cookbook:
| bacon | 1.2.3 | Application |
* I successfully run `bake --upload --community`

Scenario: When the community plugin is explicitly disabled
* the Stove config at "community.username" is "bobo"
* the Stove config at "community.key" is "../../features/support/stove.pem"
* I successfully run `bake --upload --no-community`
* the community server will not have the cookbook:
| bacon | | |
5 changes: 5 additions & 0 deletions features/plugins/git.feature
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ Feature: git Plugin
* the remote repository has additional commits
* I run `bake --git`
* it should fail with "out of sync with the remote repository"

Scenario: When a git upload should be done
* I have a cookbook named "bacon" with git support
* I successfully run `bake --upload --git`
* the git remote should have the tag "v0.0.0"
9 changes: 5 additions & 4 deletions lib/stove.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ module Mixin
end

module Plugin
autoload :Base, 'stove/plugins/base'
autoload :Git, 'stove/plugins/git'
autoload :GitHub, 'stove/plugins/github'
autoload :JIRA, 'stove/plugins/jira'
autoload :Base, 'stove/plugins/base'
autoload :Community, 'stove/plugins/community'
autoload :Git, 'stove/plugins/git'
autoload :GitHub, 'stove/plugins/github'
autoload :JIRA, 'stove/plugins/jira'
end

#
Expand Down
22 changes: 3 additions & 19 deletions lib/stove/actions/upload.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,11 @@
module Stove
class Action::Upload < Action::Base
id 'upload'
description 'Upload the cookbook to the community site'

validate(:configuration) do
Config.has_key?(:community)
end

validate(:username) do
Config[:community].has_key?(:username)
end

validate(:key) do
Config[:community].has_key?(:key)
end

validate(:category) do
!cookbook.category.nil?
end
description 'Publish the release to enabled plugin destinations'

def run
log.info('Uploading to the Chef community site')
Community.upload(cookbook)
log.debug('Running upload hooks...')
log.info('Done!')
end
end
end
26 changes: 26 additions & 0 deletions lib/stove/plugins/community.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
module Stove
class Plugin::Community < Plugin::Base
id 'community'
description 'Publish the release to the Chef community site'

validate(:configuration) do
Config.has_key?(:community)
end

validate(:username) do
Config[:community].has_key?(:username)
end

validate(:key) do
Config[:community].has_key?(:key)
end

validate(:category) do
!cookbook.category.nil?
end

after(:upload, 'Publishing the release to the Chef community site') do
Community.upload(cookbook)
end
end
end
5 changes: 2 additions & 3 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,9 @@ en:
}
}
# Upload validations
# Community validations
# ---------------------
upload:
community:
configuration: >
The Stove configuration for the Chef community site does not exist! In
order to perform operations against the Chef community site, you must
Expand Down

0 comments on commit d601a32

Please sign in to comment.