modulesync 1.2.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -169,7 +169,7 @@ msync hook activate
169
169
  ```
170
170
 
171
171
  If you have activated the hook but want to make changes to the configuration
172
- directory (such as changes to managed_modules.yml or modulesync.yml) without
172
+ directory (such as changes to `managed_modules.yml` or `modulesync.yml`) without
173
173
  touching the modules, you can deactivate the hook.
174
174
 
175
175
  ```
@@ -185,17 +185,38 @@ GitLab automatically with the `--pr` CLI option.
185
185
  msync update --pr
186
186
  ```
187
187
 
188
- You must set the `GITHUB_TOKEN` or `GITLAB_TOKEN` environment variable
189
- for GitHub PRs or GitLab MRs to work. Additional options:
188
+ In order for GitHub PRs or GitLab MRs to work, you must either provide
189
+ the `GITHUB_TOKEN` or `GITLAB_TOKEN` environment variables,
190
+ or set them per repository in `managed_modules.yml`, using the `github` or
191
+ `gitlab` keys respectively.
192
+
193
+ For GitHub Enterprise and self-hosted GitLab instances you also need to set the
194
+ `GITHUB_BASE_URL` or `GITLAB_BASE_URL` environment variables, or specify the
195
+ `base_url` parameter in `modulesync.yml`:
196
+
197
+ ```yaml
198
+ ---
199
+ repo1:
200
+ github:
201
+ token: 'EXAMPLE_TOKEN'
202
+ base_url: 'https://api.github.com/'
203
+
204
+ repo2:
205
+ gitlab:
206
+ token: 'EXAMPLE_TOKEN'
207
+ base_url: 'https://git.example.com/api/v4'
208
+ ```
209
+
210
+ Then:
190
211
 
191
212
  * Set the PR/MR title with `--pr-title` or in `modulesync.yml` with the
192
213
  `pr_title` attribute.
193
214
  * Assign labels to the PR/MR with `--pr-labels` or in `modulesync.yml` with
194
215
  the `pr_labels` attribute. **NOTE:** `pr_labels` should be a list. When
195
216
  using the `--pr-labels` CLI option, you should use a comma separated list.
217
+ * Set the target branch with `--pr-target-branch` or in `modulesync.yml` with
218
+ the `pr_target_branch` attribute.
196
219
 
197
- For GitHub Enterprise and self-hosted GitLab instances you need to set the
198
- `GITHUB_BASE_URL` or `GITLAB_BASE_URL` environment variable in addition.
199
220
  More details for GitHub:
200
221
 
201
222
  * Octokit [`api_endpoint`](https://github.com/octokit/octokit.rb#interacting-with-the-githubcom-apis-in-github-enterprise)
@@ -255,7 +276,9 @@ msync update -m "Commit message"
255
276
  Available parameters for modulesync.yml
256
277
 
257
278
  * `git_base` : The default URL to git clone from (Default: 'git@github.com:')
258
- * `namespace` : Namespace of the projects to manage (Default: 'puppetlabs')
279
+ * `namespace` : Namespace of the projects to manage (Default: 'puppetlabs').
280
+ This value can be overridden in the module name (e.g. 'namespace/mod') or by
281
+ using the `namespace` key for the module in `managed_modules.yml`.
259
282
  * `branch` : Branch to push to (Default: 'master')
260
283
  * `remote_branch` : Remote branch to push to (Default: Same value as branch)
261
284
  * `message` : Commit message to apply to updated modules.
data/Rakefile CHANGED
@@ -20,3 +20,27 @@ end
20
20
 
21
21
  task :test => %i[clean spec cucumber rubocop]
22
22
  task :default => %i[test]
23
+
24
+ begin
25
+ require 'github_changelog_generator/task'
26
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
27
+ config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
28
+ config.exclude_labels = %w[duplicate question invalid wontfix wont-fix modulesync skip-changelog]
29
+ config.user = 'voxpupuli'
30
+ config.project = 'modulesync'
31
+ config.future_release = Gem::Specification.load("#{config.project}.gemspec").version
32
+ end
33
+
34
+ # Workaround for https://github.com/github-changelog-generator/github-changelog-generator/issues/715
35
+ require 'rbconfig'
36
+ if RbConfig::CONFIG['host_os'] =~ /linux/
37
+ task :changelog do
38
+ puts 'Fixing line endings...'
39
+ changelog_file = File.join(__dir__, 'CHANGELOG.md')
40
+ changelog_txt = File.read(changelog_file)
41
+ new_contents = changelog_txt.gsub(/\r\n/, "\n")
42
+ File.open(changelog_file, 'w') { |file| file.puts new_contents }
43
+ end
44
+ end
45
+ rescue LoadError
46
+ end
data/features/cli.feature CHANGED
@@ -4,21 +4,26 @@ Feature: CLI
4
4
  Scenario: When passing no arguments to the msync command
5
5
  When I run `msync`
6
6
  And the output should match /Commands:/
7
+ Then the exit status should be 1
7
8
 
8
9
  Scenario: When passing invalid arguments to the msync update command
9
10
  When I run `msync update`
10
11
  And the output should match /No value provided for required option/
12
+ Then the exit status should be 1
11
13
 
12
14
  Scenario: When passing invalid arguments to the msync hook command
13
15
  When I run `msync hook`
14
16
  And the output should match /Commands:/
17
+ Then the exit status should be 1
15
18
 
16
- Scenario: When running the help subcommand
19
+ Scenario: When running the help command
17
20
  When I run `msync help`
18
21
  And the output should match /Commands:/
22
+ Then the exit status should be 0
19
23
 
20
24
  Scenario: When overriding a setting from the config file on the command line
21
- Given a file named "managed_modules.yml" with:
25
+ Given a puppet module "puppet-test" from "fakenamespace"
26
+ And a file named "managed_modules.yml" with:
22
27
  """
23
28
  ---
24
29
  - puppet-test
@@ -26,10 +31,13 @@ Feature: CLI
26
31
  And a file named "modulesync.yml" with:
27
32
  """
28
33
  ---
29
- namespace: maestrodev
30
- git_base: 'git@github.com:'
34
+ namespace: default
31
35
  """
36
+ And a git_base option appended to "modulesync.yml" for local tests
32
37
  And a directory named "moduleroot"
33
- When I run `msync update --noop --git-base https://github.com/`
38
+ When I run `msync update --noop --namespace fakenamespace --branch command-line-branch`
34
39
  Then the exit status should be 0
