Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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("<!-- view-component-release-benchmarks -->")))] | 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("<!-- view-component-release-benchmarks -->")))] | 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
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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*
Expand Down
2 changes: 1 addition & 1 deletion docs/_data/library.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
version: 4.21.0
version: 4.22.0
2 changes: 1 addition & 1 deletion gemfiles/rails_7.1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_7.2.gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_8.0.gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gemfiles/rails_8.1.gemfile.lock
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/rails_main.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions gemfiles/rails_main_head.gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/view_component/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module ViewComponent
module VERSION
MAJOR = 4
MINOR = 21
MINOR = 22
PATCH = 0
PRE = nil

Expand Down
15 changes: 15 additions & 0 deletions test/sandbox/test/test_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
17 changes: 13 additions & 4 deletions test/script/benchmark_workflow_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" => "<!-- view-component-release-benchmarks -->"},
{"id" => 456, "user" => {"login" => "github-actions[bot]"}, "body" => "Another comment"}
],
[
{"id" => 789, "user" => {"login" => "github-actions[bot]"}, "body" => "<!-- view-component-release-benchmarks -->\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("<!-- view-component-release-benchmarks -->")'
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
Expand Down Expand Up @@ -210,14 +218,15 @@ 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"
case "$2" in
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
Expand Down
8 changes: 3 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading