r10k 3.5.1 → 3.9.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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/.github/pull_request_template.md +4 -1
  3. data/.github/workflows/docker.yml +4 -1
  4. data/.github/workflows/release.yml +3 -2
  5. data/.github/workflows/rspec_tests.yml +81 -0
  6. data/.travis.yml +8 -1
  7. data/CHANGELOG.mkd +43 -2
  8. data/CODEOWNERS +2 -2
  9. data/README.mkd +13 -4
  10. data/doc/common-patterns.mkd +1 -0
  11. data/doc/dynamic-environments/configuration.mkd +143 -39
  12. data/doc/dynamic-environments/usage.mkd +12 -11
  13. data/doc/puppetfile.mkd +23 -3
  14. data/docker/Gemfile +1 -1
  15. data/docker/Makefile +7 -4
  16. data/docker/docker-compose.yml +18 -0
  17. data/docker/r10k/Dockerfile +4 -3
  18. data/docker/r10k/docker-entrypoint.sh +0 -1
  19. data/docker/r10k/release.Dockerfile +3 -2
  20. data/docker/spec/dockerfile_spec.rb +26 -32
  21. data/integration/tests/git_source/git_source_repeated_remote.rb +68 -0
  22. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module.rb +2 -1
  23. data/integration/tests/user_scenario/basic_workflow/multi_env_custom_forge_git_module_static.rb +2 -1
  24. data/integration/tests/user_scenario/basic_workflow/multi_source_custom_forge_git_module.rb +1 -1
  25. data/integration/tests/user_scenario/basic_workflow/single_env_custom_forge_git_module.rb +2 -1
  26. data/integration/tests/user_scenario/complex_workflow/multi_env_add_change_remove.rb +1 -1
  27. data/integration/tests/user_scenario/complex_workflow/multi_env_remove_re-add.rb +1 -1
  28. data/integration/tests/user_scenario/complex_workflow/multi_env_unamanaged.rb +1 -1
  29. data/lib/r10k/action/deploy/display.rb +9 -3
  30. data/lib/r10k/action/deploy/environment.rb +39 -14
  31. data/lib/r10k/action/deploy/module.rb +4 -1
  32. data/lib/r10k/action/runner.rb +34 -0
  33. data/lib/r10k/cli/deploy.rb +14 -7
  34. data/lib/r10k/cli/puppetfile.rb +5 -5
  35. data/lib/r10k/environment/base.rb +9 -2
  36. data/lib/r10k/environment/git.rb +17 -2
  37. data/lib/r10k/environment/name.rb +22 -4
  38. data/lib/r10k/environment/svn.rb +11 -2
  39. data/lib/r10k/environment/with_modules.rb +28 -20
  40. data/lib/r10k/forge/module_release.rb +2 -2
  41. data/lib/r10k/git.rb +1 -0
  42. data/lib/r10k/git/cache.rb +12 -4
  43. data/lib/r10k/git/rugged/credentials.rb +39 -2
  44. data/lib/r10k/git/stateful_repository.rb +4 -0
  45. data/lib/r10k/initializers.rb +2 -0
  46. data/lib/r10k/module/base.rb +8 -0
  47. data/lib/r10k/module/forge.rb +16 -4
  48. data/lib/r10k/module/git.rb +42 -24
  49. data/lib/r10k/module/local.rb +1 -1
  50. data/lib/r10k/module/svn.rb +14 -11
  51. data/lib/r10k/puppetfile.rb +30 -12
  52. data/lib/r10k/settings.rb +30 -3
  53. data/lib/r10k/source/base.rb +5 -0
  54. data/lib/r10k/source/git.rb +26 -3
  55. data/lib/r10k/source/hash.rb +4 -2
  56. data/lib/r10k/source/svn.rb +5 -1
  57. data/lib/r10k/util/setopts.rb +33 -12
  58. data/lib/r10k/version.rb +1 -1
  59. data/locales/r10k.pot +71 -43
  60. data/r10k.gemspec +1 -1
  61. data/spec/fixtures/unit/action/r10k_creds.yaml +9 -0
  62. data/spec/shared-examples/subprocess-runner.rb +11 -5
  63. data/spec/unit/action/deploy/display_spec.rb +4 -0
  64. data/spec/unit/action/deploy/environment_spec.rb +154 -12
  65. data/spec/unit/action/deploy/module_spec.rb +40 -1
  66. data/spec/unit/action/puppetfile/install_spec.rb +1 -0
  67. data/spec/unit/action/runner_spec.rb +48 -1
  68. data/spec/unit/environment/git_spec.rb +19 -2
  69. data/spec/unit/environment/name_spec.rb +28 -0
  70. data/spec/unit/environment/svn_spec.rb +12 -0
  71. data/spec/unit/environment/with_modules_spec.rb +74 -0
  72. data/spec/unit/forge/module_release_spec.rb +14 -10
  73. data/spec/unit/git/cache_spec.rb +10 -0
  74. data/spec/unit/git/rugged/credentials_spec.rb +79 -2
  75. data/spec/unit/git_spec.rb +3 -3
  76. data/spec/unit/module/forge_spec.rb +6 -0
  77. data/spec/unit/module/git_spec.rb +56 -1
  78. data/spec/unit/module_spec.rb +59 -9
  79. data/spec/unit/puppetfile_spec.rb +61 -7
  80. data/spec/unit/settings_spec.rb +12 -0
  81. data/spec/unit/source/git_spec.rb +49 -1
  82. data/spec/unit/util/setopts_spec.rb +25 -1
  83. metadata +9 -11
  84. data/azure-pipelines.yml +0 -86
