Skip to content

Commit d8242a9

Browse files
committed
WIP
1 parent 3d817fa commit d8242a9

File tree

3 files changed

+145
-3
lines changed

3 files changed

+145
-3
lines changed

.github/workflows/test.yml

+96
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ name: Unit Tests
66
push:
77
branches:
88
- master
9+
- tonycthsu/*
910
pull_request:
1011
branches:
1112
- master
@@ -141,6 +142,8 @@ jobs:
141142
- run: bundle exec rake github:run_batch_build
142143
- run: ln -s .rspec-local.example .rspec-local
143144
- run: bundle exec rake github:run_batch_tests
145+
env:
146+
COVERAGE_DIR: coverage/versions/ruby-34/${{ matrix.batch }}
144147
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
145148
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
146149
with:
@@ -152,6 +155,10 @@ jobs:
152155
with:
153156
name: junit-ruby-34-${{ matrix.batch }}-${{ github.run_id }}
154157
path: tmp/rspec/*.xml
158+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
159+
with:
160+
name: coverage-ruby-34-${{ matrix.batch }}-${{ github.run_id }}
161+
path: coverage
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,10 @@ 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
292305
batch-ruby-32:
293306
runs-on: ubuntu-24.04
294307
name: batch (ruby-3.2)
@@ -415,6 +428,8 @@ jobs:
415428
- run: bundle exec rake github:run_batch_build
416429
- run: ln -s .rspec-local.example .rspec-local
417430
- run: bundle exec rake github:run_batch_tests
431+
env:
432+
COVERAGE_DIR: coverage/versions/ruby-32/${{ matrix.batch }}
418433
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
419434
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
420435
with:
@@ -426,6 +441,10 @@ jobs:
426441
with:
427442
name: junit-ruby-32-${{ matrix.batch }}-${{ github.run_id }}
428443
path: tmp/rspec/*.xml
444+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
445+
with:
446+
name: coverage-ruby-32-${{ matrix.batch }}-${{ github.run_id }}
447+
path: coverage
429448
batch-ruby-31:
430449
runs-on: ubuntu-24.04
431450
name: batch (ruby-3.1)
@@ -552,6 +571,8 @@ jobs:
552571
- run: bundle exec rake github:run_batch_build
553572
- run: ln -s .rspec-local.example .rspec-local
554573
- run: bundle exec rake github:run_batch_tests
574+
env:
575+
COVERAGE_DIR: coverage/versions/ruby-31/${{ matrix.batch }}
555576
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
556577
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
557578
with:
@@ -563,6 +584,10 @@ jobs:
563584
with:
564585
name: junit-ruby-31-${{ matrix.batch }}-${{ github.run_id }}
565586
path: tmp/rspec/*.xml
587+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
588+
with:
589+
name: coverage-ruby-31-${{ matrix.batch }}-${{ github.run_id }}
590+
path: coverage
566591
batch-ruby-30:
567592
runs-on: ubuntu-24.04
568593
name: batch (ruby-3.0)
@@ -689,6 +714,8 @@ jobs:
689714
- run: bundle exec rake github:run_batch_build
690715
- run: ln -s .rspec-local.example .rspec-local
691716
- run: bundle exec rake github:run_batch_tests
717+
env:
718+
COVERAGE_DIR: coverage/versions/ruby-30/${{ matrix.batch }}
692719
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
693720
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
694721
with:
@@ -700,6 +727,10 @@ jobs:
700727
with:
701728
name: junit-ruby-30-${{ matrix.batch }}-${{ github.run_id }}
702729
path: tmp/rspec/*.xml
730+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
731+
with:
732+
name: coverage-ruby-30-${{ matrix.batch }}-${{ github.run_id }}
733+
path: coverage
703734
batch-ruby-27:
704735
runs-on: ubuntu-24.04
705736
name: batch (ruby-2.7)
@@ -826,6 +857,8 @@ jobs:
826857
- run: bundle exec rake github:run_batch_build
827858
- run: ln -s .rspec-local.example .rspec-local
828859
- run: bundle exec rake github:run_batch_tests
860+
env:
861+
COVERAGE_DIR: coverage/versions/ruby-27/${{ matrix.batch }}
829862
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
830863
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
831864
with:
@@ -837,6 +870,10 @@ jobs:
837870
with:
838871
name: junit-ruby-27-${{ matrix.batch }}-${{ github.run_id }}
839872
path: tmp/rspec/*.xml
873+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
874+
with:
875+
name: coverage-ruby-27-${{ matrix.batch }}-${{ github.run_id }}
876+
path: coverage
840877
batch-ruby-26:
841878
runs-on: ubuntu-24.04
842879
name: batch (ruby-2.6)
@@ -963,6 +1000,8 @@ jobs:
9631000
- run: bundle exec rake github:run_batch_build
9641001
- run: ln -s .rspec-local.example .rspec-local
9651002
- run: bundle exec rake github:run_batch_tests
1003+
env:
1004+
COVERAGE_DIR: coverage/versions/ruby-26/${{ matrix.batch }}
9661005
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
9671006
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
9681007
with:
@@ -974,6 +1013,10 @@ jobs:
9741013
with:
9751014
name: junit-ruby-26-${{ matrix.batch }}-${{ github.run_id }}
9761015
path: tmp/rspec/*.xml
1016+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1017+
with:
1018+
name: coverage-ruby-26-${{ matrix.batch }}-${{ github.run_id }}
1019+
path: coverage
9771020
batch-ruby-25:
9781021
runs-on: ubuntu-24.04
9791022
name: batch (ruby-2.5)
@@ -1100,6 +1143,8 @@ jobs:
11001143
- run: bundle exec rake github:run_batch_build
11011144
- run: ln -s .rspec-local.example .rspec-local
11021145
- run: bundle exec rake github:run_batch_tests
1146+
env:
1147+
COVERAGE_DIR: coverage/versions/ruby-25/${{ matrix.batch }}
11031148
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
11041149
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
11051150
with:
@@ -1111,6 +1156,10 @@ jobs:
11111156
with:
11121157
name: junit-ruby-25-${{ matrix.batch }}-${{ github.run_id }}
11131158
path: tmp/rspec/*.xml
1159+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1160+
with:
1161+
name: coverage-ruby-25-${{ matrix.batch }}-${{ github.run_id }}
1162+
path: coverage
11141163
batch-jruby-94:
11151164
runs-on: ubuntu-24.04
11161165
name: batch (jruby-9.4)
@@ -1237,6 +1286,8 @@ jobs:
12371286
- run: bundle exec rake github:run_batch_build
12381287
- run: ln -s .rspec-local.example .rspec-local
12391288
- run: bundle exec rake github:run_batch_tests
1289+
env:
1290+
COVERAGE_DIR: coverage/versions/jruby-94/${{ matrix.batch }}
12401291
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
12411292
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
12421293
with:
@@ -1248,6 +1299,10 @@ jobs:
12481299
with:
12491300
name: junit-jruby-94-${{ matrix.batch }}-${{ github.run_id }}
12501301
path: tmp/rspec/*.xml
1302+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1303+
with:
1304+
name: coverage-jruby-94-${{ matrix.batch }}-${{ github.run_id }}
1305+
path: coverage
12511306
batch-jruby-93:
12521307
runs-on: ubuntu-24.04
12531308
name: batch (jruby-9.3)
@@ -1374,6 +1429,8 @@ jobs:
13741429
- run: bundle exec rake github:run_batch_build
13751430
- run: ln -s .rspec-local.example .rspec-local
13761431
- run: bundle exec rake github:run_batch_tests
1432+
env:
1433+
COVERAGE_DIR: coverage/versions/jruby-93/${{ matrix.batch }}
13771434
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
13781435
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
13791436
with:
@@ -1385,6 +1442,10 @@ jobs:
13851442
with:
13861443
name: junit-jruby-93-${{ matrix.batch }}-${{ github.run_id }}
13871444
path: tmp/rspec/*.xml
1445+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1446+
with:
1447+
name: coverage-jruby-93-${{ matrix.batch }}-${{ github.run_id }}
1448+
path: coverage
13881449
batch-jruby-92:
13891450
runs-on: ubuntu-24.04
13901451
name: batch (jruby-9.2)
@@ -1511,6 +1572,8 @@ jobs:
15111572
- run: bundle exec rake github:run_batch_build
15121573
- run: ln -s .rspec-local.example .rspec-local
15131574
- run: bundle exec rake github:run_batch_tests
1575+
env:
1576+
COVERAGE_DIR: coverage/versions/jruby-92/${{ matrix.batch }}
15141577
- if: "${{ failure() && env.RUNNER_DEBUG == '1' }}"
15151578
uses: mxschmitt/action-tmate@e5c7151931ca95bad1c6f4190c730ecf8c7dde48
15161579
with:
@@ -1522,6 +1585,10 @@ jobs:
15221585
with:
15231586
name: junit-jruby-92-${{ matrix.batch }}-${{ github.run_id }}
15241587
path: tmp/rspec/*.xml
1588+
- uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08
1589+
with:
1590+
name: coverage-jruby-92-${{ matrix.batch }}-${{ github.run_id }}
1591+
path: coverage
15251592
complete:
15261593
name: complete
15271594
runs-on: ubuntu-24.04
@@ -1574,3 +1641,32 @@ jobs:
15741641
merge-multiple: true
15751642
- run: sed -i 's;file="./;file=";g' tmp/rspec/*.xml
15761643
- run: datadog-ci junit upload --verbose --dry-run tmp/rspec/
1644+
coverage:
1645+
name: coverage
1646+
runs-on: ubuntu-24.04
1647+
needs:
1648+
- build-test-ruby-34
1649+
- build-test-ruby-33
1650+
- build-test-ruby-32
1651+
- build-test-ruby-31
1652+
- build-test-ruby-30
1653+
- build-test-ruby-27
1654+
- build-test-ruby-26
1655+
- build-test-ruby-25
1656+
- build-test-jruby-94
1657+
- build-test-jruby-93
1658+
- build-test-jruby-92
1659+
container:
1660+
image: ghcr.io/datadog/images-rb/engines/ruby:3.4
1661+
steps:
1662+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
1663+
- uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16
1664+
with:
1665+
name: lockfile-ruby-34-${{ github.run_id }}
1666+
- uses: actions/cache/restore@1bd1e32a3bdc45362d1e726936510720a7c30a57
1667+
id: restore-cache
1668+
with:
1669+
key: "${{ needs.batch-ruby-34.outputs.cache-key }}"
1670+
path: "/usr/local/bundle"
1671+
- run: bundle check || bundle install
1672+
- run: COVERAGE_DIR=$GITHUB_WORKSPACE/coverage bundle exec rake coverage:report

Rakefile

+2
Original file line numberDiff line numberDiff line change
@@ -395,12 +395,14 @@ namespace :coverage do
395395
SimpleCov.collate resultset_files do
396396
coverage_dir "#{ENV.fetch('COVERAGE_DIR', 'coverage')}/report"
397397
if ENV['CI'] == 'true'
398+
puts "Formatting with cobertura"
398399
require 'simplecov-cobertura'
399400
formatter SimpleCov::Formatter::MultiFormatter.new(
400401
[SimpleCov::Formatter::HTMLFormatter,
401402
SimpleCov::Formatter::CoberturaFormatter] # Used by codecov
402403
)
403404
else
405+
puts "Formatting with html"
404406
formatter SimpleCov::Formatter::HTMLFormatter
405407
end
406408
end

tasks/github.rake

+47-3
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,13 @@ 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+
}
252+
},
240253
]
241254
}
242255
end
@@ -247,6 +260,7 @@ namespace :github do
247260
'push' => {
248261
'branches' => [
249262
'master',
263+
'tonycthsu/*',
250264
]
251265
},
252266
'pull_request' => {
@@ -317,6 +331,35 @@ 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' => 'coverage',
337+
'runs-on' => ubuntu,
338+
'needs' => runtimes.map(&:build_test_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+
{ 'run' => 'COVERAGE_DIR=$GITHUB_WORKSPACE/coverage bundle exec rake coverage:report' },
362+
]
320363
}
321364
)
322365
}
@@ -341,10 +384,11 @@ namespace :github do
341384

342385
exceptions = [
343386
# 'sidekiq', # Connection refused - connect(2) for 127.0.0.1:6379 (RedisClient::CannotConnectError)
387+
'stripe'
344388
]
345389

346-
# candidates = exceptions
347-
candidates = matrix.keys - exceptions
390+
candidates = exceptions
391+
# candidates = matrix.keys - exceptions
348392

349393
raise 'No candidates.' if candidates.empty?
350394

0 commit comments

Comments
 (0)