Skip to content

Commit

Permalink
gitignore semconv repo clone; rake improvements
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
robbkidd committed Jul 12, 2024
1 parent ba6621e commit 64a9864
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions semantic_conventions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tmp/
16 changes: 8 additions & 8 deletions semantic_conventions/Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion semantic_conventions/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

0 comments on commit 64a9864

Please sign in to comment.