modulesync 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +18 -3
  3. data/.github/workflows/release.yml +2 -4
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +14 -8
  6. data/.rubocop_todo.yml +25 -17
  7. data/.simplecov +46 -0
  8. data/CHANGELOG.md +32 -0
  9. data/Gemfile +1 -1
  10. data/bin/msync +17 -1
  11. data/features/cli.feature +12 -6
  12. data/features/execute.feature +51 -0
  13. data/features/hook.feature +5 -8
  14. data/features/push.feature +46 -0
  15. data/features/reset.feature +57 -0
  16. data/features/step_definitions/git_steps.rb +29 -1
  17. data/features/support/env.rb +9 -0
  18. data/features/update/bump_version.feature +8 -12
  19. data/features/update/dot_sync.feature +52 -0
  20. data/features/update/pull_request.feature +180 -0
  21. data/features/update.feature +74 -103
  22. data/lib/modulesync/cli/thor.rb +12 -0
  23. data/lib/modulesync/cli.rb +122 -28
  24. data/lib/modulesync/git_service/base.rb +63 -0
  25. data/lib/modulesync/git_service/factory.rb +28 -0
  26. data/lib/modulesync/{pr → git_service}/github.rb +23 -21
  27. data/lib/modulesync/git_service/gitlab.rb +62 -0
  28. data/lib/modulesync/git_service.rb +96 -0
  29. data/lib/modulesync/hook.rb +11 -13
  30. data/lib/modulesync/renderer.rb +3 -6
  31. data/lib/modulesync/repository.rb +71 -25
  32. data/lib/modulesync/settings.rb +0 -1
  33. data/lib/modulesync/source_code.rb +28 -2
  34. data/lib/modulesync/util.rb +4 -4
  35. data/lib/modulesync.rb +104 -66
  36. data/modulesync.gemspec +7 -4
  37. data/spec/helpers/faker/puppet_module_remote_repo.rb +16 -1
  38. data/spec/spec_helper.rb +1 -23
  39. data/spec/unit/modulesync/git_service/factory_spec.rb +16 -0
  40. data/spec/unit/modulesync/git_service/github_spec.rb +81 -0
  41. data/spec/unit/modulesync/git_service/gitlab_spec.rb +90 -0
  42. data/spec/unit/modulesync/git_service_spec.rb +201 -0
  43. data/spec/unit/modulesync/source_code_spec.rb +22 -0
  44. data/spec/unit/modulesync_spec.rb +0 -12
  45. metadata +74 -12
  46. data/lib/modulesync/pr/gitlab.rb +0 -54
  47. data/spec/unit/modulesync/pr/github_spec.rb +0 -49
  48. data/spec/unit/modulesync/pr/gitlab_spec.rb +0 -81
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47b0ae966cafd00936f4a6cabe78a301ed07c28dec01fefe70bf4023c358d4b7
4
- data.tar.gz: 7f1ef9ce1d648b9608653ba3ea5183acc45bfd86564691758bde8034b3095990
3
+ metadata.gz: e4914cfca898fe7b7183b87a1feaa7b4edbeb2a1d5b97d2d32f53ca7cde6adf1
4
+ data.tar.gz: 7b02e4e2a1a4b1d7108702f3c9108ef250b13ddace34f4946f11d11338de6f90
5
5
  SHA512:
6
- metadata.gz: 3ff60c169408c9be476e0b6020c9d5685ed2e025b77faba9f1618b75b3486df2205ab39190cc6b26abf541e6f29cd73fdcd623f71a7d014f2eaaa118b83050e5
7
- data.tar.gz: 3c17ac2c07fb222081266e46ba9b2be6e1fc2b61d481f2e32fe7bd5e1848cec718b5e620e8c136d5b7321d938157df81093a8a8c959ebd8f21e8089b9d17777e
6
+ metadata.gz: 93c282023d9f20729b4c8ed253e8a6b7c312433291fede9db35ee4b1250e00933b8bd751225521b6613709d41bef216f6a366115569710576253fb3473f5a408
7
+ data.tar.gz: 8019fac3cd951a7001986fbca62d50b4404e8c4008357a4724652a177a49d61ff4826d52767c67c074e0236f67723fea1df38fb583a1292d2f1ae5db8be39ccb
@@ -8,7 +8,19 @@ env:
8
8
  BUNDLE_WITHOUT: release
