Skip to content

Commit

Permalink
Merge pull request #4373 from DataDog/tonycthsu/coverage
Browse files Browse the repository at this point in the history
Upload coverage to codecov
  • Loading branch information
TonyCTHsu authored Feb 13, 2025
2 parents 20886bc + c47ee3e commit 5858773
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,9 @@ orbs:
- run:
name: Generate combined coverage report for all tests
command: COVERAGE_DIR=/tmp/workspace/coverage bundle exec rake coverage:report
- codecov/upload:
file: /tmp/workspace/coverage/report/coverage.xml
# Migrate to Github Actions
# - codecov/upload:
# file: /tmp/workspace/coverage/report/coverage.xml
- run:
name: Generate individual coverage report for each Ruby version
command: COVERAGE_DIR=/tmp/workspace/coverage bundle exec rake coverage:report_per_ruby_version
Expand Down
116 changes: 116 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/ruby-34/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -152,6 +154,11 @@ jobs:
with:
name: junit-ruby-34-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-ruby-34-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-ruby-33:
runs-on: ubuntu-24.04
name: batch (ruby-3.3)
Expand Down Expand Up @@ -278,6 +285,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/ruby-33/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -289,6 +298,11 @@ jobs:
with:
name: junit-ruby-33-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-ruby-33-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-ruby-32:
runs-on: ubuntu-24.04
name: batch (ruby-3.2)
Expand Down Expand Up @@ -415,6 +429,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/ruby-32/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -426,6 +442,11 @@ jobs:
with:
name: junit-ruby-32-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-ruby-32-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-ruby-31:
runs-on: ubuntu-24.04
name: batch (ruby-3.1)
Expand Down Expand Up @@ -552,6 +573,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/ruby-31/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -563,6 +586,11 @@ jobs:
with:
name: junit-ruby-31-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-ruby-31-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-ruby-30:
runs-on: ubuntu-24.04
name: batch (ruby-3.0)
Expand Down Expand Up @@ -689,6 +717,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/ruby-30/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -700,6 +730,11 @@ jobs:
with:
name: junit-ruby-30-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-ruby-30-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-ruby-27:
runs-on: ubuntu-24.04
name: batch (ruby-2.7)
Expand Down Expand Up @@ -826,6 +861,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/ruby-27/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -837,6 +874,11 @@ jobs:
with:
name: junit-ruby-27-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-ruby-27-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-ruby-26:
runs-on: ubuntu-24.04
name: batch (ruby-2.6)
Expand Down Expand Up @@ -963,6 +1005,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/ruby-26/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -974,6 +1018,11 @@ jobs:
with:
name: junit-ruby-26-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-ruby-26-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-ruby-25:
runs-on: ubuntu-24.04
name: batch (ruby-2.5)
Expand Down Expand Up @@ -1100,6 +1149,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/ruby-25/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -1111,6 +1162,11 @@ jobs:
with:
name: junit-ruby-25-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-ruby-25-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-jruby-94:
runs-on: ubuntu-24.04
name: batch (jruby-9.4)
Expand Down Expand Up @@ -1237,6 +1293,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/jruby-94/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -1248,6 +1306,11 @@ jobs:
with:
name: junit-jruby-94-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-jruby-94-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-jruby-93:
runs-on: ubuntu-24.04
name: batch (jruby-9.3)
Expand Down Expand Up @@ -1374,6 +1437,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/jruby-93/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -1385,6 +1450,11 @@ jobs:
with:
name: junit-jruby-93-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-jruby-93-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
batch-jruby-92:
runs-on: ubuntu-24.04
name: batch (jruby-9.2)
Expand Down Expand Up @@ -1511,6 +1581,8 @@ jobs:
- run: bundle exec rake github:run_batch_build
- run: ln -s .rspec-local.example .rspec-local
- run: bundle exec rake github:run_batch_tests
env:
COVERAGE_DIR: coverage/versions/jruby-92/${{ matrix.batch }}
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
with:
Expand All @@ -1522,6 +1594,11 @@ jobs:
with:
name: junit-jruby-92-${{ matrix.batch }}-${{ github.run_id }}
path: tmp/rspec/*.xml
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
with:
name: coverage-jruby-92-${{ matrix.batch }}-${{ github.run_id }}
path: coverage
include-hidden-files: true
complete:
name: complete
runs-on: ubuntu-24.04
Expand Down Expand Up @@ -1574,3 +1651,42 @@ jobs:
merge-multiple: true
- run: sed -i 's;file="./;file=";g' tmp/rspec/*.xml
- run: datadog-ci junit upload --verbose --dry-run tmp/rspec/
coverage:
name: upload/coverage
runs-on: ubuntu-24.04
needs:
- build-test-ruby-34
- build-test-ruby-33
- build-test-ruby-32
- build-test-ruby-31
- build-test-ruby-30
- build-test-ruby-27
- build-test-ruby-26
- build-test-ruby-25
- build-test-jruby-94
- build-test-jruby-93
- build-test-jruby-92
- batch-ruby-34
container:
image: ghcr.io/datadog/images-rb/engines/ruby:3.4
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
name: lockfile-ruby-34-${{ github.run_id }}
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
id: restore-cache
with:
key: "${{ needs.batch-ruby-34.outputs.cache-key }}"
path: "/usr/local/bundle"
- run: bundle check || bundle install
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
with:
path: coverage
pattern: coverage-*
merge-multiple: true
- run: bundle exec rake coverage:report
- uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3
with:
verbose: true
files: coverage/report/coverage.xml
60 changes: 59 additions & 1 deletion tasks/github.rake
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ namespace :github do
'bundle_artifact' => "bundle-#{runtime_alias}-${{ github.run_id }}",
'dependencies_artifact' => "bundled-dependencies-#{runtime_alias}-${{ matrix.batch }}-${{ github.run_id }}",
'junit_artifact' => "junit-#{runtime_alias}-${{ matrix.batch }}-${{ github.run_id }}",
'coverage_artifact' => "coverage-#{runtime_alias}-${{ matrix.batch }}-${{ github.run_id }}",
'bundle_cache_key' => "bundle-${{ runner.os }}-${{ runner.arch }}-#{runtime_alias}-${{ hashFiles('*.lock') }}"
)
end
Expand Down Expand Up @@ -217,7 +218,12 @@ namespace :github do
{ 'run' => 'bundle check || bundle install' },
{ 'run' => 'bundle exec rake github:run_batch_build' },
{ 'run' => 'ln -s .rspec-local.example .rspec-local' },
{ 'run' => 'bundle exec rake github:run_batch_tests' },
{
'run' => 'bundle exec rake github:run_batch_tests',
'env' => {
'COVERAGE_DIR' => "coverage/versions/#{runtime.alias}/${{ matrix.batch }}"
}
},
{
'if' => "${{ failure() && env.RUNNER_DEBUG == '1' }}",
'uses' => 'mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48',
Expand All @@ -237,6 +243,14 @@ namespace :github do
'path' => 'tmp/rspec/*.xml'
}
},
{
'uses' => 'actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08',
'with' => {
'name' => runtime.coverage_artifact,
'path' => 'coverage',
'include-hidden-files' => true
}
},
]
}
end
Expand Down Expand Up @@ -317,6 +331,50 @@ namespace :github do
{ 'run' => "sed -i 's;file=\"\.\/;file=\";g' tmp/rspec/*.xml" },
{ 'run' => 'datadog-ci junit upload --verbose --dry-run tmp/rspec/' },
]
},
'coverage' => {
'name' => 'upload/coverage',
'runs-on' => ubuntu,
'needs' => runtimes.map(&:build_test_id) + [runtimes.first.batch_id],
'container' => {
'image' => runtimes.first.image,
},
'steps' => [
{
'uses' => 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683'
},
{
'uses' => 'actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16',
'with' => {
'name' => runtimes.first.lockfile_artifact,
}
},
{
'uses' => 'actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57',
'id' => 'restore-cache',
'with' => {
'key' => "${{ needs.#{runtimes.first.batch_id}.outputs.cache-key }}",
'path' => '/usr/local/bundle'
}
},
{ 'run' => 'bundle check || bundle install' },
{
'uses' => 'actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16',
'with' => {
'path' => 'coverage',
'pattern' => 'coverage-*',
'merge-multiple' => true
}
},
{ 'run' => 'bundle exec rake coverage:report' },
{
'uses' => 'codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3',
'with' => {
'verbose' => true,
'files' => 'coverage/report/coverage.xml'
}
}
]
}
)
}
Expand Down

0 comments on commit 5858773

Please sign in to comment.