Commit Graph

820 Commits

Author SHA1 Message Date
Earlopain
d902f4487e
Add ostruct to the gemfile
Ruby 3.5 will warn, 3.6 will raise.

This is a test-only dependency, framework code itself doesn't use it (enforced by RuboCop)
2024-04-02 13:09:00 +02:00
Jean Boussier
3e7ba58439 Delete EncryptionPerformanceTest
On my machine, running the whole Active Record test suite takes
`88` seconds, and `40` of these are spent in encryption tests.

Some of them also happen to flake because of random blips.

I appreciate the care that has been put into ensuring the overhead
of encrption was reasonable, but I don't think these tests justify
their cost.
2024-02-06 18:05:31 +01:00
Yasuo Honda
0c9329161c Pin minitest version to 5.21
Managed to reproduce CI failure at https://buildkite.com/rails/rails-nightly/builds/133#018d7bb8-8a32-4978-8e36-d7cb9b067813/1196-1204 . It would also reproduce against the released versions of Ruby because this is triggered by minitest v5.22.0 change. ebb468c81c

To avoid all of railties CI failures, pin minitest version to 5.21 tentatively.

* Steps to reproduce
```ruby
git clone https://github.com/rails/rails
cd rails
rm Gemfile.lock
bundle install
cd railties
bin/test test/application/test_runner_test.rb -n test_system_tests_are_not_run_with_the_default_test_command
```

* Expected behavior
It should pass.

* Actual behavior
```ruby
$ bin/test test/application/test_runner_test.rb -n test_system_tests_are_not_run_with_the_default_test_command
Run options: -n test_system_tests_are_not_run_with_the_default_test_command --seed 14574

F

Failure:
ApplicationTests::TestRunnerTest#test_system_tests_are_not_run_with_the_default_test_command [test/application/test_runner_test.rb:1191]:
Expected /0\ runs,\ 0\ assertions,\ 0\ failures,\ 0\ errors,\ 0\ skips/ to match "Nothing ran for filter: \nRunning 0 tests in a single process (parallelization threshold is 50)\nRun options: --seed 45713\n\n# Running:\n\n".

bin/test test/application/test_runner_test.rb:1179

Finished in 9.982314s, 0.1002 runs/s, 0.2004 assertions/s.
1 runs, 2 assertions, 1 failures, 0 errors, 0 skips
$
```
2024-02-06 10:52:58 +09:00
Yasuo Honda
baae73c074 Use httpclient to run "Daily build with Ruby head"
This pull request addresses "Daily build with Ruby head" failure https://buildkite.com/rails/rails-nightly/builds/101#018d5285-b4de-4072-b7d3-61c19f21347a

Action Mailbox needs `webmock` which depends on `httpclient`.
`httpclient` master branch that added `mutex_m` as a dependency via https://github.com/nahi/httpclient/pull/455 to support Ruby 3.4.0dev.

```ruby
cd actionmailbox
bundle exec rake test
```