9
9
 
10
10
  jobs:
11
+ rubocop:
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - name: Setup ruby
16
+ uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: '3.1'
19
+ bundler-cache: true
20
+ - name: Run linter
21
+ run: bundle exec rubocop --format github
11
22
  test:
23
+ needs: rubocop
12
24
  runs-on: ubuntu-latest
13
25
  strategy:
14
26
  fail-fast: false
@@ -18,9 +30,10 @@ jobs:
18
30
  - ruby: "2.6"
19
31
  - ruby: "2.7"
20
32
  - ruby: "3.0"
21
- coverage: "yes"
33
+ - ruby: "3.1"
34
+ codecov: "yes"
22
35
  env:
23
- COVERAGE: ${{ matrix.coverage }}
36
+ CODECOV: ${{ matrix.codecov }}
24
37
  steps:
25
38
  - uses: actions/checkout@v2
26
39
  - name: Install Ruby ${{ matrix.ruby }}
@@ -28,7 +41,9 @@ jobs:
28
41
  with:
29
42
  ruby-version: ${{ matrix.ruby }}
30
43
  bundler-cache: true
31
- - name: Run tests
44
+ - name: Run unit tests
32
45
  run: bundle exec rake spec
46
+ - name: Run behavior tests
47
+ run: bundle exec cucumber
33
48
  - name: Build gem
34
49
  run: gem build *.gemspec
@@ -9,14 +9,12 @@ jobs:
9
9
  release:
10
10
  runs-on: ubuntu-latest
11
11
  if: github.repository == 'voxpupuli/modulesync'
12
- env:
13
- BUNDLE_WITHOUT: release
14
12
  steps:
15
13
  - uses: actions/checkout@v2
16
- - name: Install Ruby 3.0
14
+ - name: Install Ruby 3.1
17
15
  uses: ruby/setup-ruby@v1
18
16
  with:
19
- ruby-version: '3.0'
17
+ ruby-version: '3.1'
20
18
  - name: Build gem
21
19
  run: gem build *.gemspec
22
20
  - name: Publish gem to rubygems.org
data/.gitignore CHANGED
@@ -5,6 +5,7 @@
5
5
  Gemfile.lock
6
6
  bin/bundle
7
7
  bin/rspec
8
+ coverage/
8
9
  modules/
9
10
  tmp/
10
11
  vendor/
data/.rubocop.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  inherit_from: .rubocop_todo.yml
2
2
 
3
3
  AllCops:
4
- TargetRubyVersion: 2.4
4
+ TargetRubyVersion: 2.5
5
+ NewCops: enable
5
6
  Exclude:
6
7
  - 'vendor/**/*'
7
8
  - 'tmp/**/*'
@@ -14,19 +15,24 @@ AllCops:
14
15
  Style/HashSyntax:
15
16
  Enabled: false
16
17
 
17
- # dealbreaker:
18
- Style/TrailingCommaInLiteral:
19
- Enabled: false
18
+ Style/TrailingCommaInArguments:
19
+ EnforcedStyleForMultiline: comma
20
20
 
21
- # would require external library
22
- Layout/IndentHeredoc:
23
- Enabled: false
21
+ Style/TrailingCommaInArrayLiteral:
22
+ EnforcedStyleForMultiline: comma
23
+
24
+ Style/TrailingCommaInHashLiteral:
25
+ EnforcedStyleForMultiline: comma
24
26
 
25
27
  # sane line length
26
- Metrics/LineLength:
28
+ Layout/LineLength:
27
29
  Max: 120
28
30
  Exclude:
29
31
  - 'features/**/*'
30
32
 
31
33
  Style/FrozenStringLiteralComment:
32
34
  Enabled: false