35
- And the output should not match /git@github.com:/
40
+ And the output should contain:
41
+ """
42
+ Creating new branch command-line-branch
43
+ """
@@ -5,8 +5,7 @@ Feature: hook
5
5
  Given a directory named ".git/hooks"
6
6
  When I run `msync hook activate`
7
7
  Then the exit status should be 0
8
- Given I run `cat .git/hooks/pre-push`
9
- Then the output should contain "bash"
8
+ And the file named ".git/hooks/pre-push" should contain "bash"
10
9
 
11
10
  Scenario: Deactivating a hook
12
11
  Given a file named ".git/hooks/pre-push" with:
@@ -21,8 +20,7 @@ Feature: hook
21
20
  Given a directory named ".git/hooks"
22
21
  When I run `msync hook activate -a '--foo bar --baz quux' -b master`
23
22
  Then the exit status should be 0
24
- Given I run `cat .git/hooks/pre-push`
25
- Then the output should match:
23
+ And the file named ".git/hooks/pre-push" should contain:
26
24
  """
27
- "\$message" -n puppetlabs -b master --foo bar --baz quux
25
+ "$message" -n puppetlabs -b master --foo bar --baz quux
28
26
  """
@@ -1,47 +1,85 @@
1
- Given 'a mocked git configuration' do
2
- steps %(
3
- Given a mocked home directory
4
- And I run `git config --global user.name Test`
5
- And I run `git config --global user.email test@example.com`
6
- )
7
- end
1
+ require_relative '../../spec/helpers/faker/puppet_module_remote_repo'
8
2
 
9
- Given 'a remote module repository' do
3
+ Given 'a basic setup with a puppet module {string} from {string}' do |name, namespace|
10
4
  steps %(
11
- Given a directory named "sources"
12
- And I run `git clone https://github.com/maestrodev/puppet-test sources/puppet-test`
5
+ Given a mocked git configuration
6
+ And a puppet module "#{name}" from "#{namespace}"
13
7
  And a file named "managed_modules.yml" with:
14
8
  """
15
9
  ---
16
- - puppet-test
10
+ - #{name}
17
11
  """
12
+ And a file named "modulesync.yml" with:
13
+ """
14
+ ---
15
+ namespace: #{namespace}
16
+ """
17
+ And a git_base option appended to "modulesync.yml" for local tests
18
18
  )
19
- write_file('modulesync.yml', <<-CONFIG)
20
- ---
21
- namespace: sources
22
- git_base: file://#{expand_path('.')}/
23
- CONFIG
24
19
  end
25
20
 
26
- Given Regexp.new(/a remote module repository with "(.+?)" as the default branch/) do |branch|
21
+ Given 'a mocked git configuration' do
27
22
  steps %(
28
- Given a directory named "sources"
29
- And I run `git clone --mirror https://github.com/maestrodev/puppet-test sources/puppet-test`
30
- And a file named "managed_modules.yml" with:
31
- """
32
- ---
33
- - puppet-test
34
- """
23
+ Given a mocked home directory
24
+ And I run `git config --global user.name Aruba`
25
+ And I run `git config --global user.email aruba@example.com`
35
26
  )