@@ -3,20 +3,70 @@ require 'r10k/module'
3
3
 
4
4
  describe R10K::Module do
5
5
  describe 'delegating to R10K::Module::Git' do
6
- it "accepts args {:git => 'git url}" do
7
- obj = R10K::Module.new('foo', '/modulepath', :git => 'git url')
8
- expect(obj).to be_a_kind_of(R10K::Module::Git)
6
+ [ {git: 'git url'},
7
+ {type: 'git', source: 'git url'},
8
+ ].each do |scenario|
9
+ it "accepts a name matching 'test' and args #{scenario.inspect}" do
10
+ obj = R10K::Module.new('test', '/modulepath', scenario)
11
+ expect(obj).to be_a_kind_of(R10K::Module::Git)
12
+ expect(obj.send(:instance_variable_get, :'@remote')).to eq('git url')
13
+ end
14
+ end
15
+ end
16
+
17
+ describe 'delegating to R10K::Module::Svn' do
18
+ [ {svn: 'svn url'},
19
+ {type: 'svn', source: 'svn url'},
20
+ ].each do |scenario|
21
+ it "accepts a name matching 'test' and args #{scenario.inspect}" do
22
+ obj = R10K::Module.new('test', '/modulepath', scenario)
23
+ expect(obj).to be_a_kind_of(R10K::Module::SVN)
24
+ expect(obj.send(:instance_variable_get, :'@url')).to eq('svn url')
25
+ end
9
26
  end
10
27
  end
11
28
 
12
29
  describe 'delegating to R10K::Module::Forge' do
