forked from DataDog/integrations-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
82 lines (73 loc) · 2.41 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/usr/bin/env rake
require 'rake'
unless ENV['CI']
rakefile_dir = File.dirname(__FILE__)
ENV['TRAVIS_BUILD_DIR'] = rakefile_dir
ENV['INTEGRATIONS_DIR'] = File.join(rakefile_dir, 'embedded')
ENV['PIP_CACHE'] = File.join(rakefile_dir, '.cache/pip')
ENV['VOLATILE_DIR'] = '/tmp/integration-sdk-testing'
ENV['CONCURRENCY'] = ENV['CONCURRENCY'] || '2'
ENV['NOSE_FILTER'] = ENV['NOSE_FILTER'] || 'not windows'
ENV['RUN_VENV'] = 'true'
ENV['SDK_TESTING'] = 'true'
end
ENV['SDK_HOME'] = File.dirname(__FILE__)
spec = Gem::Specification.find_by_name 'datadog-sdk-testing'
load "#{spec.gem_dir}/lib/tasks/sdk.rake"
def find_check_files
Dir.glob("#{ENV['SDK_HOME']}/*/check.py").collect do |file_path|
check_basename = "#{File.basename(File.dirname(file_path))}.py"
[check_basename, file_path]
end.entries
end
def find_yaml_confs
yaml_confs = Dir.glob("#{ENV['SDK_HOME']}/*/conf.yaml.example").collect do |file_path|
yaml_basename = "#{File.basename(File.dirname(file_path))}.yaml.example"
[yaml_basename, file_path]
end.entries
yaml_confs += Dir.glob("#{ENV['SDK_HOME']}/*/conf/*.yaml.example").collect do |file_path|
yaml_basename = File.basename(file_path)
[yaml_basename, file_path]
end.entries
yaml_confs
end
def find_inconsistencies(files, dd_agent_base_dir)
inconsistencies = []
files.each do |file_basename, file_path|
file_content = File.read(file_path)
dd_agent_file_path = File.join(
ENV['SDK_HOME'],
'embedded',
'dd-agent',
dd_agent_base_dir,
file_basename
)
unless File.exist?(dd_agent_file_path)
inconsistencies << "#{file_basename} not found in dd-agent/#{dd_agent_base_dir}/"
next
end
if file_content != File.read(dd_agent_file_path)
inconsistencies << file_basename
end
end
inconsistencies
end
def print_inconsistencies(display_name, inconsistencies)
if inconsistencies.empty?
puts "No #{display_name} inconsistencies found"
else
puts "## #{display_name} inconsistencies:"
puts inconsistencies.join("\n")
end
end
desc 'Outputs the checks/example configs of this repo that do not match the ones in `dd-agent` (temporary task)'
task dd_agent_consistency: [:pull_latest_agent] do
print_inconsistencies(
'check file',
find_inconsistencies(find_check_files, 'checks.d')
)
print_inconsistencies(
'yaml example file',
find_inconsistencies(find_yaml_confs, 'conf.d')
)
end