dpl 1.8.48.travis.2486.5 → 1.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +2 -0
  3. data/.travis.yml +42 -21
  4. data/Gemfile +3 -98
  5. data/README.md +5 -16
  6. data/Rakefile +160 -1
  7. data/dpl-anynines.gemspec +3 -0
  8. data/dpl-atlas.gemspec +3 -0
  9. data/dpl-azure_webapps.gemspec +3 -0
  10. data/dpl-bintray.gemspec +3 -0
  11. data/dpl-bitballoon.gemspec +3 -0
  12. data/dpl-bluemix_cloud_foundry.gemspec +3 -0
  13. data/dpl-boxfuse.gemspec +3 -0
  14. data/dpl-catalyze.gemspec +3 -0
  15. data/dpl-chef_supermarket.gemspec +8 -0
  16. data/dpl-cloud66.gemspec +3 -0
  17. data/dpl-cloud_files.gemspec +3 -0
  18. data/dpl-cloud_foundry.gemspec +3 -0
  19. data/dpl-code_deploy.gemspec +3 -0
  20. data/dpl-deis.gemspec +3 -0
  21. data/dpl-divshot.gemspec +3 -0
  22. data/dpl-elastic_beanstalk.gemspec +3 -0
  23. data/dpl-engine_yard.gemspec +3 -0
  24. data/dpl-firebase.gemspec +3 -0
  25. data/dpl-gae.gemspec +3 -0
  26. data/dpl-gcs.gemspec +3 -0
  27. data/dpl-hackage.gemspec +3 -0
  28. data/dpl-heroku.gemspec +3 -0
  29. data/dpl-lambda.gemspec +3 -0
  30. data/dpl-launchpad.gemspec +3 -0
  31. data/dpl-modulus.gemspec +3 -0
  32. data/dpl-npm.gemspec +3 -0
  33. data/dpl-openshift.gemspec +3 -0
  34. data/dpl-ops_works.gemspec +3 -0
  35. data/dpl-packagecloud.gemspec +3 -0
  36. data/dpl-pages.gemspec +3 -0
  37. data/dpl-puppet_forge.gemspec +3 -0
  38. data/dpl-pypi.gemspec +3 -0
  39. data/dpl-releases.gemspec +3 -0
  40. data/dpl-rubygems.gemspec +3 -0
  41. data/dpl-s3.gemspec +3 -0
  42. data/dpl-scalingo.gemspec +3 -0
  43. data/dpl-script.gemspec +3 -0
  44. data/dpl-surge.gemspec +3 -0
  45. data/dpl-testfairy.gemspec +3 -0
  46. data/dpl-transifex.gemspec +3 -0
  47. data/dpl.gemspec +2 -31
  48. data/gemspec_helper.rb +49 -0
  49. data/lib/dpl/provider.rb +101 -58
  50. data/lib/dpl/version.rb +1 -1
  51. data/spec/provider_spec.rb +15 -34
  52. metadata +76 -107
  53. data/lib/dpl/provider/anynines.rb +0 -13
  54. data/lib/dpl/provider/appfog.rb +0 -21
  55. data/lib/dpl/provider/atlas.rb +0 -108
  56. data/lib/dpl/provider/azure_webapps.rb +0 -48
  57. data/lib/dpl/provider/bintray.rb +0 -509
  58. data/lib/dpl/provider/bitballoon.rb +0 -22
  59. data/lib/dpl/provider/bluemix_cloud_foundry.rb +0 -23
  60. data/lib/dpl/provider/boxfuse.rb +0 -57
  61. data/lib/dpl/provider/catalyze.rb +0 -49
  62. data/lib/dpl/provider/chef_supermarket.rb +0 -85
  63. data/lib/dpl/provider/cloud66.rb +0 -38
  64. data/lib/dpl/provider/cloud_files.rb +0 -38
  65. data/lib/dpl/provider/cloud_foundry.rb +0 -43
  66. data/lib/dpl/provider/code_deploy.rb +0 -154
  67. data/lib/dpl/provider/deis.rb +0 -128
  68. data/lib/dpl/provider/divshot.rb +0 -23
  69. data/lib/dpl/provider/elastic_beanstalk.rb +0 -195
  70. data/lib/dpl/provider/engine_yard.rb +0 -90
  71. data/lib/dpl/provider/firebase.rb +0 -27
  72. data/lib/dpl/provider/gae.rb +0 -97
  73. data/lib/dpl/provider/gcs.rb +0 -59
  74. data/lib/dpl/provider/hackage.rb +0 -29
  75. data/lib/dpl/provider/heroku.rb +0 -18
  76. data/lib/dpl/provider/heroku/api.rb +0 -98
  77. data/lib/dpl/provider/heroku/generic.rb +0 -94
  78. data/lib/dpl/provider/heroku/git.rb +0 -28
  79. data/lib/dpl/provider/lambda.rb +0 -236
  80. data/lib/dpl/provider/launchpad.rb +0 -48
  81. data/lib/dpl/provider/modulus.rb +0 -23
  82. data/lib/dpl/provider/npm.rb +0 -64
  83. data/lib/dpl/provider/openshift.rb +0 -59
  84. data/lib/dpl/provider/ops_works.rb +0 -132
  85. data/lib/dpl/provider/packagecloud.rb +0 -144
  86. data/lib/dpl/provider/pages.rb +0 -212
  87. data/lib/dpl/provider/puppet_forge.rb +0 -43
  88. data/lib/dpl/provider/pypi.rb +0 -103
  89. data/lib/dpl/provider/releases.rb +0 -139
  90. data/lib/dpl/provider/rubygems.rb +0 -51
  91. data/lib/dpl/provider/s3.rb +0 -123
  92. data/lib/dpl/provider/scalingo.rb +0 -97
  93. data/lib/dpl/provider/script.rb +0 -29
  94. data/lib/dpl/provider/surge.rb +0 -33
  95. data/lib/dpl/provider/testfairy.rb +0 -111
  96. data/lib/dpl/provider/transifex.rb +0 -45
  97. data/spec/provider/anynines_spec.rb +0 -20
  98. data/spec/provider/appfog_spec.rb +0 -35
  99. data/spec/provider/atlas_spec.rb +0 -99
  100. data/spec/provider/azure_webapps_spec.rb +0 -95
  101. data/spec/provider/bintray_spec.rb +0 -259
  102. data/spec/provider/bitballoon_spec.rb +0 -32
  103. data/spec/provider/bluemixcloudfoundry_spec.rb +0 -23
  104. data/spec/provider/boxfuse_spec.rb +0 -16
  105. data/spec/provider/catalyze_spec.rb +0 -39
  106. data/spec/provider/chef_supermarket_spec.rb +0 -51
  107. data/spec/provider/cloud66_spec.rb +0 -44
  108. data/spec/provider/cloud_files_spec.rb +0 -88
  109. data/spec/provider/cloudfoundry_spec.rb +0 -71
  110. data/spec/provider/code_deploy_spec.rb +0 -366
  111. data/spec/provider/deis_spec.rb +0 -116
  112. data/spec/provider/divshot_spec.rb +0 -28
  113. data/spec/provider/elastic_beanstalk_spec.rb +0 -209
  114. data/spec/provider/firebase_spec.rb +0 -40
  115. data/spec/provider/gae_spec.rb +0 -26
  116. data/spec/provider/gcs_spec.rb +0 -115
  117. data/spec/provider/hackage_spec.rb +0 -47
  118. data/spec/provider/heroku_spec.rb +0 -357
  119. data/spec/provider/lambda_spec.rb +0 -432
  120. data/spec/provider/launchpad_spec.rb +0 -33
  121. data/spec/provider/modulus_spec.rb +0 -29
  122. data/spec/provider/npm_spec.rb +0 -95
  123. data/spec/provider/openshift_spec.rb +0 -91
  124. data/spec/provider/ops_works_spec.rb +0 -127
  125. data/spec/provider/packagecloud_spec.rb +0 -56
  126. data/spec/provider/puppet_forge_spec.rb +0 -60
  127. data/spec/provider/pypi_spec.rb +0 -105
  128. data/spec/provider/releases_spec.rb +0 -303
  129. data/spec/provider/rubygems_spec.rb +0 -106
  130. data/spec/provider/s3_spec.rb +0 -174
  131. data/spec/provider/scalingo_spec.rb +0 -64
  132. data/spec/provider/script_spec.rb +0 -26
  133. data/spec/provider/surge_spec.rb +0 -15
  134. data/spec/provider/testfairy_spec.rb +0 -65
  135. data/spec/provider/transifex_spec.rb +0 -110