13
- [
14
- ['bar/quux', nil],
15
- ['bar-quux', nil],
16
- ['bar/quux', '8.0.0'],
30
+ [ 'bar/quux',
31
+ 'bar-quux',
17
32
  ].each do |scenario|
18
- it "accepts a name matching #{scenario[0]} and args #{scenario[1].inspect}" do
19
- expect(R10K::Module.new(scenario[0], '/modulepath', scenario[1])).to be_a_kind_of(R10K::Module::Forge)
33
+ it "accepts a name matching #{scenario} and args nil" do
34
+ obj = R10K::Module.new(scenario, '/modulepath', nil)
35
+ expect(obj).to be_a_kind_of(R10K::Module::Forge)
36
+ end
37
+ end
38
+ [ '8.0.0',
39
+ {type: 'forge', version: '8.0.0'},
40
+ ].each do |scenario|
41
+ it "accepts a name matching bar-quux and args #{scenario.inspect}" do
42
+ obj = R10K::Module.new('bar-quux', '/modulepath', scenario)
43
+ expect(obj).to be_a_kind_of(R10K::Module::Forge)
44
+ expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('8.0.0')
45
+ end
46
+ end
47
+
48
+ describe 'when the module is ostensibly on disk' do
49
+ before do
50
+ owner = 'theowner'
51
+ module_name = 'themodulename'
52
+ @title = "#{owner}-#{module_name}"
53
+ metadata = <<~METADATA
54
+ {
55
+ "name": "#{@title}",
56
+ "version": "1.2.0"
57
+ }
58
+ METADATA
59
+ @dirname = Dir.mktmpdir
60
+ module_path = File.join(@dirname, module_name)
61
+ FileUtils.mkdir(module_path)
62
+ File.open("#{module_path}/metadata.json", 'w') do |file|
63
+ file.write(metadata)
64
+ end
65
+ end
66
+
67
+ it 'sets the expected version to what is found in the metadata' do
68
+ obj = R10K::Module.new(@title, @dirname, nil)
69
+ expect(obj.send(:instance_variable_get, :'@expected_version')).to eq('1.2.0')
20
70
  end
21
71
  end
22
72
  end
@@ -127,6 +127,17 @@ describe R10K::Puppetfile do
127
127
 
128
128
  expect { subject.add_module('puppet/test_module', module_opts) }.to raise_error(R10K::Error, /cannot manage content.*is not within/i).and not_change { subject.modules }
129
129
  end
130
+
131
+ it "should disable and not add modules that conflict with the environment" do
132
+ env = instance_double('R10K::Environment::Base')
133
+ mod = instance_double('R10K::Module::Base', name: 'conflict', origin: :puppetfile)
134
+ allow(mod).to receive(:origin=).and_return(nil)
135
+ allow(subject).to receive(:environment).and_return(env)
136
+ allow(env).to receive(:'module_conflicts?').with(mod).and_return(true)
137
+
138
+ allow(R10K::Module).to receive(:new).with('test', anything, anything, anything).and_return(mod)
139
+ expect { subject.add_module('test', {}) }.not_to change { subject.modules }
140
+ end
130
141
  end
131
142
 
132
143
  describe "#purge_exclusions" do
@@ -154,6 +165,26 @@ describe R10K::Puppetfile do
154
165
  end
155
166
  end
156
167
 
168
+ describe '#managed_directories' do
169
+ it 'returns an array of paths that can be purged' do
170
+ allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.moduledir, '1.2.3', anything).and_call_original
171
+
172
+ subject.add_module('puppet/test_module', '1.2.3')
173
+ expect(subject.managed_directories).to match_array(["/some/nonexistent/basedir/modules"])
174
+ end
175
+
176
+ context 'with a module with install_path == \'\'' do
177
+ it 'basedir isn\'t in the list of paths to purge' do
178
+ module_opts = { install_path: '', git: 'git@example.com:puppet/test_module.git' }
179
+
180
+ allow(R10K::Module).to receive(:new).with('puppet/test_module', subject.basedir, module_opts, anything).and_call_original
181
+
182
+ subject.add_module('puppet/test_module', module_opts)
183
+ expect(subject.managed_directories).to be_empty
184
+ end
185
+ end
186
+ end
187
+
157
188
  describe "evaluating a Puppetfile" do
158
189
  def expect_wrapped_error(orig, pf_path, wrapped_error)
159
190
  expect(orig).to be_a_kind_of(R10K::Error)
@@ -244,7 +275,8 @@ describe R10K::Puppetfile do
244
275
  default_branch_override = 'default_branch_override_name'
