diff --git a/README.md b/README.md index 0b9131a..ee5527d 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/features/actions/upload.feature b/features/actions/upload.feature index 6a51230..ea359f4 100644 --- a/features/actions/upload.feature +++ b/features/actions/upload.feature @@ -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 diff --git a/features/plugins/community.feature b/features/plugins/community.feature new file mode 100644 index 0000000..0a12ad8 --- /dev/null +++ b/features/plugins/community.feature @@ -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 | | | diff --git a/features/plugins/git.feature b/features/plugins/git.feature index 832071f..4be9102 100644 --- a/features/plugins/git.feature +++ b/features/plugins/git.feature @@ -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" diff --git a/lib/stove.rb b/lib/stove.rb index 19bb0f7..1685605 100644 --- a/lib/stove.rb +++ b/lib/stove.rb @@ -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 # diff --git a/lib/stove/actions/upload.rb b/lib/stove/actions/upload.rb index 13814c3..2b525b5 100644 --- a/lib/stove/actions/upload.rb +++ b/lib/stove/actions/upload.rb @@ -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 diff --git a/lib/stove/plugins/community.rb b/lib/stove/plugins/community.rb new file mode 100644 index 0000000..a9fb4b6 --- /dev/null +++ b/lib/stove/plugins/community.rb @@ -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 diff --git a/locales/en.yml b/locales/en.yml index b8e8f12..a0eb43e 100644 --- a/locales/en.yml +++ b/locales/en.yml @@ -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