35
+
36
+ # We explicitly prefer $stderr.puts over #warn
37
+ Style/StderrPuts:
38
+ Enabled: false
data/.rubocop_todo.yml CHANGED
@@ -1,39 +1,46 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2021-04-22 16:30:35 +0200 using RuboCop version 0.50.0.
3
+ # on 2022-02-14 21:55:21 UTC using RuboCop version 1.24.1.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
- Lint/UselessAssignment:
10
+ # Cop supports --auto-correct.
11
+ # Configuration parameters: Include.
12
+ # Include: **/*.gemspec
13
+ Gemspec/RequireMFA:
11
14
  Exclude:
12
- - 'lib/modulesync.rb'
15
+ - 'modulesync.gemspec'
13
16
 
14
- # Offense count: 10
17
+ # Offense count: 9
18
+ # Configuration parameters: IgnoredMethods, CountRepeatedAttributes.
15
19
  Metrics/AbcSize:
16
- Max: 67
20
+ Max: 60
17
21
 
18
22
  # Offense count: 2
19
- # Configuration parameters: CountComments.
23
+ # Configuration parameters: CountComments, CountAsOne.
20
24
  Metrics/ClassLength:
21
- Max: 128
25
+ Max: 186
22
26
 
23
- # Offense count: 3
27
+ # Offense count: 5
28
+ # Configuration parameters: IgnoredMethods.
24
29
  Metrics/CyclomaticComplexity:
25
- Max: 12
30
+ Max: 15
26
31
 
27
- # Offense count: 13
28
- # Configuration parameters: CountComments.
32
+ # Offense count: 17
33
+ # Configuration parameters: CountComments, CountAsOne, ExcludedMethods, IgnoredMethods.
29
34
  Metrics/MethodLength:
30
- Max: 36
35
+ Max: 34
31
36
 
32
- # Offense count: 3
37
+ # Offense count: 4
38
+ # Configuration parameters: IgnoredMethods.
33
39
  Metrics/PerceivedComplexity:
34
- Max: 13
40
+ Max: 16
35
41
 
36
42
  # Offense count: 8
43
+ # Configuration parameters: AllowedConstants.
37
44
  Style/Documentation:
38
45
  Exclude:
39
46
  - 'spec/**/*'
@@ -45,7 +52,8 @@ Style/Documentation:
45
52
  - 'lib/modulesync/util.rb'
46
53
 
47
54
  # Offense count: 1
48
- # Cop supports --auto-correct.
49
- Style/EachWithObject:
55
+ # Configuration parameters: AllowedMethods.
56
+ # AllowedMethods: respond_to_missing?
57
+ Style/OptionalBooleanParameter:
50
58
  Exclude:
