Skip to content

Commit 04efab7

Browse files
authored
Merge pull request #4338 from DataDog/poc/batch-summary
Generate batch summary
2 parents 0daa829 + af0d56b commit 04efab7

File tree

2 files changed

+73
-4
lines changed

2 files changed

+73
-4
lines changed

.github/workflows/test.yml

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ name: Unit Tests
66
push:
77
branches:
88
- master
9-
- poc/**
9+
pull_request:
10+
branches:
11+
- master
1012
schedule:
1113
- cron: 0 7 * * *
1214
concurrency:
@@ -44,6 +46,9 @@ jobs:
4446
batches_json=$(bundle exec rake github:generate_batches)
4547
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
4648
echo "batches=$batches_json" >> $GITHUB_OUTPUT
49+
- env:
50+
batches_json: "${{ steps.set-batches.outputs.batches }}"
51+
run: bundle exec rake github:generate_batch_summary
4752
build-test-ruby-34:
4853
needs:
4954
- batch-ruby-34
@@ -169,6 +174,9 @@ jobs:
169174
batches_json=$(bundle exec rake github:generate_batches)
170175
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
171176
echo "batches=$batches_json" >> $GITHUB_OUTPUT
177+
- env:
178+
batches_json: "${{ steps.set-batches.outputs.batches }}"
179+
run: bundle exec rake github:generate_batch_summary
172180
build-test-ruby-33:
173181
needs:
174182
- batch-ruby-33
@@ -294,6 +302,9 @@ jobs:
294302
batches_json=$(bundle exec rake github:generate_batches)
295303
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
296304
echo "batches=$batches_json" >> $GITHUB_OUTPUT
305+
- env:
306+
batches_json: "${{ steps.set-batches.outputs.batches }}"
307+
run: bundle exec rake github:generate_batch_summary
297308
build-test-ruby-32:
298309
needs:
299310
- batch-ruby-32
@@ -419,6 +430,9 @@ jobs:
419430
batches_json=$(bundle exec rake github:generate_batches)
420431
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
421432
echo "batches=$batches_json" >> $GITHUB_OUTPUT
433+
- env:
434+
batches_json: "${{ steps.set-batches.outputs.batches }}"
435+
run: bundle exec rake github:generate_batch_summary
422436
build-test-ruby-31:
423437
needs:
424438
- batch-ruby-31
@@ -544,6 +558,9 @@ jobs:
544558
batches_json=$(bundle exec rake github:generate_batches)
545559
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
546560
echo "batches=$batches_json" >> $GITHUB_OUTPUT
561+
- env:
562+
batches_json: "${{ steps.set-batches.outputs.batches }}"
563+
run: bundle exec rake github:generate_batch_summary
547564
build-test-ruby-30:
548565
needs:
549566
- batch-ruby-30
@@ -669,6 +686,9 @@ jobs:
669686
batches_json=$(bundle exec rake github:generate_batches)
670687
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
671688
echo "batches=$batches_json" >> $GITHUB_OUTPUT
689+
- env:
690+
batches_json: "${{ steps.set-batches.outputs.batches }}"
691+
run: bundle exec rake github:generate_batch_summary
672692
build-test-ruby-27:
673693
needs:
674694
- batch-ruby-27
@@ -794,6 +814,9 @@ jobs:
794814
batches_json=$(bundle exec rake github:generate_batches)
795815
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
796816
echo "batches=$batches_json" >> $GITHUB_OUTPUT
817+
- env:
818+
batches_json: "${{ steps.set-batches.outputs.batches }}"
819+
run: bundle exec rake github:generate_batch_summary
797820
build-test-ruby-26:
798821
needs:
799822
- batch-ruby-26
@@ -919,6 +942,9 @@ jobs:
919942
batches_json=$(bundle exec rake github:generate_batches)
920943
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
921944
echo "batches=$batches_json" >> $GITHUB_OUTPUT
945+
- env:
946+
batches_json: "${{ steps.set-batches.outputs.batches }}"
947+
run: bundle exec rake github:generate_batch_summary
922948
build-test-ruby-25:
923949
needs:
924950
- batch-ruby-25
@@ -1044,6 +1070,9 @@ jobs:
10441070
batches_json=$(bundle exec rake github:generate_batches)
10451071
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
10461072
echo "batches=$batches_json" >> $GITHUB_OUTPUT
1073+
- env:
1074+
batches_json: "${{ steps.set-batches.outputs.batches }}"
1075+
run: bundle exec rake github:generate_batch_summary
10471076
build-test-jruby-94:
10481077
needs:
10491078
- batch-jruby-94
@@ -1169,6 +1198,9 @@ jobs:
11691198
batches_json=$(bundle exec rake github:generate_batches)
11701199
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
11711200
echo "batches=$batches_json" >> $GITHUB_OUTPUT
1201+
- env:
1202+
batches_json: "${{ steps.set-batches.outputs.batches }}"
1203+
run: bundle exec rake github:generate_batch_summary
11721204
build-test-jruby-93:
11731205
needs:
11741206
- batch-jruby-93
@@ -1294,6 +1326,9 @@ jobs:
12941326
batches_json=$(bundle exec rake github:generate_batches)
12951327
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
12961328
echo "batches=$batches_json" >> $GITHUB_OUTPUT
1329+
- env:
1330+
batches_json: "${{ steps.set-batches.outputs.batches }}"
1331+
run: bundle exec rake github:generate_batch_summary
12971332
build-test-jruby-92:
12981333
needs:
12991334
- batch-jruby-92
@@ -1388,7 +1423,7 @@ jobs:
13881423
uses: mxschmitt/action-tmate@v3
13891424
with:
13901425
limit-access-to-actor: true
1391-
aggregate:
1426+
unit-tests:
13921427
runs-on: ubuntu-24.04
13931428
needs:
13941429
- build-test-ruby-34

tasks/github.rake

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,12 @@ namespace :github do
139139
echo "batches=$batches_json" >> $GITHUB_OUTPUT
140140
BASH
141141
},
142+
{
143+
'env' => {
144+
'batches_json' => '${{ steps.set-batches.outputs.batches }}',
145+
},
146+
'run' => 'bundle exec rake github:generate_batch_summary'
147+
},
142148
]
143149
}
144150

@@ -226,7 +232,11 @@ namespace :github do
226232
'push' => {
227233
'branches' => [
228234
'master',
229-
'poc/**',
235+
]
236+
},
237+
'pull_request' => {
238+
'branches' => [
239+
'master',
230240
]
231241
},
232242
'schedule' => [
@@ -238,7 +248,7 @@ namespace :github do
238248
'cancel-in-progress' => '${{ github.ref != \'refs/heads/master\' }}'
239249
},
240250
'jobs' => jobs.merge(
241-
'aggregate' => {
251+
'unit-tests' => {
242252
'runs-on' => ubuntu,
243253
'needs' => runtimes.map(&:build_test_id),
244254
'steps' => [
@@ -315,6 +325,30 @@ namespace :github do
315325
puts JSON.dump(batched_matrix)
316326
end
317327

328+
task :generate_batch_summary do
329+
batches_json = ENV['batches_json']
330+
raise 'batches_json environment variable not set' unless batches_json
331+
332+
data = JSON.parse(batches_json)
333+
summary = ENV['GITHUB_STEP_SUMMARY']
334+
335+
File.open(summary, 'a') do |f|
336+
data['include'].each do |batch|
337+
rows = batch['tasks'].map do |t|
338+
"* #{t['task']} (#{t['group']})"
339+
end
340+
341+
f.puts <<~SUMMARY
342+
<details>
343+
<summary>Batch #{batch['batch']} (#{batch['tasks'].length} tasks)</summary>
344+
345+
#{rows.join("\n")}
346+
</details>
347+
SUMMARY
348+
end
349+
end
350+
end
351+
318352
task :run_batch_build do
319353
tasks = JSON.parse(ENV['BATCHED_TASKS'] || {})
320354

0 commit comments

Comments
 (0)