From 80a62b2b38551da1abf3c8945bc54ce0cad1a0c8 Mon Sep 17 00:00:00 2001 From: Tony Hsu Date: Mon, 3 Feb 2025 13:24:41 +0100 Subject: [PATCH 1/2] Provide batch summary --- .github/workflows/test.yml | 33 +++++++++++++++++++++++++++++++++ tasks/github.rake | 30 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 878c4b10f22..a0387171f2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -44,6 +44,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 @@ -169,6 +172,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 @@ -294,6 +300,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 @@ -419,6 +428,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 @@ -544,6 +556,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 @@ -669,6 +684,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 @@ -794,6 +812,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 @@ -919,6 +940,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 @@ -1044,6 +1068,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 @@ -1169,6 +1196,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 @@ -1294,6 +1324,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 diff --git a/tasks/github.rake b/tasks/github.rake index 9115360283b..0517918eafd 100644 --- a/tasks/github.rake +++ b/tasks/github.rake @@ -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' + }, ] } @@ -315,6 +321,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 +
+ Batch #{batch['batch']} (#{batch['tasks'].length} tasks) + + #{rows.join("\n")} +
+ SUMMARY + end + end + end + task :run_batch_build do tasks = JSON.parse(ENV['BATCHED_TASKS'] || {}) From af0d56b6b789755f000af27b1b47d058bf351872 Mon Sep 17 00:00:00 2001 From: Tony Hsu Date: Mon, 3 Feb 2025 15:13:09 +0100 Subject: [PATCH 2/2] Enable on pull request --- .github/workflows/test.yml | 6 ++++-- tasks/github.rake | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a0387171f2a..43942740481 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -6,7 +6,9 @@ name: Unit Tests push: branches: - master - - poc/** + pull_request: + branches: + - master schedule: - cron: 0 7 * * * concurrency: @@ -1421,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 diff --git a/tasks/github.rake b/tasks/github.rake index 0517918eafd..03853842dad 100644 --- a/tasks/github.rake +++ b/tasks/github.rake @@ -232,7 +232,11 @@ namespace :github do 'push' => { 'branches' => [ 'master', - 'poc/**', + ] + }, + 'pull_request' => { + 'branches' => [ + 'master', ] }, 'schedule' => [ @@ -244,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' => [