-
-
Notifications
You must be signed in to change notification settings - Fork 54
New CLI commands #244
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
Merged
Merged
New CLI commands #244
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
acdcec0
CLI: Remove the need to add command name to options
neomilium 3c77111
Tests: Provide new helpers steps to configure modulesync
neomilium 72dd911
Repository: Refactor #prepare_workspace
neomilium e75a2c0
Repository: Rename #switch_branch to #switch with named argument
neomilium 7e3b870
Repository: Allow to prepare workspace in offline mode
neomilium 2aab81c
CLI: Add new command to execute custom command on each repository
neomilium b56d13c
CLI: Allow `execute` to run bundler commands
neomilium 2e43182
CLI: Add new command to reset each repository
neomilium 75ec0ef
CLI: Add new command to push commits
neomilium 807bab2
CLI: Add new command to clone repositories if required
neomilium b489615
CLI: Simplify the options preparation for each command
neomilium 4bc8ec0
CLI: Add fail-fast feature to `execute` command
neomilium a825ded
CLI: Explain local script usage with `execute` command
neomilium 5438cce
Rubocop: Fix Style/FileWrite
neomilium fda6b01
Rubocop: Update TODO file
neomilium 0c9838c
Fix CI
smortex File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| Feature: execute | ||
| Use ModuleSync to execute a custom script on each repositories | ||
|
|
||
| Scenario: Cloning sourcecodes before running command when modules/ dir is empty | ||
| Given a basic setup with a puppet module "puppet-test" from "awesome" | ||
| Then the file "modules/awesome/puppet-test/metadata.json" should not exist | ||
| When I successfully run `msync exec --verbose -- /bin/true` | ||
| Then the stdout should contain "Cloning from 'file://" | ||
| And the file "modules/awesome/puppet-test/metadata.json" should exist | ||
|
|
||
| @no-clobber | ||
| Scenario: No clones before running command when sourcecode have already been cloned | ||
| Then the file "modules/awesome/puppet-test/metadata.json" should exist | ||
| When I successfully run `msync exec --verbose /bin/true` | ||
| Then the stdout should not contain "Cloning from 'file://" | ||
|
|
||
| @no-clobber | ||
| Scenario: When command run fails, fail fast if option defined | ||
| When I run `msync exec --verbose --fail-fast -- /bin/false` | ||
| Then the exit status should be 1 | ||
| And the stderr should contain: | ||
| """ | ||
| Command execution failed | ||
| """ | ||
|
|
||
| @no-clobber | ||
| Scenario: When command run fails, run all and summarize errors if option fail-fast is not set | ||
| When I run `msync exec --verbose --no-fail-fast -- /bin/false` | ||
| Then the exit status should be 1 | ||
| And the stderr should contain: | ||
| """ | ||
| Error(s) during `execute` command: | ||
| * | ||
| """ | ||
|
|
||
| Scenario: Show fail-fast default value in help | ||
| When I successfully run `msync help exec` | ||
| Then the stdout should contain: | ||
| """ | ||
| [--fail-fast], [--no-fail-fast] # Abort the run after a command execution failure | ||
| # Default: true | ||
| """ | ||
|
|
||
| Scenario: Override fail-fast default value using config file | ||
| Given the global option "fail_fast" sets to "false" | ||
| When I successfully run `msync help exec` | ||
| Then the stdout should contain: | ||
| """ | ||
| [--fail-fast], [--no-fail-fast] # Abort the run after a command execution failure | ||
| """ | ||
| # NOTE: It seems there is a Thor bug here: default value is missing in help when sets to 'false' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| Feature: push | ||
| Push commits to remote | ||
|
|
||
| Scenario: Push available commits to remote | ||
| Given a mocked git configuration | ||
| And a puppet module "puppet-test" from "awesome" | ||
| And a file named "managed_modules.yml" with: | ||
| """ | ||
| --- | ||
| puppet-test: | ||
| namespace: awesome | ||
| """ | ||
| And a file named "modulesync.yml" with: | ||
| """ | ||
| --- | ||
| branch: modulesync | ||
| """ | ||
| And a git_base option appended to "modulesync.yml" for local tests | ||
| And I successfully run `msync reset` | ||
| And I cd to "modules/awesome/puppet-test" | ||
| And I run `touch hello` | ||
| And I run `git add hello` | ||
| And I run `git commit -m'Hello!'` | ||
| And I cd to "~" | ||
| Then the puppet module "puppet-test" from "awesome" should have no commits made by "Aruba" | ||
| When I successfully run `msync push --verbose` | ||
| Then the puppet module "puppet-test" from "awesome" should have 1 commit made by "Aruba" in branch "modulesync" | ||
|
|
||
| Scenario: Push command without a branch sets | ||
| Given a basic setup with a puppet module "puppet-test" from "awesome" | ||
| When I run `msync push --verbose` | ||
| Then the exit status should be 1 | ||
| And the stderr should contain: | ||
| """ | ||
| Error: 'branch' option is missing, please set it in configuration or in command line. | ||
| """ | ||
|
|
||
| Scenario: Report the need to clone repositories if sourcecode was not cloned before | ||
| Given a basic setup with a puppet module "puppet-test" from "awesome" | ||
| And the global option "branch" sets to "modulesync" | ||
| When I run `msync push --verbose` | ||
| Then the exit status should be 1 | ||
| And the stderr should contain: | ||
| """ | ||
| puppet-test: Repository must be locally available before trying to push | ||
| """ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| Feature: reset | ||
| Reset all repositories | ||
|
|
||
| Scenario: Running first reset to clone repositories | ||
| Given a basic setup with a puppet module "puppet-test" from "awesome" | ||
| And the global option "branch" sets to "modulesync" | ||
| When I successfully run `msync reset --verbose` | ||
| Then the output should contain "Cloning from 'file://" | ||
| And the output should not contain "Hard-resetting any local changes to repository in" | ||
|
|
||
| @no-clobber | ||
| Scenario: Reset when sourcecodes have already been cloned | ||
| Given the file "modules/awesome/puppet-test/metadata.json" should exist | ||
| And the global option "branch" sets to "modulesync" | ||
| When I successfully run `msync reset --verbose` | ||
| Then the output should not contain "Cloning from 'file://" | ||
| And the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/master'" | ||
|
|
||
| Scenario: Reset after an upstream file addition | ||
| Given a basic setup with a puppet module "puppet-test" from "awesome" | ||
| And the global option "branch" sets to "modulesync" | ||
| And I successfully run `msync reset` | ||
| Then the file "modules/awesome/puppet-test/hello" should not exist | ||
| When the puppet module "puppet-test" from "awesome" has a file named "hello" with: | ||
| """ | ||
| Hello | ||
| """ | ||
| When I successfully run `msync reset --verbose` | ||
| Then the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/master'" | ||
| And the file "modules/awesome/puppet-test/hello" should exist | ||
|
|
||
| Scenario: Reset after an upstream file addition in offline mode | ||
| Given a basic setup with a puppet module "puppet-test" from "awesome" | ||
| And the global option "branch" sets to "modulesync" | ||
| And I successfully run `msync reset` | ||
| Then the file "modules/awesome/puppet-test/hello" should not exist | ||
| When the puppet module "puppet-test" from "awesome" has a branch named "execute" | ||
| And the puppet module "puppet-test" from "awesome" has, in branch "execute", a file named "hello" with: | ||
| """ | ||
| Hello | ||
| """ | ||
| When I successfully run `msync reset --offline` | ||
| Then the file "modules/awesome/puppet-test/hello" should not exist | ||
|
|
||
| Scenario: Reset to a specified branch | ||
| Given a basic setup with a puppet module "puppet-test" from "awesome" | ||
| And the global option "branch" sets to "modulesync" | ||
| When the puppet module "puppet-test" from "awesome" has a branch named "other-branch" | ||
| And the puppet module "puppet-test" from "awesome" has, in branch "other-branch", a file named "hello" with: | ||
| """ | ||
| Hello | ||
| """ | ||
| And I successfully run `msync reset` | ||
| Then the file "modules/awesome/puppet-test/hello" should not exist | ||
| When I successfully run `msync reset --verbose --source-branch origin/other-branch` | ||
| And the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/other-branch'" | ||
| Then the file "modules/awesome/puppet-test/hello" should exist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.