```ruby
... snip ...
/home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/webmock-3.19.1/lib/webmock/http_lib_adapters/httpclient_adapter.rb:234:in `alias_method': undefined method `do_get_block' for class `WebMockHTTPClient' (NameError)

    alias_method :do_get_block_without_webmock, :do_get_block
    ^^^^^^^^^^^^
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/webmock-3.19.1/lib/webmock/http_lib_adapters/httpclient_adapter.rb:234:in `<class:WebMockHTTPClient>'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/webmock-3.19.1/lib/webmock/http_lib_adapters/httpclient_adapter.rb:233:in `<top (required)>'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/webmock-3.19.1/lib/webmock.rb:52:in `require_relative'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/webmock-3.19.1/lib/webmock.rb:52:in `<top (required)>'
        from <internal:/home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from <internal:/home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/zeitwerk-2.6.12/lib/zeitwerk/kernel.rb:38:in `require'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundler/runtime.rb:60:in `block (2 levels) in require'
        from <internal:array>:52:in `each'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundler/runtime.rb:55:in `block in require'
        from <internal:array>:52:in `each'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundler/runtime.rb:44:in `require'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundler.rb:187:in `require'
        from /home/yahonda/src/github.com/rails/rails/actionmailbox/test/dummy/config/application.rb:7:in `<top (required)>'
        from /home/yahonda/src/github.com/rails/rails/actionmailbox/test/dummy/config/environment.rb:2:in `require_relative'
        from /home/yahonda/src/github.com/rails/rails/actionmailbox/test/dummy/config/environment.rb:2:in `<top (required)>'
        from /home/yahonda/src/github.com/rails/rails/actionmailbox/test/test_helper.rb:8:in `require_relative'
        from /home/yahonda/src/github.com/rails/rails/actionmailbox/test/test_helper.rb:8:in `<top (required)>'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundled_gems.rb:74:in `require'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
        from /home/yahonda/src/github.com/rails/rails/actionmailbox/test/controllers/ingresses/mailgun/inbound_emails_controller_test.rb:3:in `<top (required)>'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundled_gems.rb:74:in `require'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/3.4.0+0/bundled_gems.rb:74:in `block (2 levels) in replace_require'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb:21:in `block in <main>'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb:6:in `select'
        from /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb:6:in `<main>'
rake aborted!
Command failed with status (1): [ruby -w -I"lib:test" /home/yahonda/.rbenv/versions/ruby-dev/lib/ruby/gems/3.4.0+0/gems/rake-13.1.0/lib/rake/rake_test_loader.rb "test/controllers/ingresses/mailgun/inbound_emails_controller_test.rb" "test/controllers/ingresses/mandrill/inbound_emails_controller_test.rb" "test/controllers/ingresses/postmark/inbound_emails_controller_test.rb" "test/controllers/ingresses/relay/inbound_emails_controller_test.rb" "test/controllers/ingresses/sendgrid/inbound_emails_controller_test.rb" "test/controllers/rails/action_mailbox/inbound_emails_controller_test.rb" "test/generators/mailbox_generator_test.rb" "test/jobs/incineration_job_test.rb" "test/migrations_test.rb" "test/models/table_name_test.rb" "test/unit/inbound_email/incineration_test.rb" "test/unit/inbound_email/message_id_test.rb" "test/unit/inbound_email_test.rb" "test/unit/mail_ext/address_equality_test.rb" "test/unit/mail_ext/address_wrapping_test.rb" "test/unit/mail_ext/addresses_test.rb" "test/unit/mailbox/bouncing_test.rb" "test/unit/mailbox/callbacks_test.rb" "test/unit/mailbox/notifications_test.rb" "test/unit/mailbox/routing_test.rb" "test/unit/mailbox/state_test.rb" "test/unit/relayer_test.rb" "test/unit/router_test.rb" "test/unit/test_helper_test.rb" ]
<internal:array>:52:in `each'
<internal:array>:52:in `each'
/home/yahonda/.rbenv/versions/ruby-dev/bin/bundle:25:in `load'
/home/yahonda/.rbenv/versions/ruby-dev/bin/bundle:25:in `<main>'
Tasks: TOP => test
(See full trace by running task with --trace)
$
```
2024-01-29 21:37:10 +09:00
Hartley McGuire
0041af4c94
Ensure all RubyTracker RenderParsers are tested
Previously, only the PrismRenderParser or RipperRenderParser would be
tested depending on if the Prism gem is available. This meant that
PrismRenderParser was being tested on Ruby 3.3 and RipperRenderParser
was tested on Ruby < 3.3. Additionally, if someone were to add prism to
the rails/rails Gemfile because they wrote a tool that uses it then the
RipperRenderParser would end up completely untested.

This commit is a small refactor to enable testing both RenderParsers in
all Ruby versions so that the prism gem can be added to the Gemfile.
2024-01-24 19:16:59 -05:00
Daniel Colson
6616770ec9
Translate Trilogy syscall errors as conn failed
At GitHub we get a fair number of Trilogy `ETIMEDOUT` errors (for known
reasons that we might be able to improve somewhat, but I doubt we'll
make them go away entirely). These are very much retryable network
errors, so it'd be handy if these `ETIMEDOUT` errors were translated to
`ConnectionFailed` instead of `StatementInvalid`, making them
`retryable_connection_error`s.

ed2bc92b82/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb (L1077)

