Skip to content

Commit 5858773

Browse files
authored
Merge pull request #4373 from DataDog/tonycthsu/coverage
Upload coverage to codecov
2 parents 20886bc + c47ee3e commit 5858773

File tree

3 files changed

+178
-3
lines changed

3 files changed

+178
-3
lines changed

.circleci/config.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,9 @@ orbs:
307307
- run:
308308
name: Generate combined coverage report for all tests
309309
command: COVERAGE_DIR=/tmp/workspace/coverage bundle exec rake coverage:report
310-
- codecov/upload:
311-
file: /tmp/workspace/coverage/report/coverage.xml
310+
# Migrate to Github Actions
311+
# - codecov/upload:
312+
# file: /tmp/workspace/coverage/report/coverage.xml
312313
- run:
313314
name: Generate individual coverage report for each Ruby version
314315
command: COVERAGE_DIR=/tmp/workspace/coverage bundle exec rake coverage:report_per_ruby_version

.github/workflows/test.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,8 @@ jobs:
141141
- run: bundle exec rake github:run_batch_build
142142
- run: ln -s .rspec-local.example .rspec-local
143143
- run: bundle exec rake github:run_batch_tests
144+
env:
145+
COVERAGE_DIR: coverage/versions/ruby-34/${{ matrix.batch }}
144146
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
145147
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
146148
with:
@@ -152,6 +154,11 @@ jobs:
152154
with:
153155
name: junit-ruby-34-${{ matrix.batch }}-${{ github.run_id }}
154156
path: tmp/rspec/*.xml
157+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
158+
with:
159+
name: coverage-ruby-34-${{ matrix.batch }}-${{ github.run_id }}
160+
path: coverage
161+
include-hidden-files: true
155162
batch-ruby-33:
156163
runs-on: ubuntu-24.04
157164
name: batch (ruby-3.3)
@@ -278,6 +285,8 @@ jobs:
278285
- run: bundle exec rake github:run_batch_build
279286
- run: ln -s .rspec-local.example .rspec-local
280287
- run: bundle exec rake github:run_batch_tests
288+
env:
289+
COVERAGE_DIR: coverage/versions/ruby-33/${{ matrix.batch }}
281290
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
282291
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
283292
with:
@@ -289,6 +298,11 @@ jobs:
289298
with:
290299
name: junit-ruby-33-${{ matrix.batch }}-${{ github.run_id }}
291300
path: tmp/rspec/*.xml
301+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
302+
with:
303+
name: coverage-ruby-33-${{ matrix.batch }}-${{ github.run_id }}
304+
path: coverage
305+
include-hidden-files: true
292306
batch-ruby-32:
293307
runs-on: ubuntu-24.04
294308
name: batch (ruby-3.2)
@@ -415,6 +429,8 @@ jobs:
415429
- run: bundle exec rake github:run_batch_build
416430
- run: ln -s .rspec-local.example .rspec-local
417431
- run: bundle exec rake github:run_batch_tests
432+
env:
433+
COVERAGE_DIR: coverage/versions/ruby-32/${{ matrix.batch }}
418434
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
419435
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
420436
with:
@@ -426,6 +442,11 @@ jobs:
426442
with:
427443
name: junit-ruby-32-${{ matrix.batch }}-${{ github.run_id }}
428444
path: tmp/rspec/*.xml
445+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
446+
with:
447+
name: coverage-ruby-32-${{ matrix.batch }}-${{ github.run_id }}
448+
path: coverage
449+
include-hidden-files: true
429450
batch-ruby-31:
430451
runs-on: ubuntu-24.04
431452
name: batch (ruby-3.1)
@@ -552,6 +573,8 @@ jobs:
552573
- run: bundle exec rake github:run_batch_build
553574
- run: ln -s .rspec-local.example .rspec-local
554575
- run: bundle exec rake github:run_batch_tests
576+
env:
577+
COVERAGE_DIR: coverage/versions/ruby-31/${{ matrix.batch }}
555578
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
556579
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
557580
with:
@@ -563,6 +586,11 @@ jobs:
563586
with:
564587
name: junit-ruby-31-${{ matrix.batch }}-${{ github.run_id }}
565588
path: tmp/rspec/*.xml
589+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
590+
with:
591+
name: coverage-ruby-31-${{ matrix.batch }}-${{ github.run_id }}
592+
path: coverage
593+
include-hidden-files: true
566594
batch-ruby-30:
567595
runs-on: ubuntu-24.04
568596
name: batch (ruby-3.0)
@@ -689,6 +717,8 @@ jobs:
689717
- run: bundle exec rake github:run_batch_build
690718
- run: ln -s .rspec-local.example .rspec-local
691719
- run: bundle exec rake github:run_batch_tests
720+
env:
721+
COVERAGE_DIR: coverage/versions/ruby-30/${{ matrix.batch }}
692722
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
693723
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
694724
with:
@@ -700,6 +730,11 @@ jobs:
700730
with:
701731
name: junit-ruby-30-${{ matrix.batch }}-${{ github.run_id }}
702732
path: tmp/rspec/*.xml
733+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
734+
with:
735+
name: coverage-ruby-30-${{ matrix.batch }}-${{ github.run_id }}
736+
path: coverage
737+
include-hidden-files: true
703738
batch-ruby-27:
704739
runs-on: ubuntu-24.04
705740
name: batch (ruby-2.7)
@@ -826,6 +861,8 @@ jobs:
826861
- run: bundle exec rake github:run_batch_build
827862
- run: ln -s .rspec-local.example .rspec-local
828863
- run: bundle exec rake github:run_batch_tests
864+
env:
865+
COVERAGE_DIR: coverage/versions/ruby-27/${{ matrix.batch }}
829866
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
830867
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
831868
with:
@@ -837,6 +874,11 @@ jobs:
837874
with:
838875
name: junit-ruby-27-${{ matrix.batch }}-${{ github.run_id }}
839876
path: tmp/rspec/*.xml
877+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
878+
with:
879+
name: coverage-ruby-27-${{ matrix.batch }}-${{ github.run_id }}
880+
path: coverage
881+
include-hidden-files: true
840882
batch-ruby-26:
841883
runs-on: ubuntu-24.04
842884
name: batch (ruby-2.6)
@@ -963,6 +1005,8 @@ jobs:
9631005
- run: bundle exec rake github:run_batch_build
9641006
- run: ln -s .rspec-local.example .rspec-local
9651007
- run: bundle exec rake github:run_batch_tests
1008+
env:
1009+
COVERAGE_DIR: coverage/versions/ruby-26/${{ matrix.batch }}
9661010
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
9671011
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
9681012
with:
@@ -974,6 +1018,11 @@ jobs:
9741018
with:
9751019
name: junit-ruby-26-${{ matrix.batch }}-${{ github.run_id }}
9761020
path: tmp/rspec/*.xml
1021+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1022+
with:
1023+
name: coverage-ruby-26-${{ matrix.batch }}-${{ github.run_id }}
1024+
path: coverage
1025+
include-hidden-files: true
9771026
batch-ruby-25:
9781027
runs-on: ubuntu-24.04
9791028
name: batch (ruby-2.5)
@@ -1100,6 +1149,8 @@ jobs:
11001149
- run: bundle exec rake github:run_batch_build
11011150
- run: ln -s .rspec-local.example .rspec-local
11021151
- run: bundle exec rake github:run_batch_tests
1152+
env:
1153+
COVERAGE_DIR: coverage/versions/ruby-25/${{ matrix.batch }}
11031154
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
11041155
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
11051156
with:
@@ -1111,6 +1162,11 @@ jobs:
11111162
with:
11121163
name: junit-ruby-25-${{ matrix.batch }}-${{ github.run_id }}
11131164
path: tmp/rspec/*.xml
1165+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1166+
with:
1167+
name: coverage-ruby-25-${{ matrix.batch }}-${{ github.run_id }}
1168+
path: coverage
1169+
include-hidden-files: true
11141170
batch-jruby-94:
11151171
runs-on: ubuntu-24.04
11161172
name: batch (jruby-9.4)
@@ -1237,6 +1293,8 @@ jobs:
12371293
- run: bundle exec rake github:run_batch_build
12381294
- run: ln -s .rspec-local.example .rspec-local
12391295
- run: bundle exec rake github:run_batch_tests
1296+
env:
1297+
COVERAGE_DIR: coverage/versions/jruby-94/${{ matrix.batch }}
12401298
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
12411299
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
12421300
with:
@@ -1248,6 +1306,11 @@ jobs:
12481306
with:
12491307
name: junit-jruby-94-${{ matrix.batch }}-${{ github.run_id }}
12501308
path: tmp/rspec/*.xml
1309+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1310+
with:
1311+
name: coverage-jruby-94-${{ matrix.batch }}-${{ github.run_id }}
1312+
path: coverage
1313+
include-hidden-files: true
12511314
batch-jruby-93:
12521315
runs-on: ubuntu-24.04
12531316
name: batch (jruby-9.3)
@@ -1374,6 +1437,8 @@ jobs:
13741437
- run: bundle exec rake github:run_batch_build
13751438
- run: ln -s .rspec-local.example .rspec-local
13761439
- run: bundle exec rake github:run_batch_tests
1440+
env:
1441+
COVERAGE_DIR: coverage/versions/jruby-93/${{ matrix.batch }}
13771442
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
13781443
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
13791444
with:
@@ -1385,6 +1450,11 @@ jobs:
13851450
with:
13861451
name: junit-jruby-93-${{ matrix.batch }}-${{ github.run_id }}
13871452
path: tmp/rspec/*.xml
1453+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1454+
with:
1455+
name: coverage-jruby-93-${{ matrix.batch }}-${{ github.run_id }}
1456+
path: coverage
1457+
include-hidden-files: true
13881458
batch-jruby-92:
13891459
runs-on: ubuntu-24.04
13901460
name: batch (jruby-9.2)
@@ -1511,6 +1581,8 @@ jobs:
15111581
- run: bundle exec rake github:run_batch_build
15121582
- run: ln -s .rspec-local.example .rspec-local
15131583
- run: bundle exec rake github:run_batch_tests
1584+
env:
1585+
COVERAGE_DIR: coverage/versions/jruby-92/${{ matrix.batch }}
15141586
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
15151587
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
15161588
with:
@@ -1522,6 +1594,11 @@ jobs:
15221594
with:
15231595
name: junit-jruby-92-${{ matrix.batch }}-${{ github.run_id }}
15241596
path: tmp/rspec/*.xml
1597+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1598+
with:
1599+
name: coverage-jruby-92-${{ matrix.batch }}-${{ github.run_id }}
1600+
path: coverage
1601+
include-hidden-files: true
15251602
complete:
15261603
name: complete
15271604
runs-on: ubuntu-24.04
@@ -1574,3 +1651,42 @@ jobs:
15741651
merge-multiple: true
15751652
- run: sed -i 's;file="./;file=";g' tmp/rspec/*.xml
15761653
- run: datadog-ci junit upload --verbose --dry-run tmp/rspec/
1654+
coverage:
1655+
name: upload/coverage
1656+
runs-on: ubuntu-24.04
1657+
needs:
1658+
- build-test-ruby-34
1659+
- build-test-ruby-33
1660+
- build-test-ruby-32
1661+
- build-test-ruby-31
1662+
- build-test-ruby-30
1663+
- build-test-ruby-27
1664+
- build-test-ruby-26
1665+
- build-test-ruby-25
1666+
- build-test-jruby-94
1667+
- build-test-jruby-93
1668+
- build-test-jruby-92
1669+
- batch-ruby-34
1670+
container:
1671+
image: ghcr.io/datadog/images-rb/engines/ruby:3.4
1672+
steps:
1673+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
1674+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
1675+
with:
1676+
name: lockfile-ruby-34-${{ github.run_id }}
1677+
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
1678+
id: restore-cache
1679+
with:
1680+
key: "${{ needs.batch-ruby-34.outputs.cache-key }}"
1681+
path: "/usr/local/bundle"
1682+
- run: bundle check || bundle install
1683+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
1684+
with:
1685+
path: coverage
1686+
pattern: coverage-*
1687+
merge-multiple: true
1688+
- run: bundle exec rake coverage:report
1689+
- uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3
1690+
with:
1691+
verbose: true
1692+
files: coverage/report/coverage.xml

tasks/github.rake

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ namespace :github do
9191
'bundle_artifact' => "bundle-#{runtime_alias}-${{ github.run_id }}",
9292
'dependencies_artifact' => "bundled-dependencies-#{runtime_alias}-${{ matrix.batch }}-${{ github.run_id }}",
9393
'junit_artifact' => "junit-#{runtime_alias}-${{ matrix.batch }}-${{ github.run_id }}",
94+
'coverage_artifact' => "coverage-#{runtime_alias}-${{ matrix.batch }}-${{ github.run_id }}",
9495
'bundle_cache_key' => "bundle-${{ runner.os }}-${{ runner.arch }}-#{runtime_alias}-${{ hashFiles('*.lock') }}"
9596
)
9697
end
@@ -217,7 +218,12 @@ namespace :github do
217218
{ 'run' => 'bundle check || bundle install' },
218219
{ 'run' => 'bundle exec rake github:run_batch_build' },
219220
{ 'run' => 'ln -s .rspec-local.example .rspec-local' },
220-
{ 'run' => 'bundle exec rake github:run_batch_tests' },
221+
{
222+
'run' => 'bundle exec rake github:run_batch_tests',
223+
'env' => {
224+
'COVERAGE_DIR' => "coverage/versions/#{runtime.alias}/${{ matrix.batch }}"
225+
}
226+
},
221227
{
222228
'if' => "${{ failure() && env.RUNNER_DEBUG == '1' }}",
223229
'uses' => 'mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48',
@@ -237,6 +243,14 @@ namespace :github do
237243
'path' => 'tmp/rspec/*.xml'
238244
}
239245
},
246+
{
247+
'uses' => 'actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08',
248+
'with' => {
249+
'name' => runtime.coverage_artifact,
250+
'path' => 'coverage',
251+
'include-hidden-files' => true
252+
}
253+
},
240254
]
241255
}
242256
end
@@ -317,6 +331,50 @@ namespace :github do
317331
{ 'run' => "sed -i 's;file=\"\.\/;file=\";g' tmp/rspec/*.xml" },
318332
{ 'run' => 'datadog-ci junit upload --verbose --dry-run tmp/rspec/' },
319333
]
334+
},
335+
'coverage' => {
336+
'name' => 'upload/coverage',
337+
'runs-on' => ubuntu,
338+
'needs' => runtimes.map(&:build_test_id) + [runtimes.first.batch_id],
339+
'container' => {
340+
'image' => runtimes.first.image,
341+
},
342+
'steps' => [
343+
{
344+
'uses' => 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683'
345+
},
346+
{
347+
'uses' => 'actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16',
348+
'with' => {
349+
'name' => runtimes.first.lockfile_artifact,
350+
}
351+
},
352+
{
353+
'uses' => 'actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57',
354+
'id' => 'restore-cache',
355+
'with' => {
356+
'key' => "${{ needs.#{runtimes.first.batch_id}.outputs.cache-key }}",
357+
'path' => '/usr/local/bundle'
358+
}
359+
},
360+
{ 'run' => 'bundle check || bundle install' },
361+
{
362+
'uses' => 'actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16',
363+
'with' => {
364+
'path' => 'coverage',
365+
'pattern' => 'coverage-*',
366+
'merge-multiple' => true
367+
}
368+
},
369+
{ 'run' => 'bundle exec rake coverage:report' },
370+
{
371+
'uses' => 'codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3',
372+
'with' => {
373+
'verbose' => true,
374+
'files' => 'coverage/report/coverage.xml'
375+
}
376+
}
377+
]
320378
}
321379
)
322380
}

0 commit comments

Comments
 (0)