From 64a9864ec41d7c75aecc559d792dac8672b68a82 Mon Sep 17 00:00:00 2001 From: Robb Kidd Date: Fri, 12 Jul 2024 12:36:54 -0400 Subject: [PATCH] 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. --- semantic_conventions/.gitignore | 1 + semantic_conventions/Rakefile | 16 ++++++++-------- .../semantic_conventions/attributes_test.rb | 2 +- semantic_conventions/test/test_helper.rb | 2 +- 4 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 semantic_conventions/.gitignore diff --git a/semantic_conventions/.gitignore b/semantic_conventions/.gitignore new file mode 100644 index 0000000000..3fec32c842 --- /dev/null +++ b/semantic_conventions/.gitignore @@ -0,0 +1 @@ +tmp/ diff --git a/semantic_conventions/Rakefile b/semantic_conventions/Rakefile index c38761be5d..12658b9f36 100644 --- a/semantic_conventions/Rakefile +++ b/semantic_conventions/Rakefile @@ -32,22 +32,22 @@ end SPEC_VERSION = '1.25.0' GENERATOR_VERSION = '0.24.0' -semconv_source_dir = Pathname.new("./tmpsemconvrepo_v#{SPEC_VERSION}") +semconv_source_dir = Pathname.new('./tmp/semconvrepo') conventions_output_dir = Pathname.new('./lib/opentelemetry/semantic_conventions') candidates_output_dir = Pathname.new('./lib/opentelemetry/semantic_candidates') -EXCLUDED_ATTRIBUTES = %w[] +EXCLUDED_ATTRIBUTES = %w[].freeze task generate: %i[update_gem_version generate_stable_attributes generate_candidate_attributes] directory semconv_source_dir do - `git clone --depth=1 --branch v#{SPEC_VERSION} https://github.com/open-telemetry/semantic-conventions.git #{semconv_source_dir}` + sh "git clone --tags --depth=1 --branch v#{SPEC_VERSION} https://github.com/open-telemetry/semantic-conventions.git #{semconv_source_dir}" end task check_out_semconv_version: [semconv_source_dir] do Dir.chdir(semconv_source_dir) do - `git fetch` - `git checkout "v#{SPEC_VERSION}"` + sh "git fetch --depth 1 origin tag v#{SPEC_VERSION}" + sh "git checkout 'v#{SPEC_VERSION}'" end end @@ -88,10 +88,10 @@ def semconvgen(semconv_source, output_root:, kind:, selector:) ] puts "Running: #{cmd.join(' ')}" - `#{cmd.join(' ')}` + sh cmd.join(' ') end task :update_gem_version do - `sed -i.bak "s/VERSION = '.*'/VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb` - `rm lib/opentelemetry/semantic_conventions/version.rb.bak` + sh %(sed -i.bak "s/VERSION = '.*'/VERSION = '#{SPEC_VERSION}'/g" lib/opentelemetry/semantic_conventions/version.rb) + sh 'rm lib/opentelemetry/semantic_conventions/version.rb.bak' end diff --git a/semantic_conventions/test/opentelemetry/semantic_conventions/attributes_test.rb b/semantic_conventions/test/opentelemetry/semantic_conventions/attributes_test.rb index bfaed15a1e..58e153b303 100644 --- a/semantic_conventions/test/opentelemetry/semantic_conventions/attributes_test.rb +++ b/semantic_conventions/test/opentelemetry/semantic_conventions/attributes_test.rb @@ -19,7 +19,7 @@ .const_get(root_namespace) .constants .each do |stable_const| - it "#{stable_const}" do + it stable_const.to_s do candidate_namespace = OpenTelemetry::SemanticCandidates.const_get(root_namespace) assert candidate_namespace.constants.include?(stable_const), "Missing stable constant in candidates: #{stable_const}" end diff --git a/semantic_conventions/test/test_helper.rb b/semantic_conventions/test/test_helper.rb index e53c8ef6e8..43bd7417f3 100644 --- a/semantic_conventions/test/test_helper.rb +++ b/semantic_conventions/test/test_helper.rb @@ -13,4 +13,4 @@ require 'minitest/autorun' require 'pry' -Dir[File.join(File.dirname(__FILE__), '..', 'lib', 'opentelemetry', '**', '*.rb')].sort.each { |file| require file } +Dir[File.join(File.dirname(__FILE__), '..', 'lib', 'opentelemetry', '**', '*.rb')].each { |file| require file }