We're already translating `ECONNRESET` (via matching on the error
message) and `EPIPE` to `ConnectionFailed`. Rather than adding another
case, this commit treats all of the Trilogy `SystemCallError` subclasses
as `ConnectionFailed`.

This requires bumping trilogy 2.7 so we can get
https://github.com/trilogy-libraries/trilogy/pull/143
2024-01-23 16:20:02 -05:00
Jean Boussier
d839ddb71a Refactor ActionController::RateLimiting to use AS::Cache
Given that the limiter implementation provided by Kredis is a simple
increment with a limit, all `ActiveSupport::Cache` already provide that
same capability, with a wide range of backing stores, and not just Redis.

This even allow to use SolidCache has a backend if you so desire.

If we feel particularly fancy, we could also accept a more generic
limiter interface to better allow users to swap the implementation
for better algorithms such as leaky-bucket etc.
2024-01-17 15:40:49 +01:00
Hartley McGuire
fd7e235789
Do not automatically require minitest-bisect
This is currently causing an issue in 6-1-stable CI due to a chain of
dependencies: minitest-bisect -> minitest-server -> drb. The last
working version of Drb for Ruby 2.5 and 2.6 includes usage of
ruby2_keywords but does not declare a dependency on the shim gem
(meaning that version of Drb actual does not work on those Ruby
versions).

ruby2_keywords was [added][1] to the 6-1-stable Active Support gemspec
to address the issue with Drb, but this only fixes cases where Drb is
required by Rails. However, there are still failing tests on 6-1-stable
due to Drb being loaded in integration tests where a dummy Rails
application calls Bundler.require and the above dependency chain is
required.

To address those test failures, this commit prevents minitest-bisect
from being automatically required when the whole bundle is required. It
is not strictly necessary for main or any stable branches other than
6-1-stable, but it seems more correct since minitest_bisect is ran as an
external command anyways.

