Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Fix simplecov configuration #1366

Merged
merged 2 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/actions/test_gem/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ inputs:
required: false
type: boolean
default: false
coverage:
description: Enforce test coverage
required: false
type: boolean
default: false
minimum_coverage:
description: Minimum test coverage
required: false
type: string
default: 85
build:
description: Build gem
required: false
Expand Down Expand Up @@ -161,6 +171,14 @@ runs:
bundle exec rake rubocop
working-directory: "${{ steps.setup.outputs.gem_dir }}"

- name: Coverage
shell: bash
if: "${{ inputs.coverage == 'true' }}"
# This starts a new simplecov run which tracks nothing of its own,
# but merges with the existing coverage reports generated during testing.
run: 'bundle exec ruby -e ''require "simplecov"; SimpleCov.minimum_coverage(${{ inputs.minimum_coverage }})'''
working-directory: "${{ steps.setup.outputs.gem_dir }}"

- name: Build Gem
shell: bash
if: "${{ inputs.build == 'true' }}"
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/ci-contrib.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "Test JRuby"
if: "${{ matrix.os == 'ubuntu-latest' }}"
Expand Down Expand Up @@ -125,6 +126,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "Test JRuby"
if: "${{ matrix.os == 'ubuntu-latest' }}"
Expand Down Expand Up @@ -162,6 +164,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "Test JRuby"
if: "${{ matrix.os == 'ubuntu-latest' && steps.jruby_skip.outputs.skip == 'false' }}"
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/ci-instrumentation-with-services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
kaylareopelle marked this conversation as resolved.
Show resolved Hide resolved
build: true
- name: "Test JRuby"
uses: ./.github/actions/test_gem
Expand Down Expand Up @@ -92,6 +93,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
mysql:
Expand Down Expand Up @@ -129,6 +131,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
zookeeper:
Expand Down Expand Up @@ -182,6 +185,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
redis:
Expand Down Expand Up @@ -226,6 +230,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
postgres:
Expand Down Expand Up @@ -267,6 +272,7 @@ jobs:
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
services:
rabbitmq:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/ci-instrumentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,11 @@ jobs:
- name: "Test Ruby 3.1"
uses: ./.github/actions/test_gem
with:
gem: "opentelemetry-instrumentation-${{ matrix.gem }}"
gem: "opentelemetry-instrumentation-${{ matrix.gem }}"
ruby: "3.1"
yard: true
rubocop: true
coverage: true
build: true
- name: "JRuby Filter"
id: jruby_skip
Expand Down
14 changes: 14 additions & 0 deletions .simplecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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(digest.hexdigest)
SimpleCov.start do
add_filter %r{^/test/}
end
end
1 change: 1 addition & 0 deletions helpers/mysql/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 13.0'
spec.add_development_dependency 'rubocop', '~> 1.71.0'
spec.add_development_dependency 'rubocop-performance', '~> 1.23.0'
spec.add_development_dependency 'simplecov', '~> 0.22.0'
spec.add_development_dependency 'yard', '~> 0.9'
spec.add_development_dependency 'yard-doctest', '~> 0.1.6'

Expand Down
1 change: 1 addition & 0 deletions helpers/sql-obfuscation/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_mailer/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 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_pack/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 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/action_view/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 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_job/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
# SPDX-License-Identifier: Apache-2.0
ENV['OTEL_LOG_LEVEL'] ||= 'fatal'

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_record/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/active_support/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/all/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/aws_lambda/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/aws_sdk/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
4 changes: 1 addition & 3 deletions instrumentation/base/test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@
#
# SPDX-License-Identifier: Apache-2.0

require 'simplecov'
require 'bundler/setup'
Bundler.require(:default, :development, :test)

SimpleCov.start
SimpleCov.minimum_coverage 85

require 'opentelemetry-instrumentation-base'
require 'minitest/autorun'

Expand Down
1 change: 1 addition & 0 deletions instrumentation/bunny/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/concurrent_ruby/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/dalli/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/delayed_job/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 'logger'
require 'bundler/setup'
Bundler.require(:default, :development, :test)
Expand Down
1 change: 1 addition & 0 deletions instrumentation/ethon/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/excon/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/faraday/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/grape/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/graphql/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/grpc/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/gruf/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/sdk'
require 'minitest/autorun'
require 'webmock/minitest'
Expand Down
1 change: 1 addition & 0 deletions instrumentation/http/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/http_client/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/httpx/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/koala/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/lmdb/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/mongo/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
1 change: 1 addition & 0 deletions instrumentation/mysql2/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 'bundler/setup'
Bundler.require(:default, :development, :test)

Expand Down
Loading
Loading