Skip to content

Commit

Permalink
Merge pull request #4338 from DataDog/poc/batch-summary
Browse files Browse the repository at this point in the history
Generate batch summary
  • Loading branch information
TonyCTHsu authored Feb 3, 2025
2 parents 0daa829 + af0d56b commit 04efab7
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 4 deletions.
39 changes: 37 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ name: Unit Tests
push:
branches:
- master
- poc/**
pull_request:
branches:
- master
schedule:
- cron: 0 7 * * *
concurrency:
Expand Down Expand Up @@ -44,6 +46,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-ruby-34:
needs:
- batch-ruby-34
Expand Down Expand Up @@ -169,6 +174,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-ruby-33:
needs:
- batch-ruby-33
Expand Down Expand Up @@ -294,6 +302,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-ruby-32:
needs:
- batch-ruby-32
Expand Down Expand Up @@ -419,6 +430,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-ruby-31:
needs:
- batch-ruby-31
Expand Down Expand Up @@ -544,6 +558,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-ruby-30:
needs:
- batch-ruby-30
Expand Down Expand Up @@ -669,6 +686,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-ruby-27:
needs:
- batch-ruby-27
Expand Down Expand Up @@ -794,6 +814,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-ruby-26:
needs:
- batch-ruby-26
Expand Down Expand Up @@ -919,6 +942,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-ruby-25:
needs:
- batch-ruby-25
Expand Down Expand Up @@ -1044,6 +1070,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-jruby-94:
needs:
- batch-jruby-94
Expand Down Expand Up @@ -1169,6 +1198,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-jruby-93:
needs:
- batch-jruby-93
Expand Down Expand Up @@ -1294,6 +1326,9 @@ jobs:
batches_json=$(bundle exec rake github:generate_batches)
echo "$batches_json" | ruby -rjson -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))'
echo "batches=$batches_json" >> $GITHUB_OUTPUT
- env:
batches_json: "${{ steps.set-batches.outputs.batches }}"
run: bundle exec rake github:generate_batch_summary
build-test-jruby-92:
needs:
- batch-jruby-92
Expand Down Expand Up @@ -1388,7 +1423,7 @@ jobs:
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
aggregate:
unit-tests:
runs-on: ubuntu-24.04
needs:
- build-test-ruby-34
Expand Down
38 changes: 36 additions & 2 deletions tasks/github.rake
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,12 @@ namespace :github do
echo "batches=$batches_json" >> $GITHUB_OUTPUT
BASH
},
{
'env' => {
'batches_json' => '${{ steps.set-batches.outputs.batches }}',
},
'run' => 'bundle exec rake github:generate_batch_summary'
},
]
}

Expand Down Expand Up @@ -226,7 +232,11 @@ namespace :github do
'push' => {
'branches' => [
'master',
'poc/**',
]
},
'pull_request' => {
'branches' => [
'master',
]
},
'schedule' => [
Expand All @@ -238,7 +248,7 @@ namespace :github do
'cancel-in-progress' => '${{ github.ref != \'refs/heads/master\' }}'
},
'jobs' => jobs.merge(
'aggregate' => {
'unit-tests' => {
'runs-on' => ubuntu,
'needs' => runtimes.map(&:build_test_id),
'steps' => [
Expand Down Expand Up @@ -315,6 +325,30 @@ namespace :github do
puts JSON.dump(batched_matrix)
end

task :generate_batch_summary do
batches_json = ENV['batches_json']
raise 'batches_json environment variable not set' unless batches_json

data = JSON.parse(batches_json)
summary = ENV['GITHUB_STEP_SUMMARY']

File.open(summary, 'a') do |f|
data['include'].each do |batch|
rows = batch['tasks'].map do |t|
"* #{t['task']} (#{t['group']})"
end

f.puts <<~SUMMARY
<details>
<summary>Batch #{batch['batch']} (#{batch['tasks'].length} tasks)</summary>
#{rows.join("\n")}
</details>
SUMMARY
end
end
end

task :run_batch_build do
tasks = JSON.parse(ENV['BATCHED_TASKS'] || {})

Expand Down

0 comments on commit 04efab7

Please sign in to comment.