36
- write_file('modulesync.yml', <<-CONFIG)
37
- ---
38
- namespace: sources
39
- git_base: file://#{expand_path('.')}/
40
- CONFIG
41
- cd('sources/puppet-test') do
42
- steps %(
43
- And I run `git branch -M master #{branch}`
44
- And I run `git symbolic-ref HEAD refs/heads/#{branch}`
45
- )
46
- end
27
+ end
28
+
29
+ Given 'a puppet module {string} from {string}' do |name, namespace|
30
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
31
+ pmrr.populate
32
+ end
33
+
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'
36
+ end
37
+
38
+ Given 'the puppet module {string} from {string} is read-only' do |name, namespace|
39
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
40
+ pmrr.read_only = true
41
+ end
42
+
43
+ Then 'the puppet module {string} from {string} should have no commits between {string} and {string}' do |name, namespace, commit1, commit2|
44
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
45
+ expect(pmrr.commit_count_between(commit1, commit2)).to eq 0
46
+ end
47
+
48
+ Then 'the puppet module {string} from {string} should have( only) {int} commit(s) made by {string}' do |name, namespace, commit_count, author|
49
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
50
+ expect(pmrr.commit_count_by(author)).to eq commit_count
51
+ end
52
+
53
+ Then 'the puppet module {string} from {string} should have( only) {int} commit(s) made by {string} in branch {string}' do |name, namespace, commit_count, author, branch|
54
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
55
+ expect(pmrr.commit_count_by(author, branch)).to eq commit_count
56
+ end
57
+
58
+ Then 'the puppet module {string} from {string} should have no commits made by {string}' do |name, namespace, author|
59
+ step "the puppet module \"#{name}\" from \"#{namespace}\" should have 0 commits made by \"#{author}\""
60
+ end
61
+
62
+ Given 'the puppet module {string} from {string} has a file named {string} with:' do |name, namespace, filename, content|
63
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
64
+ pmrr.add_file(filename, content)
65
+ end
66
+
67
+ 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
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
69
+ expect(pmrr.read_file(filename, branch)).to include(content)
70
+ end
71
+
72
+ Given 'the puppet module {string} from {string} has the default branch named {string}' do |name, namespace, default_branch|
73
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
74
+ pmrr.default_branch = default_branch
75
+ end
76
+
77
+ Then('the puppet module {string} from {string} should have a tag named {string}') do |name, namespace, tag|
78
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
79
+ expect(pmrr.tags).to include(tag)
80
+ end
81
+
82
+ Then('the puppet module {string} from {string} should not have a tag named {string}') do |name, namespace, tag|
83
+ pmrr = ModuleSync::Faker::PuppetModuleRemoteRepo.new(name, namespace)
84
+ expect(pmrr.tags).not_to include(tag)
47
85
  end
@@ -1,5 +1,9 @@
1
1
  require 'aruba/cucumber'
2
2
 
3
+ require_relative '../../spec/helpers/faker'
4
+
5
+ ModuleSync::Faker.working_directory = File.expand_path('faker', Aruba.config.working_directory)
6
+
3
7
  Before do
4
8
  @aruba_timeout_seconds = 5
5
9
  end
@@ -2,17 +2,7 @@ Feature: update
2
2
  ModuleSync needs to update module boilerplate
3
3
 
4
4
  Scenario: Adding a new file
5
- Given a file named "managed_modules.yml" with:
6
- """
7
- ---
8
- - puppet-test
9
- """
10
- And a file named "modulesync.yml" with:
11
- """
12
- ---
13
- namespace: maestrodev
14
- git_base: https://github.com/
15
- """
5
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
16
6
  And a file named "config_defaults.yml" with:
17
7
  """
18
8
  ---
@@ -31,21 +21,11 @@ Feature: update
31
21
  Files added:
32
22
  test
33
23
  """
34
- Given I run `cat modules/maestrodev/puppet-test/test`
35
- Then the output should contain "aruba"
24
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
36
25
 
37
26
  Scenario: Using skip_broken option and adding a new file to repo without write access
38
- Given a file named "managed_modules.yml" with:
39
- """
40
- ---
41
- - puppet-test
42
- """
43
- And a file named "modulesync.yml" with:
44
- """
45
- ---
46
- namespace: maestrodev
47
- git_base: 'git@github.com:'
48
- """
27
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
28
+ And the puppet module "puppet-test" from "fakenamespace" is read-only
49
29
  And a file named "config_defaults.yml" with:
50
30
  """
51
31
  ---
@@ -59,19 +39,11 @@ Feature: update
59
39
  """
60
40
  When I run `msync update -s -m "Add test"`
61
41
  Then the exit status should be 0
42
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
62
43
 
63
44
  Scenario: Adding a new file to repo without write access
64
- Given a file named "managed_modules.yml" with:
65
- """
66
- ---
67
- - puppet-test
68
- """
69
- And a file named "modulesync.yml" with:
70
- """
71
- ---
72
- namespace: maestrodev
73
- git_base: 'git@github.com:'
74
- """
45
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
46
+ And the puppet module "puppet-test" from "fakenamespace" is read-only
75
47
  And a file named "config_defaults.yml" with:
76
48
  """
77
49
  ---
@@ -85,19 +57,10 @@ Feature: update
85
57
  """
86
58
  When I run `msync update -m "Add test" -r`
87
59
  Then the exit status should be 1
60
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
88
61
 
89
62
  Scenario: Adding a new file, without the .erb suffix
90
- Given a file named "managed_modules.yml" with:
91
- """
92
- ---
93
- - puppet-test
94
- """
95
- And a file named "modulesync.yml" with:
96
- """
97
- ---
98
- namespace: maestrodev
99
- git_base: https://github.com/
100
- """
63
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
101
64
  And a file named "config_defaults.yml" with:
102
65
  """
103
66
  ---
@@ -120,21 +83,11 @@ Feature: update
120
83
  Files added:
121
84
  test
122
85
  """
123
- Given I run `cat modules/maestrodev/puppet-test/test`
124
- Then the output should contain "aruba"
86
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
87
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
125
88
 
126
89
  Scenario: Adding a new file using global values
127
- Given a file named "managed_modules.yml" with:
128
- """
129
- ---
130
- - puppet-test
131
- """
132
- And a file named "modulesync.yml" with:
133
- """
134
- ---
135
- namespace: maestrodev
136
- git_base: https://github.com/
137
- """
90
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
138
91
  And a file named "config_defaults.yml" with:
139
92
  """
140
93
  ---
@@ -153,21 +106,11 @@ Feature: update
153
106
  Files added:
154
107
  test
155
108
  """
156
- Given I run `cat modules/maestrodev/puppet-test/test`
157
- Then the output should contain "aruba"
109
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
110
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
158
111
 
159
112
  Scenario: Adding a new file overriding global values
160
- Given a file named "managed_modules.yml" with:
161
- """
162
- ---
163
- - puppet-test
164
- """
165
- And a file named "modulesync.yml" with:
166
- """
167
- ---
168
- namespace: maestrodev
169
- git_base: https://github.com/
170
- """
113
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
171
114
  And a file named "config_defaults.yml" with:
172
115
  """
173
116
  ---
@@ -189,21 +132,11 @@ Feature: update
189
132
  Files added:
190
133
  test
191
134
  """
192
- Given I run `cat modules/maestrodev/puppet-test/test`
193
- Then the output should contain "aruba"
135
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
136
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
194
137
 
195
138
  Scenario: Adding a new file ignoring global values
196
- Given a file named "managed_modules.yml" with:
197
- """
198
- ---
199
- - puppet-test
200
- """
201
- And a file named "modulesync.yml" with:
202
- """
203
- ---
204
- namespace: maestrodev
205
- git_base: https://github.com/
206
- """
139
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
207
140
  And a file named "config_defaults.yml" with:
208
141
  """
209
142
  ---
@@ -225,21 +158,11 @@ Feature: update
225
158
  Files added:
226
159
  test
227
160
  """
228
- Given I run `cat modules/maestrodev/puppet-test/test`
229
- Then the output should contain "aruba"
161
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
162
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
230
163
 
231
164
  Scenario: Adding a file that ERB can't parse
232
- Given a file named "managed_modules.yml" with:
233
- """
234
- ---
235
- - puppet-test
236
- """
237
- And a file named "modulesync.yml" with:
238
- """
239
- ---
240
- namespace: maestrodev
241
- git_base: https://github.com/
242
- """
165
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
243
166
  And a file named "config_defaults.yml" with:
244
167
  """
245
168
  ---
@@ -255,19 +178,10 @@ Feature: update
255
178
  """
256
179
  When I run `msync update --noop`
257
180
  Then the exit status should be 1
181
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
258
182
 
259
183
  Scenario: Using skip_broken option with invalid files
260
- Given a file named "managed_modules.yml" with:
261
- """
262
- ---
263
- - puppet-test
264
- """
265
- And a file named "modulesync.yml" with:
266
- """
267
- ---
268
- namespace: maestrodev
269
- git_base: https://github.com/
270
- """
184
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
271
185
  And a file named "config_defaults.yml" with:
272
186
  """
273
187
  ---
@@ -283,19 +197,10 @@ Feature: update
283
197
  """
284
198
  When I run `msync update --noop -s`
285
199
  Then the exit status should be 0
200
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
286
201
 
287
202
  Scenario: Using skip_broken and fail_on_warnings options with invalid files
288
- Given a file named "managed_modules.yml" with:
289
- """
290
- ---
291
- - puppet-test
292
- """
293
- And a file named "modulesync.yml" with:
294
- """
295
- ---
296
- namespace: maestrodev
297
- git_base: https://github.com/
298
- """
203
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
299
204
  And a file named "config_defaults.yml" with:
300
205
  """
301
206
  ---
@@ -311,18 +216,13 @@ Feature: update
311
216
  """
312
217
  When I run `msync update --noop --skip_broken --fail_on_warnings`
313
218
  Then the exit status should be 1
219
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
314
220
 
315
221
  Scenario: Modifying an existing file
316
- Given a file named "managed_modules.yml" with:
317
- """
318
- ---
319
- - puppet-test
222
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
223
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "Gemfile" with:
320
224
  """
321
- And a file named "modulesync.yml" with:
322
- """
323
- ---
324
- namespace: maestrodev
325
- git_base: https://github.com/
225
+ source 'https://example.com'
326
226
  """
327
227
  And a file named "config_defaults.yml" with:
328
228
  """
@@ -342,15 +242,18 @@ Feature: update
342
242
  Files changed:
343
243
  +diff --git a/Gemfile b/Gemfile
344
244
  """
345
- Given I run `cat modules/maestrodev/puppet-test/Gemfile`
346
- Then the output should contain:
245
+ And the file named "modules/fakenamespace/puppet-test/Gemfile" should contain:
347
246
  """
348
247
  source 'https://somehost.com'
349
248
  """
249
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
350
250
 
351
251
  Scenario: Modifying an existing file and committing the change
352
- Given a mocked git configuration
353
- And a remote module repository
252
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
253
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "Gemfile" with:
254
+ """
255
+ source 'https://example.com'
256
+ """
354
257
  And a file named "config_defaults.yml" with:
355
258
  """
356
259
  ---
@@ -364,30 +267,25 @@ Feature: update
364
267
  """
365
268
  When I run `msync update -m "Update Gemfile" -r test`
366
269
  Then the exit status should be 0
367
- Given I cd to "sources/puppet-test"
368
- And I run `git checkout test`
369
- Then the file "Gemfile" should contain:
270
+ And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
271
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
272
+ And the puppet module "puppet-test" from "fakenamespace" should have a branch "test" with a file named "Gemfile" which contains:
370
273
  """
371
274
  source 'https://somehost.com'
372
275
  """
