diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..5caab99 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,31 @@ +name: CI + +on: + push: + branches: [main] + pull_request: + +jobs: + test: + name: Ruby ${{ matrix.ruby }} / Rails ${{ matrix.rails }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + ruby: ["3.2", "3.3", "3.4", "4.0"] + rails: ["7.1", "7.2", "8.0", "8.1"] + env: + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails }}.gemfile + steps: + - uses: actions/checkout@v4 + - uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Prepare dummy app database + run: bundle exec rails db:schema:load + working-directory: test/dummy + env: + RAILS_ENV: test + - name: Run tests + run: bundle exec rake test diff --git a/.gitignore b/.gitignore index fb43abb..c47b878 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ *.rbc .rspec_status Gemfile.lock +/gemfiles/*.lock # Dummy app /test/dummy/log/* diff --git a/.okf/development/testing-conventions.md b/.okf/development/testing-conventions.md index 6d69d6e..844a23c 100644 --- a/.okf/development/testing-conventions.md +++ b/.okf/development/testing-conventions.md @@ -33,5 +33,21 @@ so hidden fixtures leak between tests and only fail under some seeds. # Running `bundle exec rake test`, against `test/dummy` (part of the test setup; never delete it). Prepare -its DB with `cd test/dummy && bin/rails db:prepare`. Database pitfalls are in +the test DB with `cd test/dummy && RAILS_ENV=test bin/rails db:schema:load` — **not** `db:prepare`, +which also runs `db/seeds.rb` on a fresh DB; the self-contained tests assume an empty DB and ~30 of +them fail against seeded data. Database pitfalls are in [dev-reload gotchas](/development/dev-reload-gotchas.md). + +# CI matrix + +`.github/workflows/ci.yml` runs the suite on Ruby 3.2–4.0 × Rails 7.1–8.1 (Ruby 3.1 is out: +Phlex 2.x needs 3.2+). Each Rails version has `gemfiles/rails_X.Y.gemfile`, which pins `rails` +and `eval_gemfile`s the root `Gemfile` so the dev/test groups (RubyUI, auth adapters, kramdown…) +stay in one place. + +Keeping the dummy app loadable on the oldest Rails in the matrix: + +- `test/dummy/db/schema.rb` is pinned to `ActiveRecord::Schema[7.1]`. A schema dumped by a newer + Rails rewrites the header (`Schema[8.1]`), which Rails 7.1–8.0 reject (`Unknown version`). +- `config.load_defaults [Rails::VERSION::STRING.to_f, 7.2].min` — 7.2 is what the suite was + written against, and Rails 7.1 doesn't know `load_defaults 7.2`. diff --git a/.okf/log.md b/.okf/log.md index ce7910b..3e1263f 100644 --- a/.okf/log.md +++ b/.okf/log.md @@ -1,6 +1,10 @@ # Update Log ## 2026-11-13 +* **Update**: [testing conventions](/development/testing-conventions.md) — CI matrix (Ruby 3.2–4.0 × + Rails 7.1–8.1), per-Rails gemfiles, `db:schema:load` instead of `db:prepare` for the test DB, and + the dummy-app constraints (`Schema[7.1]`, capped `load_defaults`). + * **Creation**: initial bundle produced from an analysis of the gem's code (v0.1.1) and its `CLAUDE.md` — architecture, DSL, authorization, frontend and development areas. See [index](/index.md). diff --git a/CHANGELOG.md b/CHANGELOG.md index 4b93ab8..0158d6d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added + +- CI on GitHub Actions: the full test suite runs on Ruby 3.2, 3.3, 3.4 and 4.0 × Rails 7.1, 7.2, + 8.0 and 8.1 (`gemfiles/rails_X.Y.gemfile`). Documented in the README's compatibility matrix. + ## [0.1.1] - 2026-11-12 ### Changed diff --git a/CLAUDE.md b/CLAUDE.md index 86e591b..445fc94 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -36,7 +36,16 @@ bundle exec rake test ``` The suite runs against the dummy app in `test/dummy` (which is part of the test setup — do -not delete it). To prepare its database: `cd test/dummy && bin/rails db:prepare`. +not delete it). To prepare its database: `cd test/dummy && RAILS_ENV=test bin/rails db:schema:load` +(not `db:prepare` for the test DB: it also runs `db/seeds.rb`, and the suite expects an empty DB). + +**CI matrix** (`.github/workflows/ci.yml`): Ruby 3.2–4.0 × Rails 7.1–8.1, one Gemfile per Rails +version in `gemfiles/rails_X.Y.gemfile` (each pins `rails` and `eval_gemfile`s the root `Gemfile`). +Locally: `BUNDLE_GEMFILE=gemfiles/rails_7.1.gemfile bundle install && … bundle exec rake test`. +To keep the dummy app loadable on every Rails in the matrix: +- `test/dummy/db/schema.rb` must stay `ActiveRecord::Schema[7.1]` — dumping it from a newer Rails + rewrites the header (e.g. `Schema[8.1]`), which older Rails can't load. Fix the header back. +- `config.load_defaults` in `test/dummy/config/application.rb` is `[Rails version, 7.2].min`. ## Dummy app & assets gotchas diff --git a/README.md b/README.md index a8c4cb5..e4370e2 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # RubyUI Admin +[![CI](https://github.com/jacksonpires/ruby_ui_admin/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/jacksonpires/ruby_ui_admin/actions/workflows/ci.yml) + `ruby_ui_admin` is a Rails admin dashboard engine, rendered with [RubyUI](https://rubyui.com) (Phlex) components, that even serves its own documentation as HTML inside your app at `/docs` (e.g. `/admin/docs`). @@ -46,15 +48,34 @@ This makes the admin part of your app's UI rather than a self-contained bundle. ### Compatibility -Tested on **2026-11-10** with the latest releases; the full test suite (252 tests) passes on every -combination below: +| Dependency | Gem requirement | +| ----------- | --------------- | +| Ruby | `>= 3.2` | +| Rails | `>= 7.1` | +| Phlex | phlex-rails `>= 2.0` (tested with Phlex **2.4.1** / phlex-rails **2.4.0**) | +| RubyUI | **1.6.x** components in the host app (tested with **1.6.0**) | + +#### CI matrix + +The full test suite (252 tests) runs in CI against every combination below. + +| Ruby \ Rails | 7.1 | 7.2 | 8.0 | 8.1 | +|--------------|:---:|:---:|:---:|:---:| +| **4.0** | ✅ | ✅ | ✅ | ✅ | +| **3.4** | ✅ | ✅ | ✅ | ✅ | +| **3.3** | ✅ | ✅ | ✅ | ✅ | +| **3.2** | ✅ | ✅ | ✅ | ✅ | + +Ruby 3.1 isn't supported because Phlex 2.x (required by `phlex-rails >= 2.0`) needs Ruby 3.2+. -| Dependency | Tested versions | Gem requirement | -| ----------- | ------------------- | --------------- | -| Ruby | 3.4.4, **4.0.9** | `>= 3.2` | -| Rails | **8.1.4.1** | `>= 7.1` | -| Phlex | **2.4.1** (phlex-rails **2.4.0**) | phlex-rails `>= 2.0` | -| RubyUI | **1.6.0** | 1.6.x components in the host app | +To run the suite against a specific Rails version locally: + +```bash +export BUNDLE_GEMFILE=gemfiles/rails_8.1.gemfile +bundle install +(cd test/dummy && RAILS_ENV=test bin/rails db:schema:load) +bundle exec rake test +``` > **RubyUI's unreleased `main` is not supported yet.** It rewrites the `Combobox` family > (`ComboboxPopover`, `ComboboxTrigger`, … are removed), which the admin's filter bar and diff --git a/gemfiles/rails_7.1.gemfile b/gemfiles/rails_7.1.gemfile new file mode 100644 index 0000000..045c666 --- /dev/null +++ b/gemfiles/rails_7.1.gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rails", "~> 7.1.0" + +# Shared development/test dependencies (dummy app, RubyUI, authorization adapters, docs viewer). +eval_gemfile "../Gemfile" diff --git a/gemfiles/rails_7.2.gemfile b/gemfiles/rails_7.2.gemfile new file mode 100644 index 0000000..5bd57d1 --- /dev/null +++ b/gemfiles/rails_7.2.gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rails", "~> 7.2.0" + +# Shared development/test dependencies (dummy app, RubyUI, authorization adapters, docs viewer). +eval_gemfile "../Gemfile" diff --git a/gemfiles/rails_8.0.gemfile b/gemfiles/rails_8.0.gemfile new file mode 100644 index 0000000..af9ced9 --- /dev/null +++ b/gemfiles/rails_8.0.gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rails", "~> 8.0.0" + +# Shared development/test dependencies (dummy app, RubyUI, authorization adapters, docs viewer). +eval_gemfile "../Gemfile" diff --git a/gemfiles/rails_8.1.gemfile b/gemfiles/rails_8.1.gemfile new file mode 100644 index 0000000..2012b76 --- /dev/null +++ b/gemfiles/rails_8.1.gemfile @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gem "rails", "~> 8.1.0" + +# Shared development/test dependencies (dummy app, RubyUI, authorization adapters, docs viewer). +eval_gemfile "../Gemfile" diff --git a/test/dummy/config/application.rb b/test/dummy/config/application.rb index dd29655..8b183dd 100644 --- a/test/dummy/config/application.rb +++ b/test/dummy/config/application.rb @@ -13,7 +13,8 @@ module Dummy class Application < Rails::Application - config.load_defaults 7.2 + # Never above 7.2 (what the suite was written against), but no higher than the running Rails. + config.load_defaults [Rails::VERSION::STRING.to_f, 7.2].min config.eager_load = false config.consider_all_requests_local = true diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 0291f6b..3a7d2db 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[8.1].define(version: 2026_01_01_000008) do +ActiveRecord::Schema[7.1].define(version: 2026_01_01_000008) do create_table "active_storage_attachments", force: :cascade do |t| t.integer "blob_id", null: false t.datetime "created_at", null: false