forked from open-telemetry/opentelemetry-ruby
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
64 lines (52 loc) · 1.57 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
# frozen_string_literal: true
# Copyright The OpenTelemetry Authors
#
# SPDX-License-Identifier: Apache-2.0
require 'bundler/gem_tasks'
require 'rake/testtask'
require 'yard'
require 'rubocop/rake_task'
require 'tmpdir'
SPEC_VERSION = '1.10.0'
RuboCop::RakeTask.new
Rake::TestTask.new :test do |t|
t.libs << '../api/lib'
t.libs << 'test'
t.libs << 'lib'
t.test_files = FileList['test/**/*_test.rb']
end
YARD::Rake::YardocTask.new do |t|
t.stats_options = ['--list-undoc']
end
if RUBY_ENGINE == 'truffleruby'
task default: %i[generate test]
else
task default: %i[generate test rubocop yard]
end
task :generate do
cwd = Dir.pwd
Dir.mktmpdir('opentelemetry-specification', Dir.pwd) do |tmpdir|
`git clone https://github.com/open-telemetry/opentelemetry-specification.git #{tmpdir}`
Dir.chdir(tmpdir) do
`git fetch`
`git checkout "v#{SPEC_VERSION}"`
end
%w[trace resource].each do |kind|
cmd = %W[
docker run --rm
-v "#{tmpdir}/semantic_conventions/#{kind}":/source
-v "#{cwd}/templates":/templates
-v "#{cwd}/lib":/output
otel/semconvgen:0.11.1
-f /source code
--template /templates/semantic_conventions.j2
--output /output/opentelemetry/semantic_conventions/#{kind}.rb
-Dmodule=#{kind[0].upcase}#{kind[1..-1]}
]
puts "Running: #{cmd.join(' ')}"
`#{cmd.join(' ')}`
end
end
`sed -i.bak "s/VERSION = '.*'/VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb`
`rm lib/opentelemetry/semantic_conventions/version.rb.bak`
end