forked from DataDog/datadog-process-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
139 lines (119 loc) · 3.39 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
require "./gorake.rb"
def os
case RUBY_PLATFORM
when /linux/
"linux"
when /darwin/
"darwin"
else
fail 'Unsupported OS'
end
end
desc "Setup dependencies"
task :deps do
system("go mod download")
end
task :default => [:ci]
desc "Build Datadog Process agent"
task :build do
case os
when "windows"
bin = "process-agent.exe"
else
bin = "process-agent"
end
if ENV["STS_DEV_CONTAINER"] != "true"
sh "./prebuild-datadog-agent.sh -i"
end
go_build("github.com/StackVista/stackstate-process-agent/cmd/agent", {
:cmd => "go build -o #{bin}",
:race => ENV['GO_RACE'] == 'true',
:add_build_vars => ENV['PROCESS_AGENT_ADD_BUILD_VARS'] != 'false',
:embed_path => ENV['STACKSTATE_EMBEDDED_PATH'],
:bpf => true
})
end
desc "Run goderive to generate necessary go code"
task :derive do
sh "go run github.com/awalterschulze/goderive@886b66b111a4 ./..."
end
desc "Run prebuild steps"
task :prebuild do
sh "./prebuild-datadog-agent.sh -g"
end
desc "Run goderive to generate necessary go code (Windows)"
task :derive_win do
system("go install github.com/awalterschulze/goderive@886b66b111a4")
system("go generate ./...")
end
desc "Install Datadog Process agent"
task :install do
case os
when "windows"
bin = "process-agent.exe"
else
bin = "process-agent"
end
go_build("github.com/StackVista/stackstate-process-agent/agent", :cmd=> "go build -i -o $GOPATH/bin/#{bin}")
end
desc "Test Datadog Process agent"
task :test do
if ENV["STS_DEV_CONTAINER"] != "true"
sh "./prebuild-datadog-agent.sh -i"
end
go_test("$(go list ./...)", {
:bpf => true,
:embed_path => ENV['STACKSTATE_EMBEDDED_PATH'],
})
end
desc "Test Datadog Process agent -- cmd"
task :cmdtest do
cmd = "for /f %f in ('go list ./... ^| find /V \"vendor\"') do go test %f"
sh cmd
end
task :vet do
if ENV["STS_DEV_CONTAINER"] != "true"
sh "./prebuild-datadog-agent.sh -i"
end
go_vet("$(go list ./...)", {
:bpf => true,
:embed_path => ENV['STACKSTATE_EMBEDDED_PATH'],
})
end
task :fmt do
packages = `go list ./... | grep -v vendor`.split("\n")
packages.each do |pkg|
go_fmt(pkg)
end
end
task :lint do
sh "go install github.com/mgechev/[email protected]"
packages = `go list ./... | grep -v vendor`.split("\n")
packages.each do |pkg|
puts "revive -formatter stylish -config revive-recommended.toml #{pkg}"
output = `revive -formatter stylish -config revive-recommended.toml #{pkg}`
puts output
if output != ""
fail "Error during linting"
end
end
end
desc "Compile the protobuf files for the Process Agent"
task :protobuf do
protocv = `bash -c "protoc --version"`.strip
if protocv != 'libprotoc 3.6.1'
fail "Requires protoc version 3.6.1"
end
gogo_path = get_go_module_path("github.com/gogo/protobuf")
sketched_path = get_go_module_path("github.com/DataDog/sketches-go")
sh "protoc proto/agent_payload.proto --proto_path=#{gogo_path} -I proto --gogofaster_out model/"
sh "protoc proto/agent.proto --proto_path=#{gogo_path} --proto_path=#{sketched_path} -I proto --gogofaster_out model/"
end
desc "Process Agent CI script (fmt, vet, etc)"
task :ci => [:deps, :fmt, :vet, :test, :lint, :build]
desc "Process Agent local build"
task :local_build => [:deps, :prebuild, :build]
task :err do
system("go install github.com/kisielk/errcheck")
sh "errcheck github.com/StackVista/stackstate-process-agent"
end