245
276
  expect { subject.load!(default_branch_override) }.not_to raise_error
246
277
  git_module = subject.modules[0]
247
- expect(git_module.default_ref).to eq default_branch_override
278
+ expect(git_module.default_override_ref).to eq default_branch_override
279
+ expect(git_module.default_ref).to eq "here_lies_the_default_branch"
248
280
  end
249
281
  end
250
282
 
@@ -263,12 +295,12 @@ describe R10K::Puppetfile do
263
295
  block.call
264
296
  end
265
297
 
266
- mod1 = spy('module')
298
+ mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
299
+ mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
267
300
  expect(mod1).to receive(:accept).with(visitor)
268
- mod2 = spy('module')
269
301
  expect(mod2).to receive(:accept).with(visitor)
270
-
271
302
  expect(subject).to receive(:modules).and_return([mod1, mod2])
303
+
272
304
  subject.accept(visitor)
273
305
  end
274
306
 
@@ -284,11 +316,10 @@ describe R10K::Puppetfile do
284
316
  block.call
285
317
  end
286
318
 
287
- mod1 = spy('module')
319
+ mod1 = instance_double('R10K::Module::Base', :cachedir => :none)
320
+ mod2 = instance_double('R10K::Module::Base', :cachedir => :none)
288
321
  expect(mod1).to receive(:accept).with(visitor)
289
- mod2 = spy('module')
290
322
  expect(mod2).to receive(:accept).with(visitor)
291
-
292
323
  expect(subject).to receive(:modules).and_return([mod1, mod2])
293
324
 
294
325
  expect(Thread).to receive(:new).exactly(pool_size).and_call_original
@@ -296,5 +327,28 @@ describe R10K::Puppetfile do
296
327
 
297
328
  subject.accept(visitor)
298
329
  end
330
+
331
+ it "Creates queues of modules grouped by cachedir" do
332
+ visitor = spy('visitor')
333
+ expect(visitor).to receive(:visit) do |type, other, &block|
334
+ expect(type).to eq :puppetfile
335
+ expect(other).to eq subject
336
+ block.call
337
+ end
338
+
339
+ m1 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/A')
340
+ m2 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/B')
341
+ m3 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/C')
342
+ m4 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/C')
343
+ m5 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
344
+ m6 = instance_double('R10K::Module::Base', :cachedir => '/dev/null/D')
345
+
346
+ expect(subject).to receive(:modules).and_return([m1, m2, m3, m4, m5, m6])
347
+
348
+ queue = subject.modules_queue(visitor)
349
+ expect(queue.length).to be 4
350
+ queue_array = 4.times.map { queue.pop }
351
+ expect(queue_array).to match_array([[m1], [m2], [m3, m4], [m5, m6]])
352
+ end
299
353
  end
300
354
  end
@@ -129,6 +129,18 @@ describe R10K::Settings do
129
129
  expect { subject.evaluate('puppet_path' => '/nonexistent') }.to raise_error(R10K::Settings::Collection::ValidationError)
130
130
  end
131
131
  end
132
+
133
+ describe 'puppet_conf' do
134
+ it 'when file raises no error' do
135
+ allow(File).to receive(:readable?).with('/nonexistent').and_return(true)
136
+ expect { subject.evaluate('puppet_conf' => '/nonexistent') }.not_to raise_error
137
+ end
138
+
139
+ it 'when not file raises error' do
140
+ allow(File).to receive(:readable?).with('/nonexistent').and_return(false)
141
+ expect { subject.evaluate('puppet_conf' => '/nonexistent') }.to raise_error(R10K::Settings::Collection::ValidationError)
142
+ end
143
+ end
132
144
  end
133
145
 
134
146
  describe "global settings" do
@@ -93,9 +93,57 @@ describe R10K::Source::Git do
93
93
  let(:ignore_prefixes) { ['dev', 'test'] }