[1]: 5a54e2f36aa91e32ac9a4b7af7e605f876cc3cfa
2024-01-08 13:42:06 -05:00
Rafael Mendonça França
9d18dc8505
Remove all code to work with Ruby < 3.1 2024-01-03 19:02:31 +00:00
Hartley McGuire
66c174557a
bundle update (#50516)
This commit is meant to accomplish two things:
- update gems with precompiled C extensions (nokogiri) so that Rails'
  lockfile can be `bundle install`d on Ruby 3.3
- remove some Gemfile conditionals for Ruby < 3 now that 3.1 is the
  minimum version

Additionally, a requirement is added to ignore mdl 0.13.0 because it
raises false positive warnings. The commit introducing those warnings
has been reverted but there has not been a release since the revert.
2024-01-02 16:48:44 +01:00
Jonathan Hefner
d4cae83a17 Add brakeman as development dependency
Follow-up to #50507.

Since `brakeman` is now included in generated apps by default, it must
be installed before running Rails tests that invoke `bin/rails` for
generated apps.

This fixes CI failures such as:

  ```
  Error:
  AppGeneratorTest#test_app_update_does_not_change_app_name_when_app_name_is_hyphenated_name:
  RuntimeError: Command failed with exit 1: yes | bin/rails app:update
      test/generators/app_generator_test.rb:1304:in `system'
      test/generators/app_generator_test.rb:1304:in `block (2 levels) in run_app_update'
      test/generators/app_generator_test.rb:1304:in `block in run_app_update'
      test/generators/app_generator_test.rb:1299:in `chdir'
      test/generators/app_generator_test.rb:1299:in `run_app_update'
      test/generators/app_generator_test.rb:430:in `test_app_update_does_not_change_app_name_when_app_name_is_hyphenated_name'
  ```
2024-01-01 12:00:10 -06:00
David Heinemeier Hansson
e3da4fc53d
Add allow_browser to set minimum versions for your application (#50505)
* Add allow_browser to set minimum versions for your application
2023-12-31 19:19:16 +01:00
zzak
cbd8bd735c
Add rubocop-rails-omakase as development dependency (#50495)
This gem is used in Railties tests so it must be a development dependency.
Due to the fixture rails app tmp/rails/app_template faking Bundler and using the repo's Gemfile:
0fb5f67ac4/railties/test/isolation/abstract_unit.rb (L618-L622)

See also: e4b0488851
2023-12-31 18:18:17 +01:00
David Heinemeier Hansson
179b979ddb
Add rate limiting to Action Controller via the Kredis limiter type (#50490)
* Add rate limiting via the Kredis limiter type
2023-12-31 13:26:01 +01:00
Stan Lo
6be6669c95
Use IRB 1.10.1 to avoid console test issues on CI 2023-12-05 16:36:27 +00:00
Jean Boussier
1aa4bd3823 Lock irb to < 1.10 for now
It breaks various `rails console` related integration tests:

```
Failure:
FullStackConsoleTest#test_sandbox [test/application/console_test.rb:123]:
"> " expected, but got:

(END).
Expected "\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n--More--\r        \r(END)" to include "> ".
```

I tried to figure out a fix, but ran out of time, so in order
to fix CI we can lock IRB for now.
2023-12-05 16:31:01 +01:00
eileencodes
a8e07924d6 Fix dependency on JSON gem
Don't use `json` 2.7.0 release that has a regression.

Ref: https://github.com/flori/json/pull/554
2023-12-02 09:41:55 +01:00
Rafael Mendonça França
403447d061
Use version of importmap that support loading outside of an app
We are using it in a few scripts, and we were doing workarounds
to be able to use outside an Rails application.

Now the workaround is gone.
2023-10-27 20:23:42 +00:00
Usman
24b99910cf No need to include error_highlight when ruby version >= 3.2 2023-09-29 09:05:06 +00:00
zzak
5c2a112d37
Import rails-bin to internal tools/
Co-authored-by: zzak <zzakscott@gmail.com>
2023-09-13 01:57:16 +00:00
Mike Dalessio
64169655c7
dep: bump sqlite3 dependency
sqlite3-ruby v1.6.6 has sqlite 3.43.1 which fixes the AVG() bug
described in https://github.com/sparklemotion/sqlite3-ruby/issues/396

See related https://github.com/rails/rails/pull/49048
2023-09-12 14:18:13 -04:00
Rafael Mendonça França
e4d47eaecf
Revert "Lock globalid gem version to address broken CI"
This reverts commit 6440efa9ea05cde1f001098aa25bebbb2ea20fbb.
2023-09-05 16:17:49 +00:00
Ryuta Kamizono
6440efa9ea Lock globalid gem version to address broken CI
Broken CI is due to https://github.com/rails/globalid/pull/163 in
globalid 1.2.0.

https://buildkite.com/rails/rails/builds/99329#018a5f01-a966-4424-9596-0a7f1deeb1ff/1178-1190
2023-09-04 16:40:19 +09:00
Rafael Mendonça França
7459392bf1
Use the released version of trilogy 2023-09-01 20:39:50 +00:00
Rafael Mendonça França
4aa1625edd
Always install sdoc from git
The EDGE environment variable isn't set when installing the gems.
Since this branch is the edge branch, we don't need this environment
variable.
2023-08-28 15:29:58 +00:00
zzak
0f580a20fe
Try to build with sqlite3 1.6.3 2023-08-27 09:29:29 +09:00
Petrik
8d08867b76 Use sdoc main branch for edge API docs 2023-08-09 14:17:01 +02:00
Sean Doyle
425f100f08 Add RUBY_VERSION conditional 2023-08-02 11:19:37 -04:00
Sean Doyle
9a53234695 Omit webdrivers gem from Gemfile template
As of Selenium 4.6, [the Selenium Manager is capable of managing Chrome
Driver installations and integrations][readme]. As of Selenium 4.11, the
Selenium Manager is capable of [capable of resolving the Chrome for
Testing installation][] path.

By omitting the `gem` declaration from the `Gemfile.tt`, newly generated
applications and applications updating their `Gemfile` in lockstep with
newer Rails versions can shed the dependency and avoid test failures
introduced by newly released Chrome versions (like, for example,
[titusfortner/webdrivers#247][]).

[readme]: 43f8ac436c (update-selenium-manager)
[titusfortner/webdrivers#247]: https://github.com/titusfortner/webdrivers/issues/247
[capable of resolving the Chrome for Testing installation]: https://github.com/rails/rails/pull/48847#issuecomment-1656756862

Co-authored-by: Titus Fortner <titusfortner@users.noreply.github.com>
2023-08-01 09:22:08 -04:00
Samuel Williams
8adc374e74
Try out rack head (3.1). 2023-07-19 15:36:57 +12:00
Guillermo Iguaran
a96d5beb63 Upgrade rack and related dependencies in Gemfile and lockfile 2023-06-12 21:45:58 -07:00
Akira Matsuda
341db94b22
Revert "Switch to i18n master branch temporary to fix actionview test"
This reverts commit 43f4792f16e479afb00b7fe7a9df1e4c7b26fad7.

i18n 1.14.1 is available now
2023-06-05 08:38:18 +09:00
Guillermo Iguaran
43f4792f16 Switch to i18n master branch temporary to fix actionview test
Revert this commit after i18n > 1.14.0 is released.
2023-06-03 18:49:03 -07:00
Stan Lo
3438316e46
Don't install readline-ext 2023-06-01 17:55:27 +01:00
Yasuo Honda
a6e0b0acb2 Add readline-ext that has been removed from Ruby 3.3.0dev
Address these Rails CI failures:
https://buildkite.com/rails/rails/builds/96301#01880117-acb1-4d77-935a-4a1de13c8609/1093-1101

Refer to
https://bugs.ruby-lang.org/issues/19616
https://github.com/ruby/ruby/pull/7781

```ruby
$ ruby -v
ruby 3.3.0dev (2023-05-09T19:40:26Z master e1c84e8ee6) [x86_64-linux]
$ cd railties
$ bin/test test/application/console_test.rb
... snip ...

.F

Failure:
FullStackConsoleTest#test_environment_option_and_irb_option [/home/yahonda/src/github.com/rails/rails/railties/test/application/console_test.rb:133]:
"> " expected, but got:

Loading test environment (Rails 7.1.0.alpha)
Switch to inspect mode.
▽.
Expected # encoding: ASCII-8BIT
"Loading test environment (Rails 7.1.0.alpha)\r\nSwitch to inspect mode.\r\n\e[1G\xE2\x96\xBD\e[6n" to include "> ".

bin/test test/application/console_test.rb:167

^[[30;2RF

Failure:
FullStackConsoleTest#test_sandbox [/home/yahonda/src/github.com/rails/rails/railties/test/application/console_test.rb:133]:
"> " expected, but got:

Loading development environment in sandbox (Rails 7.1.0.alpha)
Any modifications you make will be rolled back on exit
▽.
Expected # encoding: ASCII-8BIT
"Loading development environment in sandbox (Rails 7.1.0.alpha)\r\nAny modifications you make will be rolled back on exit\r\n\e[1G\xE2\x96\xBD\e[6n" to include "> ".

bin/test test/application/console_test.rb:139

^[[30;2R......

Finished in 66.153595s, 0.1360 runs/s, 0.2872 assertions/s.
9 runs, 19 assertions, 2 failures, 0 errors, 0 skips
$
```
2023-05-10 08:33:13 +09:00
eileencodes
14f22758cc
Bump trilogy to fix connection error translation
Until we do a new release we need to run against main on trilogy to get
the latest changes from https://github.com/github/trilogy/pull/69
2023-04-21 17:33:25 -04:00
Eileen M. Uchitelle
f7a40229e3
Merge pull request #47880 from adrianna-chang-shopify/ac-trilogy-adapter
Introduce adapter for Trilogy, a MySQL-compatible DB client
2023-04-17 14:56:49 -04:00
Jonathan Hefner
a2a6331451 Add ActiveSupport::MessagePack
`ActiveSupport::MessagePack` is a serializer that integrates with the
`msgpack` gem to serialize a variety of Ruby objects.  `AS::MessagePack`
supports several types beyond the base types that `msgpack` supports,
including `Time` and `Range`, as well as Active Support types such as
`AS::TimeWithZone` and `AS::HashWithIndifferentAccess`.

Compared to `JSON` and `Marshal`, `AS::MessagePack` can provide a
performance improvement and message size reduction.  For example, when
used with `MessageVerifier`:

  ```ruby
  # frozen_string_literal: true

  require "benchmark/ips"
  require "active_support/all"
  require "active_support/message_pack"

  marshal_verifier = ActiveSupport::MessageVerifier.new("secret", serializer: Marshal)
  json_verifier = ActiveSupport::MessageVerifier.new("secret", serializer: JSON)
  asjson_verifier = ActiveSupport::MessageVerifier.new("secret", serializer: ActiveSupport::JSON)
  msgpack_verifier = ActiveSupport::MessageVerifier.new("secret", serializer: ActiveSupport::MessagePack)

  ActiveSupport::Messages::Metadata.use_message_serializer_for_metadata = true
  expiry = 1.year.from_now
  data = { bool: true, num: 123456789, string: "x" * 50 }

  Benchmark.ips do |x|
    x.report("Marshal") do
      marshal_verifier.verify(marshal_verifier.generate(data, expires_at: expiry))
    end

    x.report("JSON") do
      json_verifier.verify(json_verifier.generate(data, expires_at: expiry))
    end

    x.report("AS::JSON") do
      asjson_verifier.verify(asjson_verifier.generate(data, expires_at: expiry))
    end

    x.report("MessagePack") do
      msgpack_verifier.verify(msgpack_verifier.generate(data, expires_at: expiry))
    end

    x.compare!
  end

  puts "Marshal size: #{marshal_verifier.generate(data, expires_at: expiry).bytesize}"
  puts "JSON size: #{json_verifier.generate(data, expires_at: expiry).bytesize}"
  puts "MessagePack size: #{msgpack_verifier.generate(data, expires_at: expiry).bytesize}"
  ```

  ```
  Warming up --------------------------------------
               Marshal     1.206k i/100ms
                  JSON     1.165k i/100ms
              AS::JSON   790.000  i/100ms
           MessagePack     1.798k i/100ms
  Calculating -------------------------------------
               Marshal     11.748k (± 1.3%) i/s -     59.094k in   5.031071s
                  JSON     11.498k (± 1.4%) i/s -     58.250k in   5.066957s
              AS::JSON      7.867k (± 2.4%) i/s -     39.500k in   5.024055s
           MessagePack     17.865k (± 0.8%) i/s -     89.900k in   5.032592s

  Comparison:
           MessagePack:    17864.9 i/s
               Marshal:    11747.8 i/s - 1.52x  (± 0.00) slower
                  JSON:    11498.4 i/s - 1.55x  (± 0.00) slower
              AS::JSON:     7866.9 i/s - 2.27x  (± 0.00) slower

  Marshal size: 254
  JSON size: 234
  MessagePack size: 194
  ```

Additionally, `ActiveSupport::MessagePack::CacheSerializer` is a
serializer that is suitable for use as an `ActiveSupport::Cache` coder.
`AS::MessagePack::CacheSerializer` can serialize `ActiveRecord::Base`
instances, including loaded associations.  Like `AS::MessagePack`, it
provides a performance improvement and payload size reduction:

  ```ruby
  # frozen_string_literal: true

  require "benchmark/ips"
  require "active_support/message_pack"

  ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")

  ActiveRecord::Schema.define do
    create_table :posts, force: true do |t|
      t.string :body
      t.timestamps
    end

    create_table :comments, force: true do |t|
      t.integer :post_id
      t.string :body
      t.timestamps
    end
  end

  class Post < ActiveRecord::Base
    has_many :comments
  end

  class Comment < ActiveRecord::Base
    belongs_to :post
  end

  post = Post.create!(body: "x" * 100)
  2.times { post.comments.create!(body: "x" * 100) }
  post.comments.load
  cache_entry = ActiveSupport::Cache::Entry.new(post)

  Rails70Coder = ActiveSupport::Cache::Coders::Rails70Coder
  CacheSerializer = ActiveSupport::MessagePack::CacheSerializer

  Benchmark.ips do |x|
    x.report("Rails70Coder") do
      Rails70Coder.load(Rails70Coder.dump(cache_entry))
    end

    x.report("CacheSerializer") do
      CacheSerializer.load(CacheSerializer.dump(cache_entry))
    end

    x.compare!
  end

  puts "Rails70Coder size: #{Rails70Coder.dump(cache_entry).bytesize}"
  puts "CacheSerializer size: #{CacheSerializer.dump(cache_entry).bytesize}"
  ```

  ```
  Warming up --------------------------------------
          Rails70Coder   329.000  i/100ms
       CacheSerializer   492.000  i/100ms
  Calculating -------------------------------------
          Rails70Coder      3.285k (± 1.7%) i/s -     16.450k in   5.008447s
       CacheSerializer      4.895k (± 2.4%) i/s -     24.600k in   5.028803s

  Comparison:
       CacheSerializer:     4894.7 i/s
          Rails70Coder:     3285.4 i/s - 1.49x  slower

  Rails70Coder size: 808
  CacheSerializer size: 593
  ```

Co-authored-by: Jean Boussier <jean.boussier@gmail.com>
2023-04-17 11:56:06 -05:00
Adrianna Chang
5ed3f60df6
Introduce adapter for Trilogy, a MySQL-compatible DB client
The [Trilogy database client][trilogy-client] and corresponding
[Active Record adapter][ar-adapter] were both open sourced by GitHub last year.

Shopify has recently taken the plunge and successfully adopted Trilogy in their Rails monolith.
With two major Rails applications running Trilogy successfully, we'd like to propose upstreaming the adapter
to Rails as a MySQL-compatible alternative to Mysql2Adapter.

[trilogy-client]: https://github.com/github/trilogy
[ar-adapter]: https://github.com/github/activerecord-trilogy-adapter

Co-authored-by: Aaron Patterson <tenderlove@github.com>
Co-authored-by: Adam Roben <adam@roben.org>
Co-authored-by: Ali Ibrahim <aibrahim2k2@gmail.com>
Co-authored-by: Aman Gupta <aman@tmm1.net>
Co-authored-by: Arthur Nogueira Neves <github@arthurnn.com>
Co-authored-by: Arthur Schreiber <arthurschreiber@github.com>
Co-authored-by: Ashe Connor <kivikakk@github.com>
Co-authored-by: Brandon Keepers <brandon@opensoul.org>
Co-authored-by: Brian Lopez <seniorlopez@gmail.com>
Co-authored-by: Brooke Kuhlmann <brooke@testdouble.com>
Co-authored-by: Bryana Knight <bryanaknight@github.com>
Co-authored-by: Carl Brasic <brasic@github.com>
Co-authored-by: Chris Bloom <chrisbloom7@github.com>
Co-authored-by: Cliff Pruitt <cliff.pruitt@cliffpruitt.com>
Co-authored-by: Daniel Colson <composerinteralia@github.com>
Co-authored-by: David Calavera <david.calavera@gmail.com>
Co-authored-by: David Celis <davidcelis@github.com>
Co-authored-by: David Ratajczak <david@mockra.com>
Co-authored-by: Dirkjan Bussink <d.bussink@gmail.com>
Co-authored-by: Eileen Uchitelle <eileencodes@gmail.com>
Co-authored-by: Enrique Gonzalez <enriikke@gmail.com>
Co-authored-by: Garrett Bjerkhoel <garrett@github.com>
Co-authored-by: Georgi Knox <georgicodes@github.com>
Co-authored-by: HParker <HParker@github.com>
Co-authored-by: Hailey Somerville <hailey@hailey.lol>
Co-authored-by: James Dennes <jdennes@gmail.com>
Co-authored-by: Jane Sternbach <janester@github.com>
Co-authored-by: Jess Bees <toomanybees@github.com>
Co-authored-by: Jesse Toth <jesse.toth@github.com>
Co-authored-by: Joel Hawksley <joelhawksley@github.com>
Co-authored-by: John Barnette <jbarnette@github.com>
Co-authored-by: John Crepezzi <john.crepezzi@gmail.com>
Co-authored-by: John Hawthorn <john@hawthorn.email>
Co-authored-by: John Nunemaker <nunemaker@gmail.com>
Co-authored-by: Jonathan Hoyt <hoyt@github.com>
Co-authored-by: Katrina Owen <kytrinyx@github.com>
Co-authored-by: Keeran Raj Hawoldar <keeran@gmail.com>
Co-authored-by: Kevin Solorio <soloriok@gmail.com>
Co-authored-by: Leo Correa <lcorr005@gmail.com>
Co-authored-by: Lizz Hale <lizzhale@github.com>
Co-authored-by: Lorin Thwaits <lorint@gmail.com>
Co-authored-by: Matt Jones <al2o3cr@gmail.com>
Co-authored-by: Matthew Draper <matthewd@github.com>
Co-authored-by: Max Veytsman <mveytsman@github.com>
Co-authored-by: Nathan Witmer <nathan@zerowidth.com>
Co-authored-by: Nick Holden <nick.r.holden@gmail.com>
Co-authored-by: Paarth Madan <paarth.madan@shopify.com>
Co-authored-by: Patrick Reynolds <patrick.reynolds@github.com>
Co-authored-by: Rob Sanheim <rsanheim@gmail.com>
Co-authored-by: Rocio Delgado <rocio@github.com>
Co-authored-by: Sam Lambert <sam.lambert@github.com>
Co-authored-by: Shay Frendt <shay@github.com>
Co-authored-by: Shlomi Noach <shlomi-noach@github.com>
Co-authored-by: Sophie Haskins <sophaskins@github.com>
Co-authored-by: Thomas Maurer <tma@github.com>
Co-authored-by: Tim Pease <tim.pease@gmail.com>
Co-authored-by: Yossef Mendelssohn <ymendel@pobox.com>
Co-authored-by: Zack Koppert <zkoppert@github.com>
Co-authored-by: Zhongying Qiao <cryptoque@users.noreply.github.com>
2023-04-17 11:49:07 -04:00
zzak
4bcc7bc951
Fix duplicate Gemfile entry warning
Your Gemfile lists the gem rake (>= 13) more than once.
You should probably keep only one of them.
Remove any duplicate entries and specify the gem only once.
While it's not a problem now, it could cause errors if you change the version of one of them later.
2023-04-05 11:15:55 +09:00
zzak
c3f2b545f8
Introduce markdownlint for guides
This is a follow up to rails#47186, this time for all markdown content.

[markdownlint](https://github.com/markdownlint/markdownlint) is an excellent tool, and I've found it very useful for finding issues in the guides.

Many of the rules are common style issues I'm correcting on PRs, so it will be nice to have that automated.

We should also be able to use the same config with our editors, so that errors show up in real-time 🙏 and will update the contributing docs once this gets merged with how to debug and use mdl appropriately.
2023-03-27 12:14:18 +09:00
zzak
dadf46de36
Add rubocop-md for linting guides snippets 2023-03-15 10:48:19 +09:00
Lázaro Nixon
bde99e52ad
Install dartsass-rails when generating app with sass (#47545) 2023-03-01 06:51:29 +01:00
zzak
263d9ea626 Bump RDoc dependency
While we depend on rdoc through the sdoc gem, it only requires a minimum version.

This may be the cause for #47261 broke edgeapi.rubyonrails.org, those docs are generated with Ruby 2.6 or 2.7.

I'd also like to investigate increasing the Ruby version on the doc server, but I feel that has bigger impact.
2023-02-06 16:28:56 +09:00
Hartley McGuire
106692fb6c
Remove unused sequel gem from Gemfile
It was originally added in 175ba6666453684bba3c24d03b75580a1f8e68bb
as the database driver for Que in the Active Job integration tests.

However, the gem is now unused since the Que adapter and its integration
tests were removed in cb22eb2b3628de428171175063371155d70a136c
2023-01-31 19:13:22 -05:00
zzak
896c7faedf Use Gemfile to manage Rack version for dev 2023-01-25 12:24:19 +09:00
zzak
3503bccec6
Revert "Use eval_gemfile to read .Gemfile" 2023-01-21 10:30:47 +09:00
Sam Bostock
d525d9f4e3
Use eval_gemfile to read .Gemfile
eval_gemfile includes some error handling and management of Bundler's
internal state.
2023-01-17 11:33:26 -05:00
Petrik
34b920e776 Upgrade sdoc to support Ruby 3.2
Add support for Ruby 3.2 as File.exists? has been removed
2023-01-11 12:46:46 +01:00
Hartley McGuire
0d339411e1
Remove sprockets-export from Gemfile
Its usage was removed in 7d116c9 but I forgot to remove it

The other changes come from running bundle install, it looks like they
were supposed to be removed in d9e79ce
2023-01-03 22:56:28 -05:00