Skip to content
26 changes: 23 additions & 3 deletions .github/actions/test_gem/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ inputs:
required: false
type: boolean
default: false
minimum_coverage:
description: Minimum test coverage
required: false
type: string
default: 85
rubocop:
description: Run Rubocop
required: false
Expand Down Expand Up @@ -93,9 +98,9 @@ runs:
if [[ -f "Appraisals" ]]; then
for i in `bundle exec appraisal list | sed 's/-/_/g' `; do
echo "::group::🔎 Appraising ${i}"
BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle install --quiet --jobs=3 --retry=4 && \
BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle show && \
BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle exec rake test
SIMPLECOV_COMMAND_NAME="appraisal_${i}" BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle install --quiet --jobs=3 --retry=4 && \
SIMPLECOV_COMMAND_NAME="appraisal_${i}" BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle show && \
SIMPLECOV_COMMAND_NAME="appraisal_${i}" BUNDLE_GEMFILE=gemfiles/${i}.gemfile bundle exec rake test
echo "::endgroup::"
done
else
Expand All @@ -111,6 +116,21 @@ runs:
bundle exec rake yard
working-directory: "${{ steps.setup.outputs.gem_dir }}"

- name: Coverage
shell: bash
if: "${{!startsWith(inputs.ruby, 'truffleruby')}}"
# This starts a new simplecov run which tracks nothing of its own,
# but merges with the existing coverage reports generated during testing.
env:
MINIMUM_COVERAGE: ${{ inputs.minimum_coverage || 85 }}
run: 'bundle exec ruby -e ''require "simplecov"; SimpleCov.minimum_coverage(ENV["MINIMUM_COVERAGE"].to_i); SimpleCov.collate Dir["coverage/**/.resultset.json"];'''
working-directory: "${{ steps.setup.outputs.gem_dir }}"

- name: Cleanup coverage artifacts
shell: bash
run: rm -rf coverage
working-directory: "${{ steps.setup.outputs.gem_dir }}"

- name: Rubocop
shell: bash
if: "${{ inputs.rubocop == 'true' }}"
Expand Down
8 changes: 8 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
with:
gem: "${{ matrix.gem }}"
ruby: "3.4"
minimum_coverage: 62
- name: "Test Ruby 3.3"
uses: ./.github/actions/test_gem
with:
Expand All @@ -55,18 +56,21 @@ jobs:
yard: true
rubocop: true
build: true
minimum_coverage: 62
- name: "Test JRuby"
if: startsWith(matrix.os, 'ubuntu')
uses: ./.github/actions/test_gem
with:
gem: "${{ matrix.gem }}"
ruby: "jruby"
minimum_coverage: 62
- name: "Test truffleruby"
if: startsWith(matrix.os, 'ubuntu')
uses: ./.github/actions/test_gem
with:
gem: "${{ matrix.gem }}"
ruby: "truffleruby"
minimum_coverage: 62

exporters:
if: ${{ github.repository == 'open-telemetry/opentelemetry-ruby' }}
Expand Down Expand Up @@ -98,6 +102,7 @@ jobs:
with:
gem: "${{ matrix.gem }}"
ruby: "3.4"
minimum_coverage: 58
- name: "Test Ruby 3.3"
uses: ./.github/actions/test_gem
with:
Expand All @@ -106,12 +111,14 @@ jobs:
yard: true
rubocop: true
build: true
minimum_coverage: 58
- name: "Test Zipkin with JRuby"
if: "${{ startsWith(matrix.os, 'ubuntu') && matrix.gem == 'opentelemetry-exporter-zipkin' }}"
uses: ./.github/actions/test_gem
with:
gem: "${{ matrix.gem }}"
ruby: "jruby"
minimum_coverage: 58
- name: "Truffleruby Filter"
id: truffleruby_skip
shell: bash
Expand All @@ -126,6 +133,7 @@ jobs:
with:
gem: "${{ matrix.gem }}"
ruby: "truffleruby"
minimum_coverage: 58

propagators:
if: ${{ github.repository == 'open-telemetry/opentelemetry-ruby' }}
Expand Down
16 changes: 16 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

require 'digest'

digest = Digest::MD5.new
digest.update('test')
digest.update(ENV.fetch('BUNDLE_GEMFILE', 'gemfile')) if ENV['APPRAISAL_INITIALIZED']

ENV['ENABLE_COVERAGE'] ||= '1'