373
276
 
374
277
  Scenario: Setting an existing file to unmanaged
375
- Given a file named "managed_modules.yml" with:
376
- """
377
- ---
378
- - puppet-test
379
- """
380
- And a file named "modulesync.yml" with:
278
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
279
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "Gemfile" with:
381
280
  """
382
- ---
383
- namespace: maestrodev
384
- git_base: https://github.com/
281
+ source 'https://rubygems.org'
385
282
  """
386
283
  And a file named "config_defaults.yml" with:
387
284
  """
388
285
  ---
389
286
  Gemfile:
390
287
  unmanaged: true
288
+ gem_source: https://somehost.com
391
289
  """
392
290
  And a directory named "moduleroot"
393
291
  And a file named "moduleroot/Gemfile.erb" with:
@@ -402,27 +300,17 @@ Feature: update
402
300
  """
403
301
  And the output should match:
404
302
  """
405
- Not managing Gemfile in puppet-test
303
+ Not managing 'Gemfile' in 'puppet-test'
406
304
  """
407
305
  And the exit status should be 0
408
- Given I run `cat modules/maestrodev/puppet-test/Gemfile`
409
- Then the output should contain:
306
+ And the file named "modules/fakenamespace/puppet-test/Gemfile" should contain:
410
307
  """
411
308
  source 'https://rubygems.org'
412
309
  """
310
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
413
311
 
414
312
  Scenario: Setting an existing file to deleted
415
- Given a file named "managed_modules.yml" with:
416
- """
417
- ---
418
- - puppet-test
419
- """
420
- And a file named "modulesync.yml" with:
421
- """
422
- ---
423
- namespace: maestrodev
424
- git_base: https://github.com/
425
- """
313
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
426
314
  And a file named "config_defaults.yml" with:
427
315
  """
428
316
  ---
@@ -434,6 +322,10 @@ Feature: update
434
322
  """
435
323
  source '<%= @configs['gem_source'] %>'
436
324
  """
325
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "Gemfile" with:
326
+ """
327
+ source 'https://rubygems.org'
328
+ """
437
329
  When I run `msync update --noop`
438
330
  Then the output should match:
439
331
  """
@@ -442,19 +334,10 @@ Feature: update
442
334
  deleted file mode 100644
443
335
  """
444
336
  And the exit status should be 0
337
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
445
338
 
446
339
  Scenario: Setting a non-existent file to deleted
447
- Given a file named "managed_modules.yml" with:
448
- """
449
- ---
450
- - puppet-test
451
- """
452
- And a file named "modulesync.yml" with:
453
- """
454
- ---
455
- namespace: maestrodev
456
- git_base: https://github.com/
457
- """
340
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
458
341
  And a file named "config_defaults.yml" with:
459
342
  """
460
343
  ---
@@ -464,19 +347,10 @@ Feature: update
464
347
  And a directory named "moduleroot"
465
348
  When I run `msync update -m 'deletes a file that doesnt exist!' -f puppet-test`
466
349
  And the exit status should be 0
350
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
467
351
 
468
352
  Scenario: Setting a directory to unmanaged
469
- Given a file named "managed_modules.yml" with:
470
- """
471
- ---
472
- - puppetlabs-apache
473
- """
474
- And a file named "modulesync.yml" with:
475
- """
476
- ---
477
- namespace: puppetlabs
478
- git_base: https://github.com/
479
- """
353
+ Given a basic setup with a puppet module "puppet-apache" from "puppetlabs"
480
354
  And a file named "config_defaults.yml" with:
481
355
  """
482
356
  ---
@@ -488,36 +362,26 @@ Feature: update
488
362
  """
489
363
  some spec_helper fud
490
364
  """
491
- And a directory named "modules/puppetlabs/puppetlabs-apache/spec"
492
- And a file named "modules/puppetlabs/puppetlabs-apache/spec/spec_helper.rb" with:
365
+ And a directory named "modules/puppetlabs/puppet-apache/spec"
366
+ And a file named "modules/puppetlabs/puppet-apache/spec/spec_helper.rb" with:
493
367
  """
494
368
  This is a fake spec_helper!
495
369
  """
496
370
  When I run `msync update --offline`
497
371
  Then the output should contain:
498
372
  """
499
- Not managing spec/spec_helper.rb in puppetlabs-apache
373
+ Not managing 'spec/spec_helper.rb' in 'puppet-apache'
500
374
  """
501
375
  And the exit status should be 0
502
- Given I run `cat modules/puppetlabs/puppetlabs-apache/spec/spec_helper.rb`
503
- Then the output should contain:
376
+ And the file named "modules/puppetlabs/puppet-apache/spec/spec_helper.rb" should contain:
504
377
  """
505
378
  This is a fake spec_helper!
506
379
  """
507
380
  And the exit status should be 0
381
+ And the puppet module "puppet-apache" from "puppetlabs" should have no commits made by "Aruba"
508
382
 
509
383
  Scenario: Adding a new file in a new subdirectory
510
- Given a file named "managed_modules.yml" with:
511
- """
512
- ---
513
- - puppet-test
514
- """
515
- And a file named "modulesync.yml" with:
516
- """
517
- ---
518
- namespace: maestrodev
519
- git_base: https://github.com/
520
- """
384
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
521
385
  And a file named "config_defaults.yml" with:
522
386
  """
523
387
  ---
@@ -538,24 +402,14 @@ Feature: update
538
402
  Files added:
539
403
  spec/spec_helper.rb
540
404
  """
541
- Given I run `cat modules/maestrodev/puppet-test/spec/spec_helper.rb`
542
- Then the output should contain:
405
+ And the file named "modules/fakenamespace/puppet-test/spec/spec_helper.rb" should contain:
543
406
  """
544
407
  require 'puppetlabs_spec_helper/module_helper'
545
408
  """
409
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
546
410
 
547
411
  Scenario: Updating offline
548
- Given a file named "managed_modules.yml" with:
549
- """
550
- ---
551
- - puppet-test
552
- """
553
- And a file named "modulesync.yml" with:
554
- """
555
- ---
556
- namespace: maestrodev
557
- git_base: https://github.com/
558
- """
412
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
559
413
  And a file named "config_defaults.yml" with:
560
414
  """
561
415
  ---
@@ -572,19 +426,15 @@ Feature: update
572
426
  When I run `msync update --offline`
573
427
  Then the exit status should be 0
574
428
  And the output should not match /Files (changed|added|deleted):/
429
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
575
430
 
576
431
  Scenario: Pulling a module that already exists in the modules directory
577
- Given a file named "managed_modules.yml" with:
578
- """
579
- ---
580
- - maestrodev/puppet-test
581
- """
582
- And a file named "modulesync.yml" with:
583
- """
584
- ---
585
- git_base: https://github.com/
586
- """
587
- And a file named "config_defaults.yml" with:
432
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
433
+ And a directory named "moduleroot"
434
+ When I run `msync update --message "First update run"`
435
+ Then the exit status should be 0
436
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
437
+ Given a file named "config_defaults.yml" with:
588
438
  """
589
439
  ---
590
440
  spec/spec_helper.rb:
@@ -597,20 +447,6 @@ Feature: update
597
447
  require '<%= required %>'
598
448
  <% end %>