51
- - 'lib/modulesync/util.rb'
59
+ - 'lib/modulesync/puppet_module.rb'
data/.simplecov ADDED
@@ -0,0 +1,46 @@
1
+ SimpleCov.start do
2
+ if ENV['SIMPLECOV_ROOT']
3
+ SimpleCov.root(ENV['SIMPLECOV_ROOT'])
4
+
5
+ filters.clear # This will remove the :root_filter and :bundler_filter that come via simplecov's defaults
6
+
7
+ # Because simplecov filters everything outside of the SimpleCov.root
8
+ # This should be added, cf.
9
+ # https://github.com/colszowka/simplecov#default-root-filter-and-coverage-for-things-outside-of-it
10
+ add_filter do |src|
11
+ src.filename !~ /^#{SimpleCov.root}/
12
+ end
13
+ end
14
+
15
+ add_group 'Source code', 'lib'
16
+
17
+ add_group 'Unit tests', 'spec'
18
+
19
+ add_group 'Behavior tests', 'features'
20
+ add_filter '/features/support/env.rb'
21
+
22
+ enable_coverage :branch
23
+
24
+ # do not track vendored files
25
+ add_filter '/vendor'
26
+ add_filter '/.vendor'
27
+
28
+ # exclude anything that is not in lib, spec or features directories
29
+ add_filter do |src|
30
+ src.filename !~ %r{^#{SimpleCov.root}/(lib|spec|features)}
31
+ end
32
+
33
+ track_files '**/*.rb'
34
+ end
35
+
36
+ if ENV['CODECOV'] == 'yes'
37
+ require 'simplecov-console'
38
+ require 'codecov'
39
+
40
+ SimpleCov.formatters = [
41
+ SimpleCov::Formatter::Console,
42
+ SimpleCov::Formatter::Codecov,
43
+ ]
44
+ end
45
+
46
+ # vim: filetype=ruby
data/CHANGELOG.md CHANGED
@@ -2,6 +2,37 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [2.3.0](https://github.com/voxpupuli/modulesync/tree/2.3.0) (2022-03-07)
6
+
7
+ [Full Changelog](https://github.com/voxpupuli/modulesync/compare/2.2.0...2.3.0)
8
+
9
+ **Implemented enhancements:**
10
+
11
+ - CLI: Show relevant help when using --help option on a subcommand [\#248](https://github.com/voxpupuli/modulesync/pull/248) ([neomilium](https://github.com/neomilium))
12
+ - New CLI commands [\#244](https://github.com/voxpupuli/modulesync/pull/244) ([neomilium](https://github.com/neomilium))
13
+
14
+ **Fixed bugs:**
15
+
16
+ - Existing MR makes msync fail \(which leaves changes in target branch\) [\#195](https://github.com/voxpupuli/modulesync/issues/195)
17
+ - Target branch `.sync.yml` not taken into account on branch update \(--force\) [\#192](https://github.com/voxpupuli/modulesync/issues/192)
18
+ - Fix error when git upstream branch is deleted [\#240](https://github.com/voxpupuli/modulesync/pull/240) ([neomilium](https://github.com/neomilium))
19
+
20
+ **Closed issues:**
21
+
22
+ - Linter is missing in CI [\#237](https://github.com/voxpupuli/modulesync/issues/237)
23
+ - Behavior tests are missing in CI [\#236](https://github.com/voxpupuli/modulesync/issues/236)
24
+
25
+ **Merged pull requests:**
26
+
27
+ - Properly ensure the parent directory exists [\#247](https://github.com/voxpupuli/modulesync/pull/247) ([ekohl](https://github.com/ekohl))
28
+ - Add Ruby 3.1 to CI matrix [\#245](https://github.com/voxpupuli/modulesync/pull/245) ([bastelfreak](https://github.com/bastelfreak))
29
+ - Fix rubocop offences and add linter to CI [\#243](https://github.com/voxpupuli/modulesync/pull/243) ([neomilium](https://github.com/neomilium))
30
+ - Support `.sync.yml` changes between two runs [\#242](https://github.com/voxpupuli/modulesync/pull/242) ([neomilium](https://github.com/neomilium))
31
+ - Fix gitlab merge request submission [\#241](https://github.com/voxpupuli/modulesync/pull/241) ([neomilium](https://github.com/neomilium))
32
+ - Add behavior tests to CI [\#239](https://github.com/voxpupuli/modulesync/pull/239) ([neomilium](https://github.com/neomilium))
33
+ - Rework PR/MR feature [\#219](https://github.com/voxpupuli/modulesync/pull/219) ([neomilium](https://github.com/neomilium))
34
+ - Refactor code for maintainabilty [\#206](https://github.com/voxpupuli/modulesync/pull/206) ([neomilium](https://github.com/neomilium))
35
+
5
36
  ## [2.2.0](https://github.com/voxpupuli/modulesync/tree/2.2.0) (2021-07-24)
6
37
 
7
38
  [Full Changelog](https://github.com/voxpupuli/modulesync/compare/2.1.1...2.2.0)
@@ -52,6 +83,7 @@ The 2.1.0 release didn't make it to github packages. 2.1.1 is a new release with
52
83
 
53
84
  **Closed issues:**
54
85
 
86
+ - PR/MR feature should honor the repository default branch name as target branch [\#207](https://github.com/voxpupuli/modulesync/issues/207)
55
87
  - Add linting \(rubocop\) to Travis CI configuration [\#153](https://github.com/voxpupuli/modulesync/issues/153)
56
88
  - Language sensitive GIT handling [\#85](https://github.com/voxpupuli/modulesync/issues/85)
57
89
 
data/Gemfile CHANGED
@@ -6,7 +6,7 @@ group :release do
6
6
  gem 'github_changelog_generator', :require => false
7
7
  end
8
8
 
9
- group :coverage, optional: ENV['COVERAGE']!='yes' do
9
+ group :coverage, optional: ENV['CODECOV']!='yes' do
10
10
  gem 'simplecov-console', :require => false
11
11
  gem 'codecov', :require => false
12
12
  end
data/bin/msync CHANGED
@@ -1,6 +1,22 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- lib = File.expand_path('../../lib', __FILE__)
3
+ if ENV['COVERAGE']
4
+ # This block allow us to grab code coverage when running this script.
5
+ #
6
+ # Note: This environment variable (ie. COVERAGE) is set in Cucumber/Aruba configuration to collect reports
7
+ simplecov_root = File.expand_path File.join(File.dirname(__FILE__), '..')
8
+
9
+ # When running with aruba simplecov was using /tmp/aruba as the root folder.
10
+ # This is to force using the project folder
11
+ ENV['SIMPLECOV_ROOT'] = simplecov_root
12
+ require 'simplecov'
13
+
14
+ # https://github.com/simplecov-ruby/simplecov/issues/234
15
+ # As described in the issue, every process must have an unique name:
16
+ SimpleCov.command_name "#{File.basename $PROGRAM_NAME} (pid: #{Process.pid})"
17
+ end
18
+
19
+ lib = File.expand_path('../lib', __dir__)
4
20
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
21
 
6
22
  require 'modulesync/cli'
data/features/cli.feature CHANGED
@@ -17,9 +17,16 @@ Feature: CLI
17
17
  Then the exit status should be 1
18
18
 
19
19
  Scenario: When running the help command
20
- When I run `msync help`
21
- And the output should match /Commands:/
22
- Then the exit status should be 0
20
+ When I successfully run `msync help`
21
+ Then the output should match /Commands:/
22
+
23
+ Scenario: Use --help options on subcommand should show subcommand help
24
+ When I successfully run `msync clone --help`
25
+ Then the output should contain:
26
+ """
27
+ Usage:
28
+ msync clone
29
+ """
23
30
 
24
31
  Scenario: When overriding a setting from the config file on the command line
25
32
  Given a puppet module "puppet-test" from "fakenamespace"
@@ -35,9 +42,8 @@ Feature: CLI
35
42
  """
36
43
  And a git_base option appended to "modulesync.yml" for local tests
37
44
  And a directory named "moduleroot"
38
- When I run `msync update --noop --namespace fakenamespace --branch command-line-branch`
39
- Then the exit status should be 0
40
- And the output should contain:
45
+ When I successfully run `msync update --verbose --noop --namespace fakenamespace --branch command-line-branch`
46
+ Then the output should contain:
41
47
  """
42
48
  Creating new branch command-line-branch
43
49
  """
@@ -0,0 +1,51 @@
1
+ Feature: execute
2
+ Use ModuleSync to execute a custom script on each repositories
3
+
4
+ Scenario: Cloning sourcecodes before running command when modules/ dir is empty
5
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
6
+ Then the file "modules/awesome/puppet-test/metadata.json" should not exist
7
+ When I successfully run `msync exec --verbose -- /bin/true`
8
+ Then the stdout should contain "Cloning from 'file://"
9
+ And the file "modules/awesome/puppet-test/metadata.json" should exist
10
+
11
+ @no-clobber
12
+ Scenario: No clones before running command when sourcecode have already been cloned
13
+ Then the file "modules/awesome/puppet-test/metadata.json" should exist
14
+ When I successfully run `msync exec --verbose /bin/true`
15
+ Then the stdout should not contain "Cloning from 'file://"
16
+
17
+ @no-clobber
18
+ Scenario: When command run fails, fail fast if option defined
19
+ When I run `msync exec --verbose --fail-fast -- /bin/false`
20
+ Then the exit status should be 1
21
+ And the stderr should contain:
22
+ """
23
+ Command execution failed
24
+ """
25
+
26
+ @no-clobber
27
+ Scenario: When command run fails, run all and summarize errors if option fail-fast is not set
28
+ When I run `msync exec --verbose --no-fail-fast -- /bin/false`
29
+ Then the exit status should be 1
30
+ And the stderr should contain:
31
+ """
32
+ Error(s) during `execute` command:
33
+ *
34
+ """
35
+
36
+ Scenario: Show fail-fast default value in help
37
+ When I successfully run `msync help exec`
38
+ Then the stdout should contain:
39
+ """
40
+ [--fail-fast], [--no-fail-fast] # Abort the run after a command execution failure
41
+ # Default: true
42
+ """
43
+
44
+ Scenario: Override fail-fast default value using config file
45
+ Given the global option "fail_fast" sets to "false"
46
+ When I successfully run `msync help exec`
47
+ Then the stdout should contain:
48
+ """
49
+ [--fail-fast], [--no-fail-fast] # Abort the run after a command execution failure
50
+ """
51
+ # NOTE: It seems there is a Thor bug here: default value is missing in help when sets to 'false'
@@ -3,24 +3,21 @@ Feature: hook
3
3
 
4
4
  Scenario: Activating a hook
5
5
  Given a directory named ".git/hooks"
6
- When I run `msync hook activate`
7
- Then the exit status should be 0
8
- And the file named ".git/hooks/pre-push" should contain "bash"
6
+ When I successfully run `msync hook activate`
7
+ Then the file named ".git/hooks/pre-push" should contain "bash"
9
8
 
10
9
  Scenario: Deactivating a hook
11
10
  Given a file named ".git/hooks/pre-push" with:
12
11
  """
13
12
  git hook
14
13
  """
15
- When I run `msync hook deactivate`
16
- Then the exit status should be 0
14
+ When I successfully run `msync hook deactivate`
17
15
  Then the file ".git/hooks/pre-push" should not exist
18
16
 
19
17
  Scenario: Activating a hook with arguments
20
18
  Given a directory named ".git/hooks"
21
- When I run `msync hook activate -a '--foo bar --baz quux' -b master`
22
- Then the exit status should be 0
23
- And the file named ".git/hooks/pre-push" should contain:
19
+ When I successfully run `msync hook activate -a '--foo bar --baz quux' -b master`
20
+ Then the file named ".git/hooks/pre-push" should contain:
24
21
  """
25
22
  "$message" -n puppetlabs -b master --foo bar --baz quux
26
23
  """
@@ -0,0 +1,46 @@
1
+ Feature: push
2
+ Push commits to remote
3
+
4
+ Scenario: Push available commits to remote
5
+ Given a mocked git configuration
6
+ And a puppet module "puppet-test" from "awesome"
7
+ And a file named "managed_modules.yml" with:
8
+ """
9
+ ---
10
+ puppet-test:
11
+ namespace: awesome
12
+ """
13
+ And a file named "modulesync.yml" with:
14
+ """
15
+ ---
16
+ branch: modulesync
17
+ """
18
+ And a git_base option appended to "modulesync.yml" for local tests
19
+ And I successfully run `msync reset`
20
+ And I cd to "modules/awesome/puppet-test"
21
+ And I run `touch hello`
22
+ And I run `git add hello`
23
+ And I run `git commit -m'Hello!'`
24
+ And I cd to "~"
25
+ Then the puppet module "puppet-test" from "awesome" should have no commits made by "Aruba"
26
+ When I successfully run `msync push --verbose`
27
+ Then the puppet module "puppet-test" from "awesome" should have 1 commit made by "Aruba" in branch "modulesync"
28
+
29
+ Scenario: Push command without a branch sets
30
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
31
+ When I run `msync push --verbose`
32
+ Then the exit status should be 1
33
+ And the stderr should contain:
34
+ """
35
+ Error: 'branch' option is missing, please set it in configuration or in command line.
36
+ """
37
+
38
+ Scenario: Report the need to clone repositories if sourcecode was not cloned before
39
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
40
+ And the global option "branch" sets to "modulesync"
41
+ When I run `msync push --verbose`
42
+ Then the exit status should be 1
43
+ And the stderr should contain:
44
+ """
45
+ puppet-test: Repository must be locally available before trying to push
46
+ """
@@ -0,0 +1,57 @@
1
+ Feature: reset
2
+ Reset all repositories
3
+
4
+ Scenario: Running first reset to clone repositories
5
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
6
+ And the global option "branch" sets to "modulesync"
7
+ When I successfully run `msync reset --verbose`
8
+ Then the output should contain "Cloning from 'file://"
9
+ And the output should not contain "Hard-resetting any local changes to repository in"
10
+
11
+ @no-clobber
12
+ Scenario: Reset when sourcecodes have already been cloned
13
+ Given the file "modules/awesome/puppet-test/metadata.json" should exist
14
+ And the global option "branch" sets to "modulesync"
15
+ When I successfully run `msync reset --verbose`
16
+ Then the output should not contain "Cloning from 'file://"
17
+ And the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/master'"
18
+
19
+ Scenario: Reset after an upstream file addition
20
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
21
+ And the global option "branch" sets to "modulesync"
22
+ And I successfully run `msync reset`
23
+ Then the file "modules/awesome/puppet-test/hello" should not exist
24
+ When the puppet module "puppet-test" from "awesome" has a file named "hello" with:
25
+ """
26
+ Hello
27
+ """
28
+ When I successfully run `msync reset --verbose`
29
+ Then the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/master'"
30
+ And the file "modules/awesome/puppet-test/hello" should exist
31
+
32
+ Scenario: Reset after an upstream file addition in offline mode
33
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
34
+ And the global option "branch" sets to "modulesync"
35
+ And I successfully run `msync reset`
36
+ Then the file "modules/awesome/puppet-test/hello" should not exist
37
+ When the puppet module "puppet-test" from "awesome" has a branch named "execute"
38
+ And the puppet module "puppet-test" from "awesome" has, in branch "execute", a file named "hello" with:
39
+ """
40
+ Hello
41
+ """
42
+ When I successfully run `msync reset --offline`
43
+ Then the file "modules/awesome/puppet-test/hello" should not exist
44
+
45
+ Scenario: Reset to a specified branch
46
+ Given a basic setup with a puppet module "puppet-test" from "awesome"
47
+ And the global option "branch" sets to "modulesync"
48
+ When the puppet module "puppet-test" from "awesome" has a branch named "other-branch"
49
+ And the puppet module "puppet-test" from "awesome" has, in branch "other-branch", a file named "hello" with:
50
+ """
51
+ Hello
52
+ """
53
+ And I successfully run `msync reset`
54
+ Then the file "modules/awesome/puppet-test/hello" should not exist
55
+ When I successfully run `msync reset --verbose --source-branch origin/other-branch`
56
+ And the output should contain "Hard-resetting any local changes to repository in 'modules/awesome/puppet-test' from branch 'origin/other-branch'"
57
+ Then the file "modules/awesome/puppet-test/hello" should exist
@@ -32,7 +32,20 @@ Given 'a puppet module {string} from {string}' do |name, namespace|
32
32
  end
33
33
 
34
34
  Given 'a git_base option appended to "modulesync.yml" for local tests' do
35
- File.write "#{Aruba.config.working_directory}/modulesync.yml", "\ngit_base: #{ModuleSync::Faker::PuppetModuleRemoteRepo.git_base}", mode: 'a'
35
+ step "the global option 'git_base' sets to '#{ModuleSync::Faker::PuppetModuleRemoteRepo.git_base}'"
36
+ end
37
+
38
+ Given 'the file {string} appended with:' do |filename, content|
39
+ File.write filename, "\n#{content}", mode: 'a'
40
+ end
41
+
42
+ Given 'the global option {string} sets to {string}' do |key, value|
43
+ steps %(
44
+ Given the file "#{Aruba.config.working_directory}/modulesync.yml" appended with:
45
+ """
46
+ #{key}: #{value}
47
+ """
48
+ )
36
49
  end
37
50
 
38
51
  Given 'the puppet module {string} from {string} is read-only' do |name, namespace|
@@ -64,6 +77,16 @@ Given 'the puppet module {string} from {string} has a file named {string} with:'
64
77
  pmrr.add_file(filename, content)
65
78
  end
66
79
 
80
+ Given 'the puppet module {string} from {string} has, in branch {string}, a file named {string} with:' do |name, namespace, branch, filename, content|
81
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
82
+ pmrr.add_file(filename, content, branch)
83
+ end
84
+
85
+ Given 'the puppet module {string} from {string} has a branch named {string}' do |name, namespace, branch|
86
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
87
+ pmrr.create_branch(branch)
88
+ end
89
+
67
90
  Then 'the puppet module {string} from {string} should have a branch {string} with a file named {string} which contains:' do |name, namespace, branch, filename, content|
68
91
  pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
69
92
  expect(pmrr.read_file(filename, branch)).to include(content)
@@ -83,3 +106,8 @@ Then('the puppet module {string} from {string} should not have a tag named {stri
83
106
  pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
84
107
  expect(pmrr.tags).not_to include(tag)
85
108
  end
109
+
110
+ Given 'the branch {string} of the puppet module {string} from {string} is deleted' do |branch, name, namespace|
111
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
112
+ pmrr.delete_branch(branch)
113
+ end
@@ -1,3 +1,7 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.command_name 'Cucumber'
4
+
1
5
  require 'aruba/cucumber'
2
6
 
3
7
  require_relative '../../spec/helpers/faker'
@@ -6,4 +10,9 @@ ModuleSync::Faker.working_directory = File.expand_path('faker', Aruba.config.wor
6
10
 
7
11
  Before do
8
12
  @aruba_timeout_seconds = 5
13
+
14
+ # This enables coverage when aruba runs `msync` executable (cf. `bin/msync`)
15
+ set_environment_variable('COVERAGE', '1')
16
+
17
+ aruba.config.activate_announcer_on_command_failure = %i[stdout stderr]
9
18
  end
@@ -16,9 +16,8 @@ Feature: Bump a new version after an update
16
16
  """
17
17
  <%= @configs['content'] %>
18
18
  """
19
- When I run `msync update --message "Add new-file" --bump --changelog --tag`
20
- Then the exit status should be 0
21
- And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
19
+ When I successfully run `msync update --verbose --message "Add new-file" --bump --changelog --tag`
20
+ Then the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
22
21
  And the stdout should contain:
23
22
  """
24
23
  Bumped to version 0.4.3
@@ -44,9 +43,8 @@ Feature: Bump a new version after an update
44
43
  """
45
44
  <%= @configs['content'] %>
46
45
  """
47
- When I run `msync update --message "Add new-file" --bump`
48
- Then the exit status should be 0
49
- And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
46
+ When I successfully run `msync update --message "Add new-file" --bump`
47
+ Then the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
50
48
  And the stdout should contain:
51
49
  """
52
50
  Bumped to version 0.4.3
@@ -67,9 +65,8 @@ Feature: Bump a new version after an update
67
65
  """
68
66
  <%= @configs['content'] %>
69
67
  """
70
- When I run `msync update --message "Add new-file" --bump --changelog`
71
- Then the exit status should be 0
72
- And the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
68
+ When I successfully run `msync update --message "Add new-file" --bump --changelog`
69
+ Then the file named "modules/fakenamespace/puppet-test/new-file" should contain "aruba"
73
70
  And the stdout should contain:
74
71
  """
75
72
  Bumped to version 0.4.3
@@ -81,7 +78,6 @@ Feature: Bump a new version after an update
81
78
  Scenario: Dont bump the module version after an update that produces no changes
82
79
  Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
83
80
  And a directory named "moduleroot"
84
- When I run `msync update --message "Add new-file" --bump --tag`
85
- Then the exit status should be 0
86
- And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
81
+ When I successfully run `msync update --message "Add new-file" --bump --tag`
82
+ Then the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
87
83
  And the puppet module "puppet-test" from "fakenamespace" should not have a tag named "0.4.3"