@@ -1,32 +0,0 @@
1
- require 'spec_helper'
2
- require 'dpl/provider/bitballoon'
3
-
4
- describe DPL::Provider::BitBalloon do
5
- subject :provider do
6
- described_class.new(DummyContext.new,{})
7
- end
8
-
9
- describe "#needs_key?" do
10
- example do
11
- expect(provider.needs_key?).to eq(false)
12
- end
13
- end
14
-
15
- describe "#push_app" do
16
- example "Without optional parameters" do
17
- expect(provider.context).to receive(:shell).with("bitballoon deploy")
18
- provider.push_app
19
- end
20
-
21
- example "With optional parameters" do
22
- provider.options.update(local_dir: 'build')
23
- provider.options.update(access_token:'fake-access-token')
24
- provider.options.update(site_id:'fake-site')
25
-
26
- expected_command = "bitballoon deploy ./build --site-id=fake-site --access-token=fake-access-token"
27
-
28
- expect(provider.context).to receive(:shell).with(expected_command)
29
- provider.push_app
30
- end
31
- end
32
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
- require 'dpl/provider/bluemix_cloud_foundry'
3
-
4
- describe DPL::Provider::BluemixCloudFoundry do
5
- subject :provider do
6
- described_class.new(DummyContext.new, region: 'eu-gb', username: 'Moonpie',
7
- password: 'myexceptionallyaveragepassword',
8
- organization: 'myotherorg',
9
- space: 'inner',
10
- manifest: 'worker-manifest.yml',
11
- skip_ssl_validation: true)
12
- end
13
-
14
- describe "#check_auth" do
15
- example do
16
- expect(provider.context).to receive(:shell).with('test x$TRAVIS_OS_NAME = "xlinux" && rel="linux64-binary" || rel="macosx64"; wget "https://cli.run.pivotal.io/stable?release=${rel}&source=github" -qO cf.tgz && tar -zxvf cf.tgz && rm cf.tgz')
17
- expect(provider.context).to receive(:shell).with('./cf api api.eu-gb.bluemix.net --skip-ssl-validation')
18
- expect(provider.context).to receive(:shell).with('./cf login -u Moonpie -p myexceptionallyaveragepassword -o myotherorg -s inner')
19
- provider.check_auth
20
- end
21
- end
22
-
23
- end
@@ -1,16 +0,0 @@
1
- require 'spec_helper'
2
- require 'dpl/provider/boxfuse'
3
-
4
- describe DPL::Provider::Boxfuse do
5
- subject :provider do
6
- described_class.new(DummyContext.new, :user => 'dummyuser', :image => 'abc:123')
7
- end
8
-
9
- describe "#deploy" do
10
- example do
11
- expect(provider.context).to receive(:shell).with('curl -L https://files.boxfuse.com/com/boxfuse/client/boxfuse-commandline/latest/boxfuse-commandline-latest-linux-x64.tar.gz | tar xz')
12
- expect(provider.context).to receive(:shell).with('boxfuse/boxfuse run -user=dummyuser -image=abc:123 -env=test')
13
- provider.deploy
14
- end
15
- end
16
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
- require 'dpl/provider/catalyze'
3
-
4
- describe DPL::Provider::Catalyze do
5
- subject :provider do
6
- described_class.new(DummyContext.new, :target => 'test-target', :path => 'test-path')
7
- end
8
-
9
- describe "#check_auth" do
10
- it 'should require a target' do
11
- provider.options.update(:target => nil)
12
- expect{ provider.check_auth }.to raise_error("Missing Catalyze target")
13
- end
14
- end
15
-
16
- describe "#push_app" do
17
- it 'should push the current branch to the target' do
18
- expect(provider.context).to receive(:shell).with("git push --force test-target HEAD:master")
19
- provider.push_app
20
- end
21
- it 'should add and commit local build files if skip_cleanup is true' do
22
- provider.options.update(:skip_cleanup => true)
23
- expect(provider.context).to receive(:shell).with("git checkout HEAD")
24
- expect(provider.context).to receive(:shell).with("git add test-path --all --force")
25
- expect(provider.context).to receive(:shell).with("git commit -m \"Local build\" --quiet")
26
- expect(provider.context).to receive(:shell).with("git push --force test-target HEAD:master")
27
- provider.push_app
28
- end
29
- it 'should use a path of "." if the path is not specified' do
30
- provider.options.update(:path => nil)
31
- provider.options.update(:skip_cleanup => true)
32
- expect(provider.context).to receive(:shell).with("git checkout HEAD")
33
- expect(provider.context).to receive(:shell).with("git add . --all --force")
34
- expect(provider.context).to receive(:shell).with("git commit -m \"Local build\" --quiet")
35
- expect(provider.context).to receive(:shell).with("git push --force test-target HEAD:master")
36
- provider.push_app
37
- end
38
- end
39
- end
@@ -1,51 +0,0 @@
1
- require 'spec_helper'
2
- require 'chef/cookbook_loader'
3
- require 'chef/cookbook_uploader'
4
- require 'dpl/provider/chef_supermarket'
5
-
6
- describe DPL::Provider::ChefSupermarket do
7
- subject :provider do
8
- described_class.new(
9
- DummyContext.new,
10
- app: 'example',
11
- cookbook_category: 'Others',
12
- user_id: 'user',
13
- client_key: '/tmp/example.pem'
14
- )
15
- end
16
-
17
- let(:cookbook_uploader) do
18
- double('cookbook_uploader', validate_cookbooks: true)
19
- end
20
-
21
- let(:http_resp) do
22
- double('http_resp', body: '{}', code: '201')
23
- end
24
-
25
- describe "#check_auth" do
26
- example do
27
- ::File.stub(:exist?).and_return(true)
28
- expect(File).to receive(:exist?)
29
- provider.check_auth
30
- end
31
- end
32
-
33
- describe "#check_app" do
34
- example do
35
- ::Chef::CookbookLoader.any_instance.stub(:[]).and_return nil
36
- expect(::Chef::CookbookUploader).to receive(:new).and_return(cookbook_uploader)
37
- provider.check_app
38
- end
39
- end
40
-
41
- describe "#push_app" do
42
- example do
43
- expect(::Chef::CookbookSiteStreamingUploader).to receive(:create_build_dir).and_return('/tmp/build_dir')
44
- expect(provider).to receive(:system).and_return(true)
45
- expect(::File).to receive(:open)
46
- expect(::Chef::CookbookSiteStreamingUploader).to receive(:post).and_return(http_resp)
47
- expect(::FileUtils).to receive(:rm_rf).with('/tmp/build_dir')
48
- provider.push_app
49
- end
50
- end
51
- end
@@ -1,44 +0,0 @@
1
- require 'spec_helper'
2
- require 'dpl/provider/cloud66'
3
-
4
- describe DPL::Provider::Cloud66 do
5
- subject :provider do
6
- described_class.new(DummyContext.new, options)
7
- end
8
-
9
- let(:successful_response){ double(code: '200') }
10
- let(:not_found_response){ double(code: '404') }
11
- let(:options){ {} }
12
-
13
- describe "#push_app" do
14
- context 'with a successful response' do
15
- let(:options){ {:redeployment_hook => 'https://hooks.cloud66.com/stacks/redeploy/0101010101010101'} }
16
-
17
- example do
18
- expect(provider).to receive(:webhook_call).with('https', 'hooks.cloud66.com', 443, '/stacks/redeploy/0101010101010101').and_return(successful_response)
19
- provider.push_app
20
- end
21
- end
22
-
23
- context 'with a 404 response' do
24
- let(:options){ {:redeployment_hook => 'https://hooks.cloud66.com/stacks/redeploy/0101010101010101'} }
25
-
26
- it 'should raise an error' do
27
- expect(provider).to receive(:webhook_call).with('https', 'hooks.cloud66.com', 443, '/stacks/redeploy/0101010101010101').and_return(not_found_response)
28
- expect { provider.push_app }.to raise_error(DPL::Error, "Redeployment failed [404]")
29
- end
30
- end
31
-
32
- context 'with missing redeployment_hook option' do
33
- it 'should raise an error' do
34
- expect { provider.push_app }.to raise_error(DPL::Error, "missing redeployment_hook")
35
- end
36
- end
37
- end
38
-
39
- describe "#needs_key?" do
40
- example do
41
- expect(provider.needs_key?).to eq(false)
42
- end
43
- end
44
- end
@@ -1,88 +0,0 @@
1
- require 'spec_helper'
2
- require 'dpl/provider/cloud_files'
3
- require 'fog'
4
-
5
- describe DPL::Provider::CloudFiles do
6
- before :each do
7
- Fog.mock!
8
- end
9
-
10
- subject :provider do
11
- described_class.new(DummyContext.new, :username => 'username', :api_key => 'api key', :container => 'travis', :region => 'dfw')
12
- end
13
-
14
- describe "#needs_key?" do
15
- example do
16
- expect(provider.needs_key?).to eq(false)
17
- end
18
- end
19
-
20
- describe "#api" do
21
- example do
22
- expect(Fog::Storage).to receive(:new).with(:provider => 'Rackspace', :rackspace_username => 'username', :rackspace_api_key => 'api key', :rackspace_region => 'dfw')
23
-
24
- provider.api
25
- end
26
- end
27
-
28
- describe "#check_auth" do
29
- example do
30
- expect(provider).to receive(:log).with('Authenticated as username')
31
-
32
- provider.check_auth
33
- end
34
- end
35
-
36
- describe "#push_app" do
37
- let :files do
38
- files = double
39
-
40
- directory = double
41
- allow(directory).to receive(:files) { files }
42
-
43
- directories = double
44
- expect(directories).to receive(:get).with('travis').and_return(directory)
45
-
46
- service = double(:service)
47
- allow(service).to receive(:directories) { directories }
48
- allow(provider).to receive(:api) { service }
49
-
50
- files
51
- end
52
-
53
- example do
54
- expect(files).to receive(:create).with(:key => 'a', :body => 'a body')
55
- expect(files).to receive(:create).with(:key => 'b', :body => 'b body')
56
- expect(files).to receive(:create).with(:key => 'c', :body => 'c body')
57
-
58
- expect(Dir).to receive(:glob).with('**/*').and_return(['a', 'b', 'c'])
59
- allow(File).to receive(:open) { |name| "#{name} body" }
60
-
61
- provider.push_app
62
- end
63
-
64
- example "with dot_match option" do
65
- provider.options.update(:dot_match => true)
66
- expect(files).to receive(:create).with(:key => '.a', :body => '.a body')
67
- expect(files).to receive(:create).with(:key => 'a', :body => 'a body')
68
-
69
- expect(Dir).to receive(:glob).with('**/*', File::FNM_DOTMATCH).and_return(['.a', 'a'])
70
- allow(File).to receive(:open) { |name| "#{name} body" }
71
-
72
- provider.push_app
73
- end
74
- end
75
-
76
- describe "#deploy" do
77
- example 'Not Found' do
78
- directories = double
79
- allow(directories).to receive(:get) { nil }
80
-
81
- service = double(:service)
82
- allow(service).to receive(:directories) { directories }
83
- allow(provider).to receive(:api) { service }
84
-
85
- expect { provider.deploy }.to raise_error(DPL::Error, 'The specified container does not exist.')
86
- end
87
- end
88
- end
@@ -1,71 +0,0 @@
1
- require 'spec_helper'
2
- require 'dpl/provider/cloud_foundry'
3
-
4
- describe DPL::Provider::CloudFoundry do
5
- subject :provider do
6
- described_class.new(DummyContext.new, api: 'api.run.awesome.io', username: 'mallomar',
7
- password: 'myreallyawesomepassword',
8
- organization: 'myorg',
9
- space: 'outer',
10
- manifest: 'worker-manifest.yml',
11
- skip_ssl_validation: true)
12
- end
13
-
14
- describe "#check_auth" do
15
- example do
16
- expect(provider.context).to receive(:shell).with('test x$TRAVIS_OS_NAME = "xlinux" && rel="linux64-binary" || rel="macosx64"; wget "https://cli.run.pivotal.io/stable?release=${rel}&source=github" -qO cf.tgz && tar -zxvf cf.tgz && rm cf.tgz')
17
- expect(provider.context).to receive(:shell).with('./cf api api.run.awesome.io --skip-ssl-validation')
18
- expect(provider.context).to receive(:shell).with('./cf login -u mallomar -p myreallyawesomepassword -o myorg -s outer')
19
- provider.check_auth
20
- end
21
- end
22
-
23
- describe "#check_app" do
24
- context 'when the manifest file exists' do
25
- example do
26
- File.stub(:exists?).with('worker-manifest.yml').and_return(true)
27
- expect{provider.check_app}.not_to raise_error
28
- end
29
- end
30
-
31
- context 'when the manifest file exists' do
32
- example do
33
- File.stub(:exists?).with('worker-manifest.yml').and_return(false)
34
- expect{provider.check_app}.to raise_error('Application must have a manifest.yml for unattended deployment')
35
- end
36
- end
37
- end
38
-
39
- describe "#needs_key?" do
40
- example do
41
- expect(provider.needs_key?).to eq(false)
42
- end
43
- end
44
-
45
- describe "#push_app" do
46
- before do
47
- allow(provider.context).to receive(:shell).and_return(true)
48
- end
49
-
50
- example "With manifest" do
51
- expect(provider.context).to receive(:shell).with('./cf push -f worker-manifest.yml')
52
- expect(provider.context).to receive(:shell).with('./cf logout')
53
- provider.push_app
54
- end
55
-
56
- example "Without manifest" do
57
- provider.options.update(:manifest => nil)
58
- expect(provider.context).to receive(:shell).with('./cf push')
59
- expect(provider.context).to receive(:shell).with('./cf logout')
60
- provider.push_app
61
- end
62
-
63
- example 'Failed to push' do
64
- allow(provider.context).to receive(:shell).and_return(false)
65
-
66
- expect(provider.context).to receive(:shell).with('./cf push -f worker-manifest.yml')
67
- expect(provider.context).to receive(:shell).with('./cf logout')
68
- expect{provider.push_app}.to raise_error(DPL::Error, 'Failed to push app')
69
- end
70
- end
71
- end
@@ -1,366 +0,0 @@
1
- require 'spec_helper'
2
- require 'aws-sdk'
3
- require 'dpl/error'
4
- require 'dpl/provider'
5
- require 'dpl/provider/code_deploy'
6
-
7
- describe DPL::Provider::CodeDeploy do
8
-
9
- subject :provider do
10
- described_class.new(DummyContext.new, :access_key_id => 'qwertyuiopasdfghjklz', :secret_access_key => 'qwertyuiopasdfghjklzqwertyuiopasdfghjklz')
11
- end
12
-
13
- describe '#code_deploy_options' do
14
- context 'without region' do
15
- example do
16
- options = provider.code_deploy_options
17
- expect(options[:region]).to eq('us-east-1')
18
- end
19
- end
20
-
21
- context 'with region' do
22
- example do
23
- region = 'us-west-1'
24
- provider.options.update(:region => region)
25
- options = provider.code_deploy_options
26
- expect(options[:region]).to eq(region)
27
- end
28
- end
29
-
30
- context 'without endpoint' do
31
- example do
32
- options = provider.code_deploy_options
33
- expect(options[:endpoint]).to eq(nil)
34
- end
35
- end
36
-
37
- context 'with endpoint' do
38
- example do
39
- endpoint = 's3test.com.s3-website-us-west-2.amazonaws.com'
40
- provider.options.update(:endpoint => endpoint)
41
- options = provider.code_deploy_options
42
- expect(options[:endpoint]).to eq(endpoint)
43
- end
44
- end
45
- end
46
- end
47
-
48
- describe DPL::Provider::CodeDeploy do
49
- access_key_id = 'someaccesskey'
50
- secret_access_key = 'somesecretaccesskey'
51
- application = 'app'
52
- deployment_group = 'group'
53
- description = 'description'
54
- revision = '23jkljkl'
55
- client_options = {
56
- :stub_responses => true,
57
- :region => 'us-east-1',
58
- :credentials => ::Aws::Credentials.new(access_key_id, secret_access_key),
59
- :endpoint => 'https://codedeploy.us-east-1.amazonaws.com'
60
- }
61
-
62
- subject :provider do
63
- described_class.new(DummyContext.new, {
64
- :access_key_id => access_key_id,
65
- :secret_access_key => secret_access_key
66
- })
67
- end
68
-
69
- before :each do
70
- provider.stub(:code_deploy_options).and_return(client_options)
71
- end
72
-
73
- describe '#code_deploy' do
74
- example do
75
- expect(::Aws::CodeDeploy::Client).to receive(:new).with(client_options).once
76
- provider.code_deploy
77
- end
78
- end
79
-
80
- describe '#needs_key?' do
81
- example do
82
- expect(provider.needs_key?).to eq(false)
83
- end
84
- end
85
-
86
- describe '#revision' do
87
- expected_s3_revision = {
88
- revision_type: 'S3',
89
- s3_location: {
90
- bucket: 'bucket',
91
- bundle_type: 'tar',
92
- key: 'key',
93
- version: 'object_version_id',
94
- e_tag: 'etag'
95
- }
96
- }
97
-
98
- expected_github_revision = {
99
- revision_type: 'GitHub',
100
- git_hub_location: {
101
- commit_id: '2lk3j4k2j3k4j23k4j',
102
- repository: 'travis-ci/dpl'
103
- }
104
- }
105
-
106
- before(:each) do
107
- provider.stub(:s3_revision).and_return(expected_s3_revision)
108
- provider.stub(:github_revision).and_return(expected_github_revision)
109
- end
110
-
111
- context 'when s3' do
112
- before do
113
- provider.options.update(:revision_type => :s3)
114
- end
115
-
116
- example do
117
- expect(provider.revision).to eq(expected_s3_revision)
118
- end
119
- end
120
-
121
- context 'when github' do
122
- before do
123
- provider.options.update(:revision_type => :github)
124
- end
125
-
126
- example do
127
- expect(provider.revision).to eq(expected_github_revision)
128
- end
129
- end
130
-
131
- context 'when not specified' do
132
- before do
133
- provider.options.update(:bucket => 'bucket')
134
- end
135
-
136
- example do
137
- expect(provider.revision).to eq(expected_s3_revision)
138
- end
139
- end
140
-
141
- context 'when revision and bucket are not specified' do
142
- example do
143
- expect(provider.revision).to eq(expected_github_revision)
144
- end
145
- end
146
-
147
- context 'when not a known revision type' do
148
- type = :bad
149
-
150
- before do
151
- provider.options.update(:revision_type => type)
152
- end
153
-
154
- example do
155
- expect(provider).to receive(:error).with(/unknown revision type :#{type}/)
156
- provider.revision
157
- end
158
- end
159
- end
160
-
161
- describe '#s3_revision' do
162
- bucket = 'bucket'
163
- bundle_type = 'tar'
164
- key = "/some/key.#{bundle_type}"
165
-
166
- before(:each) do
167
- head_data = provider.s3api.stub(:head_object).and_return({
168
- version_id: 'object_version_id',
169
- etag: 'etag'
170
- })
171
- provider.s3api.stub_responses(:head_object, head_data)
172
- expect(provider).to receive(:option).at_least(1).times.with(:bucket).and_return(bucket)
173
- expect(provider).to receive(:bundle_type).and_return(bundle_type)
174
- expect(provider).to receive(:s3_key).at_least(1).times.and_return(key)
175
- end
176
-
177
- example do
178
- expect(provider.s3_revision[:s3_location]).to include(
179
- bucket: bucket,
180
- bundle_type: bundle_type,
181
- key: key,
182
- version: 'object_version_id',
183
- e_tag: 'etag'
184
- )
185
- end
186
- end
187
-
188
- describe '#github_revision' do
189
- commit_id = '432s35s3'
190
- repository = 'git@github.com/org/repo.git'
191
-
192
- context 'with options set' do
193
- before(:each) do
194
- expect(provider.options).to receive(:[]).with(:commit_id).and_return(commit_id)
195
- expect(provider.options).to receive(:[]).with(:repository).and_return(repository)
196
- end
197
-
198
- example do
199
- expect(provider.github_revision).to eq({
200
- revision_type: 'GitHub',
201
- git_hub_location: {
202
- commit_id: commit_id,
203
- repository: repository
204
- }
205
- })
206
- end
207
- end
208
-
209
- context 'with environment variables' do
210
- before(:each) do
211
- expect(provider.options).to receive(:[]).with(:commit_id).and_return(nil)
212
- expect(provider.options).to receive(:[]).with(:repository).and_return(nil)
213
- expect(provider.context.env).to receive(:[]).with('TRAVIS_COMMIT').and_return(commit_id)
214
- expect(provider.context.env).to receive(:[]).with('TRAVIS_REPO_SLUG').and_return(repository)
215
- end
216
-
217
- example do
218
- expect(provider.github_revision).to eq({
219
- revision_type: 'GitHub',
220
- git_hub_location: {
221
- commit_id: commit_id,
222
- repository: repository
223
- }
224
- })
225
- end
226
- end
227
-
228
- context 'without required options' do
229
- before(:each) do
230
- expect(provider.options).to receive(:[]).with(:commit_id).and_return(nil)
231
- provider.options.stub(:[]).with(:repository) { nil }
232
- expect(provider.context.env).to receive(:[]).with('TRAVIS_COMMIT').and_return(nil)
233
- expect(provider.context.env).to receive(:[]).with('TRAVIS_REPO_SLUG').and_return(nil)
234
- end
235
-
236
- example do
237
- expect{provider.github_revision}.to raise_error(DPL::Error)
238
- end
239
- end
240
- end
241
-
242
- describe '#push_app' do
243
- before(:each) do
244
- old_options = provider.options
245
- provider.stub(:options) {old_options.merge({
246
- :application_name => application,
247
- :deployment_group_name => deployment_group,
248
- :description => description,
249
- :repository => 'git@github.com:travis-ci/dpl.git'
250
- })}
251
- end
252
-
253
- context 'without an error' do
254
- deployment_id = 'some-deployment-id'
255
-
256
- before do
257
- provider.code_deploy.stub_responses(:create_deployment, :deployment_id => deployment_id)
258
- end
259
-
260
- example do
261
- expect(provider).to receive(:log).with(/Triggered deployment \"#{deployment_id}\"\./)
262
- provider.push_app
263
- end
264
-
265
- before do
266
- allow(provider.code_deploy).to receive(:get_deployment).and_return(
267
- {:deployment_info => {:status => "Created"}},
268
- {:deployment_info => {:status => "Queued"}},
269
- {:deployment_info => {:status => "InProgress"}},
270
- {:deployment_info => {:status => "Succeeded"}})
271
- end
272
-
273
- example 'with :wait_until_deployed' do
274
- old_options = provider.options
275
- provider.stub(:options) {old_options.merge({
276
- app_id: 'app-id',
277
- wait_until_deployed: true})}
278
- expect(provider).to receive(:log).with(/Triggered deployment \"#{deployment_id}\"\./)
279
- expect(provider).to receive(:log).with(/Deployment successful./)
280
- provider.push_app
281
- end
282
- end
283
-
284
- context 'with an error' do
285
- before do
286
- provider.code_deploy.stub_responses(:create_deployment, 'DeploymentLimitExceededException')
287
- end
288
-
289
- example do
290
- expect(provider).to receive(:error).once
291
- provider.push_app
292
- end
293
- end
294
- end
295
-
296
- describe '#bundle_type' do
297
- context 'with s3_key' do
298
- format = 'zip'
299
- s3_key = "/some/key/name.#{format}"
300
-
301
- before(:each) do
302
- expect(provider).to receive(:s3_key).and_return(s3_key)
303
- end
304
-
305
- example do
306
- expect(provider.bundle_type).to eq(format)
307
- end
308
- end
309
-
310
- context 'without s3_key' do
311
- bundle_type = 'tar'
312
-
313
- before do
314
- expect(provider).to receive(:s3_key).and_return('')
315
- expect(provider).to receive(:option).with(:bundle_type).and_return(bundle_type)
316
- end
317
-
318
- example do
319
- expect(provider.bundle_type).to eq(bundle_type)
320
- end
321
- end
322
- end
323
-
324
- describe '#s3_key' do
325
- key = '/some/key/name.zip'
326
-
327
- context 'with key option' do
328
- before do
329
- expect(provider.options).to receive(:[]).with(:key).and_return(key)
330
- end
331
-
332
- example do
333
- expect(provider.s3_key).to eq(key)
334
- end
335
- end
336
-
337
- context 'with s3_key option' do
338
- before do
339
- expect(provider).to receive(:option).with(:s3_key).and_return(key)
340
- end
341
-
342
- example do
343
- expect(provider.s3_key).to eq(key)
344
- end
345
- end
346
- end
347
-
348
- describe '#default_description' do
349
- build_number = 2
350
-
351
- before do
352
- provider.context.env.stub(:[]).with('TRAVIS_BUILD_NUMBER').and_return(build_number)
353
- end
354
-
355
- example do
356
- expect(provider.default_description).to eq("Deploy build #{build_number} via Travis CI")
357
- end
358
- end
359
-
360
- describe '#check_auth' do
361
- example do
362
- expect(provider).to receive(:log).with("Logging in with Access Key: #{access_key_id[-4..-1].rjust(20, '*')}")
363
- provider.check_auth
364
- end
365
- end
366
- end