if ENV['ENABLE_COVERAGE'].to_i.positive?
SimpleCov.command_name(ENV['SIMPLECOV_COMMAND_NAME'] || digest.hexdigest)
SimpleCov.start do
add_filter %r{^/test/}
end
end
7 changes: 1 addition & 6 deletions api/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
SimpleCov.minimum_coverage 85
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry'
require 'minitest/autorun'
Expand Down
6 changes: 1 addition & 5 deletions common/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry/common'
require 'minitest/autorun'
6 changes: 1 addition & 5 deletions exporter/jaeger/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry/exporter/jaeger'
require 'minitest/autorun'
Expand Down
6 changes: 1 addition & 5 deletions exporter/otlp-common/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
end

require 'simplecov'
require 'opentelemetry/sdk'
require 'opentelemetry-test-helpers'
require 'opentelemetry-exporter-otlp-common'
Expand Down
6 changes: 1 addition & 5 deletions exporter/otlp-grpc/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry/exporter/otlp/grpc'
require 'minitest/autorun'
Expand Down
6 changes: 1 addition & 5 deletions exporter/otlp-http/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry-exporter-otlp-http'
require 'minitest/autorun'
Expand Down
11 changes: 1 addition & 10 deletions exporter/otlp-logs/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start do
enable_coverage :branch
add_filter '/test/'
end

SimpleCov.minimum_coverage 85
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry/exporter/otlp_logs'
require 'minitest/autorun'
Expand Down
6 changes: 1 addition & 5 deletions exporter/otlp-metrics/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry/exporter/otlp_metrics'
require 'minitest/autorun'
Expand Down
6 changes: 1 addition & 5 deletions exporter/otlp/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry/exporter/otlp'
require 'minitest/autorun'
Expand Down
6 changes: 1 addition & 5 deletions exporter/zipkin/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry/exporter/zipkin'
require 'minitest/autorun'
Expand Down
8 changes: 0 additions & 8 deletions logs_api/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,5 @@
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'

SimpleCov.start do
enable_coverage :branch
add_filter '/test/'
end

SimpleCov.minimum_coverage 85

require 'opentelemetry-logs-api'
require 'minitest/autorun'
8 changes: 0 additions & 8 deletions logs_sdk/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,6 @@
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'

SimpleCov.start do
enable_coverage :branch
add_filter '/test/'
end

SimpleCov.minimum_coverage 85

require 'opentelemetry-logs-api'
require 'opentelemetry-logs-sdk'
require 'opentelemetry-test-helpers'
Expand Down
5 changes: 1 addition & 4 deletions metrics_api/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

# require 'simplecov'
# # SimpleCov.start
# # SimpleCov.minimum_coverage 85

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry-metrics-api'
require 'minitest/autorun'
Expand Down
5 changes: 1 addition & 4 deletions metrics_sdk/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

# require 'simplecov'
# # SimpleCov.start
# # SimpleCov.minimum_coverage 85

require 'simplecov'
require 'opentelemetry-metrics-sdk'
require 'opentelemetry-test-helpers'
require 'minitest/autorun'
Expand Down
1 change: 1 addition & 0 deletions propagator/b3/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'minitest/autorun'
require 'opentelemetry-propagator-b3'
1 change: 1 addition & 0 deletions propagator/jaeger/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'minitest/autorun'
require 'opentelemetry-propagator-jaeger'
1 change: 1 addition & 0 deletions registry/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'opentelemetry-registry'
require 'minitest/autorun'
require 'rspec/mocks/minitest_integration'
Expand Down
7 changes: 1 addition & 6 deletions sdk/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
SimpleCov.minimum_coverage 85
end

require 'simplecov'
require 'opentelemetry-test-helpers'
require 'opentelemetry-sdk'
require 'opentelemetry-instrumentation-base'
Expand Down
5 changes: 1 addition & 4 deletions sdk_experimental/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

# require 'simplecov'
# # SimpleCov.start
# # SimpleCov.minimum_coverage 85

require 'simplecov'
require 'opentelemetry-sdk-experimental'
require 'opentelemetry-test-helpers'
require 'minitest/autorun'
Expand Down
7 changes: 1 addition & 6 deletions semantic_conventions/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
SimpleCov.minimum_coverage 85
end

require 'simplecov'
require 'minitest/autorun'

Dir[File.join(File.dirname(__FILE__), '..', 'lib', 'opentelemetry', '**', '*.rb')].each { |file| require file }
7 changes: 1 addition & 6 deletions test_helpers/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,7 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'opentelemetry-sdk'
require 'opentelemetry-test-helpers'
require 'minitest/autorun'

if RUBY_ENGINE == 'ruby'
require 'simplecov'
SimpleCov.start
SimpleCov.minimum_coverage 85
end