diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cb3240ef6..5acdcdf9b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -68,8 +68,8 @@ jobs: done } > benchmark-comment.md - comment_id=$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments?per_page=100" \ - --jq '[.[][] | select(.user.login == "github-actions[bot]" and (.body | startswith("")))] | first | .id // empty') + comment_id=$(gh api --paginate --slurp "repos/$GITHUB_REPOSITORY/issues/$PR_NUMBER/comments?per_page=100" | + jq -r '[.[][] | select(.user.login == "github-actions[bot]" and (.body | startswith("")))] | first | .id // empty') if [ -n "$comment_id" ]; then gh api --method PATCH "repos/$GITHUB_REPOSITORY/issues/comments/$comment_id" \ --field body=@benchmark-comment.md --silent diff --git a/Gemfile.lock b/Gemfile.lock index c866eae1c..f2a4b6255 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - view_component (4.21.0) + view_component (4.22.0) actionview (>= 7.1.0) activesupport (>= 7.1.0) prism (>= 1.0) @@ -651,7 +651,7 @@ CHECKSUMS unicode-emoji (4.3.0) sha256=11c02fa73290378c066bb0562cd4c87d8e1b706fbbe0059ca12746a4244de8ce uri (1.1.2) sha256=89292e98eabbef6248b0a0ed5e7e398e152f83f17560023a6d94a7f492b169fb useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844 - view_component (4.21.0) + view_component (4.22.0) warning (1.6.0) sha256=a49cdfae19fb77d19afff2efbe45f8ab759e9cd25b4e4ce2c79dbaf46bdb6c9e websocket (1.2.11) sha256=b7e7a74e2410b5e85c25858b26b3322f29161e300935f70a0e0d3c35e0462737 websocket-driver (0.8.2) sha256=97c556b019bf3410b4961002ac501621e9322d3f8a7bc02161a09301cc4c4146 diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index a7bf51d97..0f2cf2b20 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -10,6 +10,8 @@ nav_order: 6 ## main +## 4.22.0 + * Comment on release pull requests with benchmark results compared to the previous release. *Joel Hawksley* diff --git a/docs/_data/library.yml b/docs/_data/library.yml index e03aecf4a..f5c9393d7 100644 --- a/docs/_data/library.yml +++ b/docs/_data/library.yml @@ -1 +1 @@ -version: 4.21.0 +version: 4.22.0 diff --git a/gemfiles/rails_7.1.gemfile.lock b/gemfiles/rails_7.1.gemfile.lock index 0ba536680..0076c92e4 100644 --- a/gemfiles/rails_7.1.gemfile.lock +++ b/gemfiles/rails_7.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - view_component (4.21.0) + view_component (4.22.0) actionview (>= 7.1.0) activesupport (>= 7.1.0) prism (>= 1.0) diff --git a/gemfiles/rails_7.2.gemfile.lock b/gemfiles/rails_7.2.gemfile.lock index f52bd98d8..3ee4fd358 100644 --- a/gemfiles/rails_7.2.gemfile.lock +++ b/gemfiles/rails_7.2.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - view_component (4.21.0) + view_component (4.22.0) actionview (>= 7.1.0) activesupport (>= 7.1.0) prism (>= 1.0) diff --git a/gemfiles/rails_8.0.gemfile.lock b/gemfiles/rails_8.0.gemfile.lock index deda602db..6acbf753c 100644 --- a/gemfiles/rails_8.0.gemfile.lock +++ b/gemfiles/rails_8.0.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - view_component (4.21.0) + view_component (4.22.0) actionview (>= 7.1.0) activesupport (>= 7.1.0) prism (>= 1.0) diff --git a/gemfiles/rails_8.1.gemfile.lock b/gemfiles/rails_8.1.gemfile.lock index a92c183be..8f5b650c1 100644 --- a/gemfiles/rails_8.1.gemfile.lock +++ b/gemfiles/rails_8.1.gemfile.lock @@ -1,7 +1,7 @@ PATH remote: .. specs: - view_component (4.21.0) + view_component (4.22.0) actionview (>= 7.1.0) activesupport (>= 7.1.0) prism (>= 1.0) diff --git a/gemfiles/rails_main.gemfile.lock b/gemfiles/rails_main.gemfile.lock index 7e0bf2ef6..351f2da9e 100644 --- a/gemfiles/rails_main.gemfile.lock +++ b/gemfiles/rails_main.gemfile.lock @@ -110,7 +110,7 @@ GIT PATH remote: .. specs: - view_component (4.21.0) + view_component (4.22.0) actionview (>= 7.1.0) activesupport (>= 7.1.0) prism (>= 1.0) @@ -601,7 +601,7 @@ CHECKSUMS unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6 useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844 - view_component (4.21.0) + view_component (4.22.0) warning (1.6.0) sha256=a49cdfae19fb77d19afff2efbe45f8ab759e9cd25b4e4ce2c79dbaf46bdb6c9e webrick (1.9.2) sha256=beb4a15fc474defed24a3bda4ffd88a490d517c9e4e6118c3edce59e45864131 websocket-driver (0.8.0) sha256=ed0dba4b943c22f17f9a734817e808bc84cdce6a7e22045f5315aa57676d4962 diff --git a/gemfiles/rails_main_head.gemfile.lock b/gemfiles/rails_main_head.gemfile.lock index fb19e9399..fd4eb911d 100644 --- a/gemfiles/rails_main_head.gemfile.lock +++ b/gemfiles/rails_main_head.gemfile.lock @@ -110,7 +110,7 @@ GIT PATH remote: .. specs: - view_component (4.21.0) + view_component (4.22.0) actionview (>= 7.1.0) activesupport (>= 7.1.0) prism (>= 1.0) @@ -563,7 +563,7 @@ CHECKSUMS unicode-emoji (4.2.0) sha256=519e69150f75652e40bf736106cfbc8f0f73aa3fb6a65afe62fefa7f80b0f80f uri (1.1.1) sha256=379fa58d27ffb1387eaada68c749d1426738bd0f654d812fcc07e7568f5c57c6 useragent (0.16.11) sha256=700e6413ad4bb954bb63547fa098dddf7b0ebe75b40cc6f93b8d54255b173844 - view_component (4.21.0) + view_component (4.22.0) warning (1.6.0) sha256=a49cdfae19fb77d19afff2efbe45f8ab759e9cd25b4e4ce2c79dbaf46bdb6c9e webrick (1.9.2) sha256=beb4a15fc474defed24a3bda4ffd88a490d517c9e4e6118c3edce59e45864131 websocket-driver (0.8.0) sha256=ed0dba4b943c22f17f9a734817e808bc84cdce6a7e22045f5315aa57676d4962 diff --git a/lib/view_component/version.rb b/lib/view_component/version.rb index b98172fd3..0126c7db3 100644 --- a/lib/view_component/version.rb +++ b/lib/view_component/version.rb @@ -3,7 +3,7 @@ module ViewComponent module VERSION MAJOR = 4 - MINOR = 21 + MINOR = 22 PATCH = 0 PRE = nil diff --git a/test/sandbox/test/test_helper_test.rb b/test/sandbox/test/test_helper_test.rb index 0beeac5bb..11c8603ef 100644 --- a/test/sandbox/test/test_helper_test.rb +++ b/test/sandbox/test/test_helper_test.rb @@ -3,6 +3,21 @@ require "test_helper" class TestHelperTest < ViewComponent::TestCase + def test_modify_file_processes_pending_view_reloads + Rails.application.reloader.reload! + refute Rails.application.reloaders.any?(&:updated?) + + path = "app/views/shared/_partial.html.erb" + original = File.read(Rails.root.join(path)) + + modify_file(path, "#{original}\n") do + assert_equal "#{original}\n", File.read(Rails.root.join(path)) + end + + assert_equal original, File.read(Rails.root.join(path)) + refute Rails.application.reloaders.any?(&:updated?) + end + def test_with_request_url_inside_slots_path with_request_url "/slots" do render_inline(CurrentPageComponent.new) diff --git a/test/script/benchmark_workflow_test.rb b/test/script/benchmark_workflow_test.rb index 598185159..8515ad4d1 100644 --- a/test/script/benchmark_workflow_test.rb +++ b/test/script/benchmark_workflow_test.rb @@ -93,14 +93,22 @@ def test_comments_include_both_rails_results_and_are_updated_on_reruns end write("artifacts/performance-rails-main/report.md", "Updated Rails main results\n") - stdout, stderr, status = run_step("benchmark-comment", "Post release benchmark results", env: {"COMMENT_ID" => "789"}) + comment_pages = [ + [ + {"id" => 123, "user" => {"login" => "contributor"}, "body" => ""}, + {"id" => 456, "user" => {"login" => "github-actions[bot]"}, "body" => "Another comment"} + ], + [ + {"id" => 789, "user" => {"login" => "github-actions[bot]"}, "body" => "\nOld results"} + ] + ] + stdout, stderr, status = run_step("benchmark-comment", "Post release benchmark results", env: {"COMMENT_PAGES" => JSON.generate(comment_pages)}) assert status.success?, "#{stdout}\n#{stderr}" assert_includes read("posted-comment.md"), "Updated Rails main results" assert_equal 1, read("commands.log").lines.count { |line| line.include?("--method POST") } assert_includes read("commands.log"), "--method PATCH repos/ViewComponent/view_component/issues/comments/789" - assert_includes read("commands.log"), '.user.login == "github-actions[bot]"' - assert_includes read("commands.log"), 'startswith("")' + assert_includes read("commands.log"), "--paginate --slurp repos/ViewComponent/view_component/issues/456/comments?per_page=100" end def test_missing_results_are_reported_explicitly @@ -210,6 +218,7 @@ def assert_comparison_report(head_ratio:, exitstatus:) def prepare_comments %w[8.1 main].each { |rails| write("artifacts/performance-rails-#{rails}/report.md", "Results for Rails #{rails}\n") } @environment["COMMAND_LOG"] = File.join(@directory, "commands.log") + @environment["COMMENT_PAGES"] = JSON.generate([[]]) mock_commands(<<~BASH) gh() { printf '%s\\n' "$*" >> "$COMMAND_LOG" @@ -217,7 +226,7 @@ def prepare_comments repos/*/pulls/*) printf '%s\\n' "${CURRENT_HEAD:-$HEAD_SHA}" ;; --paginate) if [ "${LOOKUP_STATUS:-0}" != "0" ]; then return "$LOOKUP_STATUS"; fi - printf '%s' "${COMMENT_ID:-}" + printf '%s\\n' "$COMMENT_PAGES" ;; --method) if [ "${COMMENT_STATUS:-0}" != "0" ]; then return "$COMMENT_STATUS"; fi diff --git a/test/test_helper.rb b/test/test_helper.rb index 9d1b68e1f..296523726 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -169,11 +169,9 @@ def modify_file(file, content) # recompiles from the now-restored file. ViewComponent::CompileCache.invalidate! - # Restoring a Ruby file leaves a code reload pending. Apply it here, in the - # test's own thread: if a system test's server thread picked it up instead, - # it would wait for this thread's executor to finish, which never happens - # while the test waits on the request. - Rails.application.reloader.reload! if File.extname(filename) == ".rb" + # Restoring a watched file can leave a code or view reload pending. Apply it + # on the test thread before a system-test request can wait for its executor. + Rails.application.reloader.reload! end end