94
94
 
95
95
  it "filters branches" do
96
- expect(subject.filter_branches(branches, ignore_prefixes)).to eq(['master', 'production', 'not_dev_test_me'])
96
+ expect(subject.filter_branches_by_regexp(branches, ignore_prefixes)).to eq(['master', 'production', 'not_dev_test_me'])
97
97
  end
98
98
  end
99
+
100
+ describe "filtering branches with command" do
101
+ let(:branches) { ['master', 'development', 'production'] }
102
+ if R10K::Util::Platform.windows?
103
+ let(:filter_command) { 'powershell.exe if ($env:R10K_BRANCH.equals(\"development\")) {exit 1} else {exit 0}' }
104
+ else
105
+ let(:filter_command) { 'sh -c "[ $R10K_BRANCH != development ]"' }
106
+ end
107
+
108
+ it "filters branches" do
109
+ expect(subject.filter_branches_by_command(branches, filter_command)).to eq(['master', 'production'])
110
+ end
111
+ end
112
+
113
+ describe "generate_environments respects filter_command setting" do
114
+ before do
115
+ allow(subject.cache).to receive(:branches).and_return ['master', 'development', 'production']
116
+ if R10K::Util::Platform.windows?
117
+ subject.instance_variable_set(:@filter_command, 'powershell.exe if ($env:R10K_BRANCH.equals(\"master\")) {exit 1} else {exit 0}')
118
+ else
119
+ subject.instance_variable_set(:@filter_command, '[ $R10K_BRANCH != master ]')
120
+ end
121
+ end
122
+
123
+ let(:environments) { subject.generate_environments }
124
+
125
+ it "creates an environment for each branch not filtered by filter_command" do
126
+ expect(subject.generate_environments.size).to eq(2)
127
+ end
128
+ end
129
+
130
+ describe "generate_environments respects filter_command setting and name" do
131
+ before do
132
+ allow(subject.cache).to receive(:branches).and_return ['master', 'development', 'production']
133
+ if R10K::Util::Platform.windows?
134
+ subject.instance_variable_set(:@filter_command, 'powershell.exe if ($env:R10K_NAME.equals(\"mysource\")) {exit 0} else {exit 1}')
135
+ else
136
+ subject.instance_variable_set(:@filter_command, '[ $R10K_NAME = mysource ]')
137
+ end
138
+ end
139
+
140
+ let(:environments) { subject.generate_environments }
141
+
142
+ it "creates an environment for each branch not filtered by filter_command" do
143
+ expect(subject.generate_environments.size).to eq(3)
144
+ end
145
+ end
146
+
99
147
  end
100
148
 
101
149
  describe R10K::Source::Git, "handling invalid branch names" do
@@ -10,7 +10,10 @@ describe R10K::Util::Setopts do
10
10
 
11
11
  def initialize(opts = {})
12
12
  setopts(opts, {
13
- :valid => :self, :alsovalid => :self, :truthyvalid => true,
13
+ :valid => :self,
14
+ :duplicate => :valid,
15
+ :alsovalid => :self,
16
+ :truthyvalid => true,
14
17
  :validalias => :valid,
15
18
  :ignoreme => nil
16
19
  })
@@ -53,7 +56,28 @@ describe R10K::Util::Setopts do
53
56
  }.to raise_error(ArgumentError, /cannot handle option 'notvalid'/)
54
57
  end
55
58
 
59
+ it "warns when given an unhandled option and raise_on_unhandled=false" do
60
+ test = Class.new { include R10K::Util::Setopts }.new
61
+ allow(test).to receive(:logger).and_return(spy)
62
+
63
+ test.send(:setopts, {valid: :value, invalid: :value},
64
+ {valid: :self},
65
+ raise_on_unhandled: false)
66
+
67
+ expect(test.logger).to have_received(:warn).with(%r{cannot handle option 'invalid'})
68
+ end
69
+
56
70
  it "ignores values that are marked as unhandled" do
