datadog-sdk-testing 0.2.6 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8abfa3c4a71a45a7f7be6ef19b3ac17de10812ad
4
- data.tar.gz: 952c49ece71ff1f1fa96cdaa652c3f52fbc8c393
3
+ metadata.gz: 35884f0cdb990ba4887fc07a279d45228ae91bd9
4
+ data.tar.gz: 52e671f3f5d435cea6f3ac22b1107457812c178c
5
5
  SHA512:
6
- metadata.gz: 46c82f0a53287b96e638eb1d57ff914c8e28c0a5a40cbdf0a2f01f773130dfc54bd142e73f0f6ffdab134cd874ab413d6d919c8e5cd659024bb2c655045b711f
7
- data.tar.gz: ca21e14b396d519e58d771ebc6ebc82ab1fb5f11b28d0332a408f4976c0d99b0867810893b9df034115b34b63e33d5265d58cc6304c0e4ab366d6bb5dc97f3ad
6
+ metadata.gz: 7c64ed55f6ae4d3f4cf891784e72f49e5bc6df161569ba37a387fbcfc24edbcb2984697e851a0ee72024155e0695b4125234b3dc732a3bdf884f6f90401d2c96
7
+ data.tar.gz: a81b3a9b9f631c81201d0bc382363ca36cd92bbd38d700eff38224a7fc253e54f48f56b817d26f0b67259695d350d950524428ad1965e12dd69a02bd8809e29f
@@ -1,3 +1,7 @@
1
+ # (C) Datadog, Inc. 2010-2016
2
+ # All rights reserved
3
+ # Licensed under Simplified BSD License (see LICENSE)
4
+
1
5
  # stdlib
2
6
 
3
7
  # 3rd party
@@ -1,7 +1,7 @@
1
1
  require 'ci/common'
2
2
 
3
3
  def skeleton_version
4
- ENV['FLAVOR_VERSION'] || '2.4.12'
4
+ ENV['FLAVOR_VERSION'] || 'latest'
5
5
  end
6
6
 
7
7
  def skeleton_rootdir
@@ -18,13 +18,13 @@ namespace :ci do
18
18
  "--cache-dir #{ENV['PIP_CACHE']}",
19
19
  "#{ENV['VOLATILE_DIR']}/ci.log", use_venv)
20
20
  # sample docker usage
21
- # sh %(docker create -p XXX:YYY --name skeleton source/skeleton)
21
+ # sh %(docker create -p XXX:YYY --name skeleton source/skeleton:skeleton_version)
22
22
  # sh %(docker start skeleton)
23
23
  end
24
24
 
25
25
  task before_script: ['ci:common:before_script']
26
26
 
27
- task script: ['ci:common:script'] do |_, attr|
27
+ task script: ['ci:common:script'] do
28
28
  this_provides = [
29
29
  'skeleton'
30
30
  ]
@@ -1,3 +1,7 @@
1
+ # (C) Datadog, Inc. 2010-2016
2
+ # All rights reserved
3
+ # Licensed under Simplified BSD License (see LICENSE)
4
+
1
5
  # stdlib
2
6
  from nose.plugins.attrib import attr
3
7
 
@@ -7,7 +7,6 @@ require 'timeout'
7
7
  # Colors don't work on Appveyor
8
8
  String.disable_colorization = true if Gem.win_platform?
9
9
 
10
-
11
10
  def check_env
12
11
  abort 'SDK_HOME env variable must be defined in your Rakefile to used this gem.' unless ENV['SDK_HOME']
13
12
  end
@@ -36,17 +35,21 @@ def in_venv
36
35
  ENV['RUN_VENV'] && ENV['RUN_VENV'] == 'true' ? true : false
37
36
  end
38
37
 
39
- def install_requirements(req_file, pip_options = nil, output = nil, use_venv = nil)
38
+ def install_req(requirement, pip_options = nil, output = nil, use_venv = nil)
40
39
  pip_command = use_venv ? "#{ENV['SDK_HOME']}/venv/bin/pip" : 'pip'
41
40
  redirect_output = output ? "2>&1 >> #{output}" : ''
42
41
  pip_options = '' if pip_options.nil?
