Skip to content

Commit 64a9864

Browse files
committed
gitignore semconv repo clone; rake improvements
* Move to a tmp/ dir and ignore that. * Update the git commands to be able to reuse one directory for the repo working copy, just update what's needed for a different tag between iterations. (Generally only an improvement for dev envs.) * Use sh() for shell commands so that tasks fail if their commands fail. * Appease Rubocop.
1 parent ba6621e commit 64a9864

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

semantic_conventions/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tmp/

semantic_conventions/Rakefile

+8-8
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ end
3232

3333
SPEC_VERSION = '1.25.0'
3434
GENERATOR_VERSION = '0.24.0'
35-
semconv_source_dir = Pathname.new("./tmpsemconvrepo_v#{SPEC_VERSION}")
35+
semconv_source_dir = Pathname.new('./tmp/semconvrepo')
3636
conventions_output_dir = Pathname.new('./lib/opentelemetry/semantic_conventions')
3737
candidates_output_dir = Pathname.new('./lib/opentelemetry/semantic_candidates')
3838

39-
EXCLUDED_ATTRIBUTES = %w[]
39+
EXCLUDED_ATTRIBUTES = %w[].freeze
4040

4141
task generate: %i[update_gem_version generate_stable_attributes generate_candidate_attributes]
4242

4343
directory semconv_source_dir do
44-
`git clone --depth=1 --branch v#{SPEC_VERSION} https://github.com/open-telemetry/semantic-conventions.git #{semconv_source_dir}`
44+
sh "git clone --tags --depth=1 --branch v#{SPEC_VERSION} https://github.com/open-telemetry/semantic-conventions.git #{semconv_source_dir}"
4545
end
4646

4747
task check_out_semconv_version: [semconv_source_dir] do
4848
Dir.chdir(semconv_source_dir) do
49-
`git fetch`
50-
`git checkout "v#{SPEC_VERSION}"`
49+
sh "git fetch --depth 1 origin tag v#{SPEC_VERSION}"
50+
sh "git checkout 'v#{SPEC_VERSION}'"
5151
end
5252
end
5353

@@ -88,10 +88,10 @@ def semconvgen(semconv_source, output_root:, kind:, selector:)
8888
]
8989

9090
puts "Running: #{cmd.join(' ')}"
91-
`#{cmd.join(' ')}`
91+
sh cmd.join(' ')
9292
end
9393

9494
task :update_gem_version do
95-
`sed -i.bak "s/VERSION = '.*'/VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb`
96-
`rm lib/opentelemetry/semantic_conventions/version.rb.bak`
95+
sh %(sed -i.bak "s/VERSION = '.*'/VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb)
96+
sh 'rm lib/opentelemetry/semantic_conventions/version.rb.bak'
9797
end

semantic_conventions/test/opentelemetry/semantic_conventions/attributes_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
.const_get(root_namespace)
2020
.constants
2121
.each do |stable_const|
22-
it "#{stable_const}" do
22+
it stable_const.to_s do
2323
candidate_namespace = OpenTelemetry::SemanticCandidates.const_get(root_namespace)
2424
assert candidate_namespace.constants.include?(stable_const), "Missing stable constant in candidates: #{stable_const}"
2525
end

semantic_conventions/test/test_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
require 'minitest/autorun'
1414
require 'pry'
1515

16-
Dir[File.join(File.dirname(__FILE__), '..', 'lib', 'opentelemetry', '**', '*.rb')].sort.each { |file| require file }
16+
Dir[File.join(File.dirname(__FILE__), '..', 'lib', 'opentelemetry', '**', '*.rb')].each { |file| require file }

0 commit comments

Comments
 (0)