57
71
  klass.new(:ignoreme => "IGNORE ME!")
58
72
  end
73
+
74
+ it "warns when given conflicting options" do
75
+ test = Class.new { include R10K::Util::Setopts }.new
76
+ allow(test).to receive(:logger).and_return(spy)
77
+
78
+ test.send(:setopts, {valid: :one, duplicate: :two},
79
+ {valid: :arg, duplicate: :arg})
80
+
81
+ expect(test.logger).to have_received(:warn).with(%r{valid.*duplicate.*conflict.*not both})
82
+ end
59
83
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: r10k
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrien Thebo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-08 00:00:00.000000000 Z
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colored2
@@ -28,22 +28,16 @@ dependencies:
28
28
  name: cri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - '='
32
32
  - !ruby/object:Gem::Version
33
33
  version: 2.15.10
34
- - - "<"
35
- - !ruby/object:Gem::Version
36
- version: 3.0.0
37
34
  type: :runtime
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
- - - ">="
38
+ - - '='
42
39
  - !ruby/object:Gem::Version
43
40
  version: 2.15.10
44
- - - "<"
45
- - !ruby/object:Gem::Version
46
- version: 3.0.0
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: log4r
49
43
  requirement: !ruby/object:Gem::Requirement
@@ -204,6 +198,7 @@ files:
204
198
  - ".github/pull_request_template.md"
205
199
  - ".github/workflows/docker.yml"
206
200
  - ".github/workflows/release.yml"
201
+ - ".github/workflows/rspec_tests.yml"
207
202
  - ".gitignore"
208
203
  - ".travis.yml"
209
204
  - CHANGELOG.mkd
@@ -213,7 +208,6 @@ files:
213
208
  - LICENSE
214
209
  - README.mkd
215
210
  - Rakefile
216
- - azure-pipelines.yml
217
211
  - bin/r10k
218
212
  - doc/common-patterns.mkd
219
213
  - doc/dynamic-environments.mkd
@@ -235,6 +229,7 @@ files:
235
229
  - docker/Gemfile
236
230
  - docker/Makefile
237
231
  - docker/README.md
232
+ - docker/docker-compose.yml
238
233
  - docker/r10k/Dockerfile
239
234
  - docker/r10k/adduser.sh
240
235
  - docker/r10k/docker-entrypoint.d/10-analytics.sh
@@ -282,6 +277,7 @@ files:
282
277
  - integration/tests/command_line/negative/neg_invalid_cmd_line_arg.rb
283
278
  - integration/tests/git_source/HTTP_proxy_and_git_source.rb
284
279
  - integration/tests/git_source/git_source_git.rb
280
+ - integration/tests/git_source/git_source_repeated_remote.rb
285
281
  - integration/tests/git_source/git_source_ssh.rb
286
282
  - integration/tests/git_source/git_source_submodule.rb
287
283
  - integration/tests/git_source/negative/neg_git_broken_remote.rb
@@ -446,6 +442,7 @@ files:
446
442
  - spec/fixtures/module/forge/eight_hundred/metadata.json
447
443
  - spec/fixtures/unit/action/r10k.yaml
448
444
  - spec/fixtures/unit/action/r10k_cachedir.yaml
445
+ - spec/fixtures/unit/action/r10k_creds.yaml
449
446
  - spec/fixtures/unit/action/r10k_generate_types.yaml
450
447
  - spec/fixtures/unit/action/r10k_puppet_path.yaml
451
448
  - spec/fixtures/unit/puppetfile/argument-error/Puppetfile
@@ -504,6 +501,7 @@ files:
504
501
  - spec/unit/environment/git_spec.rb
505
502
  - spec/unit/environment/name_spec.rb
506
503
  - spec/unit/environment/svn_spec.rb
504
+ - spec/unit/environment/with_modules_spec.rb
507
505
  - spec/unit/errors/formatting_spec.rb