42
+ unless requirement.empty? || requirement.start_with?('#')
43
+ sh %(#{pip_command} install #{requirement} #{pip_options} #{redirect_output}\
44
+ || echo 'Unable to install #{requirement}' #{redirect_output})
45
+ end
46
+ end
47
+
48
+ def install_requirements(req_file, pip_options = nil, output = nil, use_venv = nil)
43
49
  File.exist?(req_file) && File.open(req_file, 'r') do |f|
44
50
  f.each_line do |line|
45
51
  line.strip!
46
- unless line.empty? || line.start_with?('#')
47
- sh %(#{pip_command} install #{line} #{pip_options} #{redirect_output}\
48
- || echo 'Unable to install #{line}' #{redirect_output})
49
- end
52
+ install_req(line, pip_options, output, use_venv)
50
53
  end
51
54
  end
52
55
  end
@@ -74,50 +77,90 @@ def integration_tests(root_dir)
74
77
  [testable, untested]
75
78
  end
76
79
 
77
- def create_skeleton(integration)
78
- if File.directory?("#{ENV['SDK_HOME']}/#{integration}")
79
- puts "directory already exists for #{integration} - bailing out."
80
- return
80
+ def move_file(src, dst)
81
+ File.delete(dst)
82
+ File.rename(src, dst)
83
+ end
84
+
85
+ def check_travis_flavor(flavor, version = nil)
86
+ version = 'latest' if version.nil?
87
+ File.foreach("#{ENV['SDK_HOME']}/.travis.yml") do |line|
88
+ return false if line =~ /- TRAVIS_FLAVOR=#{flavor} FLAVOR_VERSION=#{version}/
81
89
  end
90
+ true
91
+ end
82
92
 
83
- puts "generating skeleton files for #{integration}"
84
- gem_home = Bundler.rubygems.find_name('datadog-sdk-testing').first.full_gem_path
85
- capitalized = integration.capitalize
86
- sh "mkdir -p #{ENV['SDK_HOME']}/#{integration}/ci"
87
- sh "cp #{gem_home}/lib/config/ci/skeleton.rake #{ENV['SDK_HOME']}/#{integration}/ci/#{integration}.rake"
88
- sh "cp #{gem_home}/lib/config/manifest.json #{ENV['SDK_HOME']}/#{integration}/manifest.json"
89
- sh "cp #{gem_home}/lib/config/check.py #{ENV['SDK_HOME']}/#{integration}/check.py"
90
- sh "cp #{gem_home}/lib/config/test_skeleton.py #{ENV['SDK_HOME']}/#{integration}/test_#{integration}.py"
91
- sh "cp #{gem_home}/lib/config/metadata.csv #{ENV['SDK_HOME']}/#{integration}/metadata.csv"
92
- sh "cp #{gem_home}/lib/config/requirements.txt #{ENV['SDK_HOME']}/#{integration}/requirements.txt"
93
- sh "cp #{gem_home}/lib/config/README.md #{ENV['SDK_HOME']}/#{integration}/README.md"
94
- Dir.glob("#{ENV['SDK_HOME']}/#{integration}/**/*") do |f|
95
- if File.file?(f)
96
- sed(f, 'skeleton', "#{integration}", 'g')
97
- sed(f, 'Skeleton', "#{capitalized}", 'g')
93
+ def add_travis_flavor(flavor, version = nil)
94
+ new_file = "#{ENV['SDK_HOME']}/.travis.yml.new"
95
+ version = 'latest' if version.nil?
96
+ added = false
97
+ File.open(new_file, 'w') do |fo|
98
+ File.foreach("#{ENV['SDK_HOME']}/.travis.yml") do |line|
99
+ if !added && line =~ /# END OF TRAVIS MATRIX|- TRAVIS_FLAVOR=#{flavor}/
100
+ fo.puts " - TRAVIS_FLAVOR=#{flavor} FLAVOR_VERSION=#{version}"
101
+ added = true
102
+ end
103
+ fo.puts line
98
104
  end
99
105
  end
100
- sh "git add #{ENV['SDK_HOME']}/#{integration}/"
106
+ move_file(new_file, "#{ENV['SDK_HOME']}/.travis.yml")
107
+ end
101
108
 
109
+ def add_circleci_flavor(flavor)
102
110
  new_file = "#{ENV['SDK_HOME']}/circle.yml.new"
103
111
  File.open(new_file, 'w') do |fo|
104
112
  File.foreach("#{ENV['SDK_HOME']}/circle.yml") do |line|
105
- fo.puts " - rake ci:run[#{integration}]" if line =~ /bundle\ exec\ rake\ requirements/
113
+ fo.puts " - rake ci:run[#{flavor}]" if line =~ /bundle\ exec\ rake\ requirements/
106
114
  fo.puts line
107
115
  end
108
116
  end
109
- File.delete("#{ENV['SDK_HOME']}/circle.yml")
110
- File.rename(new_file, "#{ENV['SDK_HOME']}/circle.yml")
117
+ move_file(new_file, "#{ENV['SDK_HOME']}/circle.yml")
118
+ end
111
119
 
112
- new_file = "#{ENV['SDK_HOME']}/.travis.yml.new"
113
- File.open(new_file, 'w') do |fo|
114
- File.foreach("#{ENV['SDK_HOME']}/.travis.yml") do |line|
115
- fo.puts " - rake ci:run[#{integration}]" if line =~ /bundle\ exec\ rake\ requirements/
116
- fo.puts line
120
+ def copy_skeleton(source, dst, integration)
121
+ gem_home = Bundler.rubygems.find_name('datadog-sdk-testing').first.full_gem_path
122
+ sh "cp #{gem_home}/#{source} #{ENV['SDK_HOME']}/#{integration}/#{dst}"
123
+ end
124
+
125
+ def create_integration_path(integration)
126
+ sh "mkdir -p #{ENV['SDK_HOME']}/#{integration}/ci"
127
+ end
128
+
129
+ def rename_skeleton(integration)
130
+ capitalized = integration.capitalize
131
+ Dir.glob("#{ENV['SDK_HOME']}/#{integration}/**/*") do |f|
132
+ if File.file?(f)
133
+ sed(f, 'skeleton', integration.to_s, 'g')
134
+ sed(f, 'Skeleton', capitalized.to_s, 'g')
117
135
  end
118
136
  end
119
- File.delete("#{ENV['SDK_HOME']}/.travis.yml")
120
- File.rename(new_file, "#{ENV['SDK_HOME']}/.travis.yml")
137
+ end
138
+
139
+ def generate_skeleton(integration)
140
+ copy_skeleton('lib/config/ci/skeleton.rake', "ci/#{integration}.rake", integration)
141
+ copy_skeleton('lib/config/manifest.json', 'manifest,json', integration)
142
+ copy_skeleton('lib/config/check.py', 'check.py', integration)
143
+ copy_skeleton('lib/config/test_skeleton.py', "test_#{integration}.py", integration)
144
+ copy_skeleton('lib/config/metadata.csv', 'metadata.csv', integration)
145
+ copy_skeleton('lib/config/requirements.txt', 'requirements.txt', integration)
146
+ copy_skeleton('lib/config/README.md', 'README.md', integration)
147
+ end
148
+
149
+ def create_skeleton(integration)
150
+ if File.directory?("#{ENV['SDK_HOME']}/#{integration}")
151
+ puts "directory already exists for #{integration} - bailing out."
152
+ return
153
+ end
154
+
155
+ puts "generating skeleton files for #{integration}"
156
+ create_integration_path(integration.to_s)
157
+ generate_skeleton(integration.to_s)
158
+ rename_skeleton(integration.to_s)
159
+
160
+ sh "git add #{ENV['SDK_HOME']}/#{integration}/"
161
+
162
+ add_travis_flavor(integration)
163
+ add_circleci_flavor(integration)
121
164
  end
122
165
 
123
166
  # helper class to wait for TCP/HTTP services to boot
@@ -38,16 +38,15 @@ end
38
38
  desc 'Clean development environment for the SDK (remove!)'
39
39
  task 'clean_env' do
40
40
  check_env
41
- input = ''
42
- print "Are you sure you want to delete the SDK environment (y/n)? "
41
+ print 'Are you sure you want to delete the SDK environment (y/n)? '
43
42
  input = STDIN.gets.chomp
44
43
  case input.upcase
45
- when "Y"
44
+ when 'Y'
46
45
  `rm -rf #{ENV['SDK_HOME']}/venv` if File.directory?("#{ENV['SDK_HOME']}/venv")
47
46
  `rm -rf #{ENV['SDK_HOME']}/embedded` if File.directory?("#{ENV['SDK_HOME']}/embedded")
48
- puts "virtual environment, agent source removed."
49
- when "N"
50
- puts "aborting the task..."
47
+ puts 'virtual environment, agent source removed.'
48
+ when 'N'
49
+ puts 'aborting the task...'
51
50
  end
52
51
  end
53
52
 
@@ -93,6 +92,21 @@ namespace :generate do
93
92
  check_env
94
93
  create_skeleton(args[:option])
95
94
  end
95
+
96
+ desc 'Add a new integration flavor to Travis - option may be option or option,version'
97
+ task :travis_flavor, [:option] do |_, args|
98
+ check_env
99
+
100
+ integration = args[:option]
101
+ flavor = 'latest'
102
+ flavor = args.extras[0] if args.extras.count == 1
103
+ puts "Adding integration flavor to travis: #{integration}:#{flavor}"
104
+ if check_travis_flavor(integration, flavor)
105
+ add_travis_flavor(integration, flavor)
106
+ else
107
+ puts "#{integration}:#{flavor} already set in travis... skipping."
108
+ end
109
+ end
96
110
  end
97
111
 
98
112
  namespace :ci do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: datadog-sdk-testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jaime Fullaondo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-08 00:00:00.000000000 Z
11
+ date: 2016-08-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Datadog Integration SDK testing/scaffolding gem
14
14
  email: jaime.fullaondo@datadoghq.com