599
449
  """
600
- Given I run `git init modules/maestrodev/puppet-test`
601
- Given a file named "modules/maestrodev/puppet-test/.git/config" with:
602
- """
603
- [core]
604
- repositoryformatversion = 0
605
- filemode = true
606
- bare = false
607
- logallrefupdates = true
608
- ignorecase = true
609
- precomposeunicode = true
610
- [remote "origin"]
611
- url = https://github.com/maestrodev/puppet-test.git
612
- fetch = +refs/heads/*:refs/remotes/origin/*
613
- """
614
450
  When I run `msync update --noop`
615
451
  Then the exit status should be 0
616
452
  And the output should match:
@@ -618,37 +454,24 @@ Feature: update
618
454
  Files added:
619
455
  spec/spec_helper.rb
620
456
  """
457
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
621
458
 
622
- Scenario: When running update with no changes
623
- Given a file named "managed_modules.yml" with:
624
- """
625
- ---
626
- - puppet-test
627
- """
628
- And a file named "modulesync.yml" with:
629
- """
630
- ---
631
- namespace: maestrodev
632
- git_base: https://github.com/
633
- """
459
+ Scenario: When running update without changes
460
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
634
461
  And a directory named "moduleroot"
635
- When I run `msync update --noop`
462
+ When I run `msync update --message "Running without changes"`
636
463
  Then the exit status should be 0
637
- And the output should not match /diff/
464
+ And the stdout should contain "There were no changes in 'modules/fakenamespace/puppet-test'. Not committing."
465
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
638
466
 
639
467
  Scenario: When specifying configurations in managed_modules.yml
640
- Given a file named "managed_modules.yml" with:
468
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
469
+ And a file named "managed_modules.yml" with:
641
470
  """
642
471
  ---
643
472
  puppet-test:
644
473
  module_name: test
645
474
  """
646
- And a file named "modulesync.yml" with:
647
- """
648
- ---
649
- namespace: maestrodev
650
- git_base: https://github.com/
651
- """
652
475
  And a file named "config_defaults.yml" with:
653
476
  """
654
477
  ---
@@ -667,11 +490,14 @@ Feature: update
667
490
  Files added:
668
491
  test
669
492
  """
670
- Given I run `cat modules/maestrodev/puppet-test/test`
671
- Then the output should contain "aruba"
493
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
494
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
672
495
 
673
496
  Scenario: When specifying configurations in managed_modules.yml and using a filter
674
- Given a file named "managed_modules.yml" with:
497
+ Given a mocked git configuration
498
+ And a puppet module "puppet-test" from "fakenamespace"
499
+ And a puppet module "puppet-blacksmith" from "fakenamespace"
500
+ And a file named "managed_modules.yml" with:
675
501
  """
676
502
  ---
677
503
  puppet-blacksmith:
@@ -681,9 +507,9 @@ Feature: update
681
507
  And a file named "modulesync.yml" with:
682
508
  """
683
509
  ---
684
- namespace: maestrodev
685
- git_base: https://github.com/
510
+ namespace: fakenamespace
686
511
  """
512
+ And a git_base option appended to "modulesync.yml" for local tests
687
513
  And a file named "config_defaults.yml" with:
688
514
  """
689
515
  ---
@@ -702,12 +528,15 @@ Feature: update
702
528
  Files added:
703
529
  test
704
530
  """
705
- Given I run `cat modules/maestrodev/puppet-test/test`
706
- Then the output should contain "aruba"
707
- And a directory named "modules/maestrodev/puppet-blacksmith" should not exist
531
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
532
+ And a directory named "modules/fakenamespace/puppet-blacksmith" should not exist
533
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
708
534
 
709
535
  Scenario: When specifying configurations in managed_modules.yml and using a negative filter
710
- Given a file named "managed_modules.yml" with:
536
+ Given a mocked git configuration
537
+ And a puppet module "puppet-test" from "fakenamespace"
538
+ And a puppet module "puppet-blacksmith" from "fakenamespace"
539
+ And a file named "managed_modules.yml" with:
711
540
  """
712
541
  ---
713
542
  puppet-blacksmith:
@@ -717,9 +546,9 @@ Feature: update
717
546
  And a file named "modulesync.yml" with:
718
547
  """
719
548
  ---
720
- namespace: maestrodev
721
- git_base: https://github.com/
549
+ namespace: fakenamespace
722
550
  """
551
+ And a git_base option appended to "modulesync.yml" for local tests
723
552
  And a file named "config_defaults.yml" with:
724
553
  """
725
554
  ---
@@ -738,21 +567,12 @@ Feature: update
738
567
  Files added:
739
568
  test
740
569
  """
741
- Given I run `cat modules/maestrodev/puppet-test/test`
742
- Then the output should contain "aruba"
743
- And a directory named "modules/maestrodev/puppet-blacksmith" should not exist
570
+ And the file named "modules/fakenamespace/puppet-test/test" should contain "aruba"
571
+ And a directory named "modules/fakenamespace/puppet-blacksmith" should not exist
572
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
744
573
 
745
574
  Scenario: Updating a module with a .sync.yml file
746
- Given a file named "managed_modules.yml" with:
747
- """
748
- ---
749
- - maestrodev/puppet-test
750
- """
751
- And a file named "modulesync.yml" with:
752
- """
753
- ---
754
- git_base: https://github.com/
755
- """
575
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
756
576
  And a file named "config_defaults.yml" with:
757
577
  """
758
578
  ---
@@ -775,21 +595,7 @@ Feature: update
775
595
  <%= @configs['global-to-overwrite'] %>
776
596
  <%= @configs['module-default'] %>
777
597
  """
778
- Given I run `git init modules/maestrodev/puppet-test`
779
- Given a file named "modules/maestrodev/puppet-test/.git/config" with:
780
- """
781
- [core]
782
- repositoryformatversion = 0
783
- filemode = true
784
- bare = false
785
- logallrefupdates = true
786
- ignorecase = true
787
- precomposeunicode = true
788
- [remote "origin"]
789
- url = https://github.com/maestrodev/puppet-test.git
790
- fetch = +refs/heads/*:refs/remotes/origin/*
791
- """
792
- Given a file named "modules/maestrodev/puppet-test/.sync.yml" with:
598
+ And the puppet module "puppet-test" from "fakenamespace" has a file named ".sync.yml" with:
793
599
  """
794
600
  ---
795
601
  :global:
@@ -802,18 +608,21 @@ Feature: update
802
608
  Then the exit status should be 0
803
609
  And the output should match:
804
610
  """
805
- Not managing spec/spec_helper.rb in puppet-test
611
+ Not managing 'spec/spec_helper.rb' in 'puppet-test'
806
612
  """
807
- Given I run `cat modules/maestrodev/puppet-test/global-test.md`
808
- Then the output should match:
613
+ And the file named "modules/fakenamespace/puppet-test/global-test.md" should contain:
809
614
  """
810
615
  some-default
811
616
  it-is-overwritten
812
617
  some-value
813
618
  """
619
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
814
620
 
815
621
  Scenario: Module with custom namespace
816
- Given a file named "managed_modules.yml" with:
622
+ Given a mocked git configuration
623
+ And a puppet module "puppet-test" from "fakenamespace"
624
+ And a puppet module "puppet-lib-file_concat" from "electrical"
625
+ And a file named "managed_modules.yml" with:
817
626
  """
818
627
  ---
819
628
  - puppet-test
@@ -822,9 +631,9 @@ Feature: update
822
631
  And a file named "modulesync.yml" with:
823
632
  """
824
633
  ---
825
- namespace: maestrodev
826
- git_base: https://github.com/
634
+ namespace: fakenamespace
827
635
  """
636
+ And a git_base option appended to "modulesync.yml" for local tests
828
637
  And a file named "config_defaults.yml" with:
829
638
  """
830
639
  ---
@@ -843,23 +652,13 @@ Feature: update
843
652
  Files added:
844
653
  test
845
654
  """
846
- Given I run `cat modules/maestrodev/puppet-test/.git/config`
847
- Then the output should contain "url = https://github.com/maestrodev/puppet-test.git"
848
- Given I run `cat modules/electrical/puppet-lib-file_concat/.git/config`
849
- Then the output should contain "url = https://github.com/electrical/puppet-lib-file_concat.git"
655
+ And the file named "modules/fakenamespace/puppet-test/.git/config" should match /^\s+url = .*fakenamespace.puppet-test$/
656
+ And the file named "modules/electrical/puppet-lib-file_concat/.git/config" should match /^\s+url = .*electrical.puppet-lib-file_concat$/
657
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
658
+ And the puppet module "puppet-lib-file_concat" from "electrical" should have no commits made by "Aruba"
850
659
 
851
660
  Scenario: Modifying an existing file with values exposed by the module
852
- Given a file named "managed_modules.yml" with:
853
- """
854
- ---
855
- - puppet-test
856
- """
857
- And a file named "modulesync.yml" with:
858
- """
859
- ---
860
- namespace: maestrodev
861
- git_base: https://github.com/
862
- """
661
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
863
662
  And a file named "config_defaults.yml" with:
864
663
  """
865
664
  ---
@@ -868,7 +667,12 @@ Feature: update
868
667
  And a directory named "moduleroot"
869
668
  And a file named "moduleroot/README.md.erb" with:
870
669
  """
871
- echo '<%= @configs[:git_base] + @configs[:namespace] %>'
670
+ module: <%= @configs[:puppet_module] %>
671
+ namespace: <%= @configs[:namespace] %>
672
+ """
673
+ And the puppet module "puppet-test" from "fakenamespace" has a file named "README.md" with:
674
+ """
675
+ Hello world!
872
676
  """
873
677
  When I run `msync update --noop`
874
678
  Then the exit status should be 0
@@ -877,15 +681,15 @@ Feature: update
877
681
  Files changed:
878
682
  +diff --git a/README.md b/README.md
879
683
  """
880
- Given I run `cat modules/maestrodev/puppet-test/README.md`
881
- Then the output should contain:
684
+ And the file named "modules/fakenamespace/puppet-test/README.md" should contain:
882
685
  """
883
- echo 'https://github.com/maestrodev'
686
+ module: puppet-test
687
+ namespace: fakenamespace
884
688
  """
689
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
885
690
 
886
691
  Scenario: Running the same update twice and pushing to a remote branch
887
- Given a mocked git configuration
888
- And a remote module repository
692
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
889
693
  And a file named "config_defaults.yml" with:
890
694
  """
891
695
  ---
@@ -899,15 +703,41 @@ Feature: update
899
703
  """
900
704
  When I run `msync update -m "Update Gemfile" -r test`
901
705
  Then the exit status should be 0
706
+ And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
707
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
902
708
  Given I remove the directory "modules"
903
709
  When I run `msync update -m "Update Gemfile" -r test`
904
710
  Then the exit status should be 0
905
711
  Then the output should not contain "error"
906
712
  Then the output should not contain "rejected"
713
+ And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
714
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "test"
715
+
716
+ Scenario: Creating a GitHub PR with an update
717
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
718
+ And a directory named "moduleroot"
719
+ And I set the environment variables to:
720
+ | variable | value |
721
+ | GITHUB_TOKEN | foobar |
722
+ When I run `msync update --noop --branch managed_update --pr`
723
+ Then the output should contain "Would submit PR "
724
+ And the exit status should be 0
725
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
726
+
727
+ Scenario: Creating a GitLab MR with an update
728
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
729
+ And a directory named "moduleroot"
730
+ And I set the environment variables to:
731
+ | variable | value |
732
+ | GITLAB_TOKEN | foobar |
733
+ When I run `msync update --noop --branch managed_update --pr`
734
+ Then the output should contain "Would submit MR "
735
+ And the exit status should be 0
736
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"
907
737
 
908
738
  Scenario: Repository with a default branch other than master
909
- Given a mocked git configuration
910
- And a remote module repository with "develop" as the default branch
739
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
740
+ And the puppet module "puppet-test" from "fakenamespace" has the default branch named "develop"
911
741
  And a file named "config_defaults.yml" with:
912
742
  """
913
743
  ---
@@ -921,24 +751,16 @@ Feature: update
921
751
  """
922
752
  When I run `msync update -m "Update Gemfile"`
923
753
  Then the exit status should be 0
924
- Then the output should contain "Using repository's default branch: develop"
754
+ And the output should contain "Using repository's default branch: develop"
755
+ And the puppet module "puppet-test" from "fakenamespace" should have only 1 commit made by "Aruba"
756
+ And the puppet module "puppet-test" from "fakenamespace" should have 1 commit made by "Aruba" in branch "develop"
925
757
 
926
- Scenario: Adding a new file from a template using meta data
758
+ Scenario: Adding a new file from a template using metadata
759
+ Given a basic setup with a puppet module "puppet-test" from "fakenamespace"
927
760
  And a file named "config_defaults.yml" with:
928
761
  """
929
762
  ---
930
763
  """
931
- Given a file named "managed_modules.yml" with:
932
- """
933
- ---
934
- - puppet-test
935
- """
936
- And a file named "modulesync.yml" with:
937
- """
938
- ---
939
- namespace: maestrodev
940
- git_base: https://github.com/
941
- """
942
764
  And a directory named "moduleroot"
943
765
  And a file named "moduleroot/test.erb" with:
944
766
  """
@@ -948,10 +770,10 @@ Feature: update
948
770
  """
949
771
  When I run `msync update --noop`
950
772
  Then the exit status should be 0
951
- Given I run `cat modules/maestrodev/puppet-test/test`
952
- Then the output should contain:
773
+ And the file named "modules/fakenamespace/puppet-test/test" should contain:
953
774
  """
954
775
  module: puppet-test
955
- target: modules/maestrodev/puppet-test/test
956
- workdir: modules/maestrodev/puppet-test
776
+ target: modules/fakenamespace/puppet-test/test
777
+ workdir: modules/fakenamespace/puppet-test
957
778
  """
779
+ And the puppet module "puppet-test" from "fakenamespace" should have no commits made by "Aruba"