508
506
  - spec/unit/feature_spec.rb
509
507
  - spec/unit/forge/module_release_spec.rb
data/azure-pipelines.yml DELETED
@@ -1,86 +0,0 @@
1
- # Don't run Azure when a branch is updated, only when a PR is updated.
2
- # Prevents double builds when a PR is made from the main repo and not a fork.
3
- trigger: none
4
- pr:
5
- autoCancel: true
6
- branches:
7
- include:
8
- - '*'
9
-
10
- pool:
11
- # self-hosted agent on Windows 10 1903 environment
12
- # includes newer Docker engine with LCOW enabled, new build of LCOW image
13
- # includes Ruby 2.5, Go 1.10, Node.js 10.10
14
- name: Default
15
-
16
- variables:
17
- NAMESPACE: puppet
18
- CONTAINER_NAME: r10k
19
- CONTAINER_BUILD_PATH: .
20
- LINT_IGNORES:
21
- DOCKER_BUILDKIT: 1
22
-
23
- workspace:
24
- clean: resources
25
-
26
- steps:
27
- - checkout: self # self represents the repo where the initial Pipelines YAML file was found
28
- clean: true # whether to fetch clean each time
29
-
30
- - powershell: |
31
- $gemfile = Join-Path -Path (Get-Location) -ChildPath 'docker/Gemfile'
32
- $gempath = Join-Path -Path (Get-Location) -ChildPath 'docker/.bundle/gems'
33
- bundle config --local gemfile $gemfile
34
- bundle config --local path $gempath
35
- bundle install --with test
36
- displayName: Fetch Dependencies
37
- timeoutInMinutes: 1
38
- name: fetch_deps
39
-
40
- - powershell: |
41
- . "$(bundle show pupperware)/ci/build.ps1"
42
- Write-HostDiagnostics
43
- displayName: Diagnostic Host Information
44
- timeoutInMinutes: 2
45
- name: hostinfo
46
-
47
- - powershell: |
48
- . "$(bundle show pupperware)/ci/build.ps1"
49
- Lint-Dockerfile -Name $ENV:CONTAINER_NAME -Ignore ($ENV:LINT_IGNORES -split ' ')
50
- displayName: Lint $(CONTAINER_NAME) Dockerfile
51
- timeoutInMinutes: 1
52
- name: lint_dockerfile
53
-
54
- - powershell: |
55
- . "$(bundle show pupperware)/ci/build.ps1"
56
- Build-Container -Name $ENV:CONTAINER_NAME -Namespace $ENV:NAMESPACE -PathOrUri $ENV:CONTAINER_BUILD_PATH
57
- displayName: Build $(CONTAINER_NAME) Container
58
- timeoutInMinutes: 5
59
- name: build_container
60
-
61
- - powershell: |
62
- . "$(bundle show pupperware)/ci/build.ps1"
63
- Initialize-TestEnv
64
- displayName: Prepare Test Environment
65
- name: test_prepare
66
-
67
- - powershell: |
68
- . "$(bundle show pupperware)/ci/build.ps1"
69
- Invoke-ContainerTest -Name $ENV:CONTAINER_NAME -Namespace $ENV:NAMESPACE
70
- displayName: Test $(CONTAINER_NAME)
71
- timeoutInMinutes: 5
72
- name: test_container
73
-
74
- - task: PublishTestResults@2
75
- displayName: Publish $(CONTAINER_NAME) test results
76
- inputs:
77
- testResultsFormat: 'JUnit'
78
- testResultsFiles: 'docker/TEST-*.xml'
79
- testRunTitle: $(CONTAINER_NAME) Test Results
80
-
81
- - powershell: |
82
- . "$(bundle show pupperware)/ci/build.ps1"
83
- Clear-BuildState -Name $ENV:CONTAINER_NAME -Namespace $ENV:NAMESPACE
84
- displayName: Container Cleanup
85
- timeoutInMinutes: 4
86
- condition: always()