Skip to content

Commit

Permalink
add more CI checks, add notice of official Rails 7.1 support (#7)
Browse files Browse the repository at this point in the history
* bump CI to check support for latest Rails (7.1) and Ruby (3.3.0)

* turn of fail-fast for matrix

* fix rspec test to work with AR 7.1+

* Update README.md

* Update README.md
  • Loading branch information
6 committed Apr 10, 2024
1 parent b4aee3a commit d40331b
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 9 deletions.
15 changes: 9 additions & 6 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- ruby-version: "2.6.10"
rails-version: "4.2"
- ruby-version: "2.7.7"
- ruby-version: "2.7.8"
rails-version: "5.2"
- ruby-version: "2.7.7"
- ruby-version: "2.7.8"
rails-version: "6.1"
- ruby-version: "2.7.7"
- ruby-version: "2.7.8"
rails-version: "7.0"
- ruby-version: "3.1.3"
rails-version: "7.0"
- ruby-version: "3.2.0"
- ruby-version: "3.1.4"
rails-version: "7.0"
- ruby-version: "3.2.3"
rails-version: "7.1"
- ruby-version: "3.3.0"
rails-version: "7.1"
services:
postgres:
image: postgres:15
Expand Down
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# activerecord-explain-analyze [![checks](https://github.com/6/activerecord-explain-analyze/actions/workflows/checks.yml/badge.svg)](https://github.com/6/activerecord-explain-analyze/actions/workflows/checks.yml) [![Gem Version](https://badge.fury.io/rb/activerecord-explain-analyze.svg)](https://rubygems.org/gems/activerecord-explain-analyze)
> [!NOTE]
> As of Rails 7.1+, `ActiveRecord#explain` now officially supports analyze options. See the [docs](https://guides.rubyonrails.org/active_record_querying.html#explain-options) and [PR](https://github.com/rails/rails/pull/47043) for details. This rubygem will remain available for older versions of Rails (<= 7.0).
# activerecord-explain-analyze [![checks](https://github.com/6/activerecord-explain-analyze/actions/workflows/checks.yml/badge.svg?branch=main)](https://github.com/6/activerecord-explain-analyze/actions/workflows/checks.yml) [![Gem Version](https://badge.fury.io/rb/activerecord-explain-analyze.svg)](https://rubygems.org/gems/activerecord-explain-analyze)

Extends [`ActiveRecord#explain`](http://guides.rubyonrails.org/active_record_querying.html#running-explain) with support for EXPLAIN ANALYZE and output formats of JSON, XML, and YAML.

It currently has been tested to support:

- ActiveRecord versions 4 through 7
- PostgreSQL only
- Ruby 2.7.x, 3.1.x, and 3.2.x
- Ruby 2.7.x, 3.1.x, 3.2.x, 3.3.x

#### What's EXPLAIN ANALYZE?

Expand Down
7 changes: 6 additions & 1 deletion spec/activerecord-explain-analyze_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@
context "without any args" do
it "returns normal explain output" do
output = Car.where(model: "bmw").explain
expect(output).to start_with(%{EXPLAIN for: SELECT "cars"})
# AR 7.1+ has slightly different output:
if ActiveRecord::VERSION::MAJOR >= 7 && ActiveRecord::VERSION::MINOR >= 1
expect(output).to start_with(%{EXPLAIN SELECT "cars"})
else
expect(output).to start_with(%{EXPLAIN for: SELECT "cars"})
end
expect(output).not_to include("actual time")
end
end
Expand Down
8 changes: 8 additions & 0 deletions spec/support/Gemfile-rails-7.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source 'https://rubygems.org'

gem 'activerecord', '~> 7.1'
gem 'database_cleaner'
gem 'pg'
gem 'pry'
gem 'rake', '~> 13.0'
gem 'rspec', '~> 3.0'

0 comments on commit d40331b

Please sign in to comment.