Skip to content

Commit 8bd0dcf

Browse files
authored
Merge pull request #17 from nativeapptemplate/upgrade_rails_8_1
Upgrade Rails to 8.1 and replace Redis/Sidekiq with Solid*
2 parents 8687e58 + aa83378 commit 8bd0dcf

57 files changed

Lines changed: 673 additions & 1686 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 28 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,16 @@ name: CI
22

33
on:
44
pull_request:
5-
branches:
6-
- '*'
75
push:
8-
branches:
9-
- main
6+
branches: [ main ]
107

118
jobs:
129
scan_ruby:
13-
timeout-minutes: 10
1410
runs-on: ubuntu-latest
1511

1612
steps:
1713
- name: Checkout code
18-
uses: actions/checkout@v4
14+
uses: actions/checkout@v6
1915

2016
- name: Set up Ruby
2117
uses: ruby/setup-ruby@v1
@@ -25,27 +21,41 @@ jobs:
2521
- name: Scan for common Rails security vulnerabilities
2622
run: bin/brakeman --no-pager
2723

24+
- name: Scan for known security vulnerabilities in gems used
25+
run: bin/bundler-audit
26+
2827
lint:
29-
timeout-minutes: 10
3028
runs-on: ubuntu-latest
29+
env:
30+
RUBOCOP_CACHE_ROOT: tmp/rubocop
3131
steps:
3232
- name: Checkout code
33-
uses: actions/checkout@v4
33+
uses: actions/checkout@v6
3434

3535
- name: Set up Ruby
3636
uses: ruby/setup-ruby@v1
3737
with:
3838
bundler-cache: true
3939

40+
- name: Prepare RuboCop cache
41+
uses: actions/cache@v5
42+
env:
43+
DEPENDENCIES_HASH: ${{ hashFiles('.ruby-version', '**/.rubocop.yml', 'Gemfile.lock') }}
44+
with:
45+
path: ${{ env.RUBOCOP_CACHE_ROOT }}
46+
key: rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-${{ github.ref_name == github.event.repository.default_branch && github.run_id || 'default' }}
47+
restore-keys: |
48+
rubocop-${{ runner.os }}-${{ env.DEPENDENCIES_HASH }}-
49+
4050
- name: Lint code for consistent style
4151
run: bin/rubocop -f github
4252

43-
- name: Erb Lint
53+
- name: Lint ERB for consistent style
4454
run: bundle exec erb_lint --lint-all
4555

4656
test:
47-
timeout-minutes: 10
4857
runs-on: ubuntu-latest
58+
4959
services:
5060
postgres:
5161
image: postgres:latest
@@ -59,47 +69,27 @@ jobs:
5969
--health-interval 10s
6070
--health-timeout 5s
6171
--health-retries 5
62-
redis:
63-
image: redis
64-
ports: ['6379:6379']
65-
options: >-
66-
--health-cmd "redis-cli ping"
67-
--health-interval 10s
68-
--health-timeout 5s
69-
--health-retries 5
70-
7172
steps:
72-
- uses: actions/checkout@v4
73+
- name: Install dependencies
74+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libvips
7375

74-
- name: Setup Ruby
76+
- name: Checkout code
77+
uses: actions/checkout@v6
78+
79+
- name: Set up Ruby
7580
uses: ruby/setup-ruby@v1
7681
with:
7782
bundler-cache: true
7883

79-
- name: Setup Node
80-
uses: actions/setup-node@v4
81-
with:
82-
node-version-file: '.node-version'
83-
cache: yarn
84-
85-
- name: Install dependencies
86-
run: |
87-
sudo apt-get update
88-
sudo apt-get install -y -qq libvips
89-
yarn install --frozen-lockfile
90-
9184
- name: Run tests
9285
env:
9386
DATABASE_URL: postgres://postgres:password@localhost:5432/test
94-
REDIS_URL: redis://localhost:6379/0
9587
RAILS_ENV: test
9688
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
97-
run: |
98-
# bin/rails zeitwerk:check test:prepare db:test:prepare test
99-
bin/rails test:prepare db:test:prepare test
89+
run: bin/rails db:test:prepare test
10090

10191
- name: Keep screenshots from failed system tests
102-
uses: actions/upload-artifact@v4
92+
uses: actions/upload-artifact@v6
10393
if: failure()
10494
with:
10595
name: screenshots

.gitignore

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
/public/assets
3333
/app/assets/builds/*
3434
!/app/assets/builds/.keep
35-
/node_modules
3635

3736
# Ignore master key for decrypting credentials and more.
3837
/config/master.key
@@ -42,9 +41,6 @@
4241

4342
# Ignore other files
4443
.byebug_history
45-
yarn-error.log
46-
yarn-debug.log*
47-
.yarn-integrity
4844
.DS_Store
4945
.idea
5046
*~

.node-version

Lines changed: 0 additions & 1 deletion
This file was deleted.

.rubocop.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -787,9 +787,6 @@ Lint/SuppressedException:
787787
Lint/SymbolConversion:
788788
Enabled: true
789789

790-
Lint/Syntax:
791-
Enabled: true
792-
793790
Lint/ToEnumArguments:
794791
Enabled: false
795792

Brewfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22
brew "postgresql@16"
33
brew "libpq"
44

5-
# Redis - For ActionCable support (and Sidekiq, caching, etc)
6-
brew "redis"
7-
85
# Overmind (requires tmux)
96
brew "tmux"
107
brew "overmind"

CLAUDE.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
44

55
## Project Overview
66

7-
This is a Rails 8.0 API application that serves as the backend for NativeAppTemplate iOS/Android mobile applications. It's a multi-tenant SaaS application with token-based authentication, role-based authorization, and RESTful API endpoints. Ruby 4.0.1, PostgreSQL, Redis, Sidekiq.
7+
This is a Rails 8.1 API application that serves as the backend for NativeAppTemplate iOS/Android mobile applications. It's a multi-tenant SaaS application with token-based authentication, role-based authorization, and RESTful API endpoints. Ruby 4.0.1, PostgreSQL, Solid Queue/Cable/Cache.
88

99
## Development Commands
1010

@@ -15,7 +15,7 @@ bin/setup # Installs all dependencies, prepares database, builds assets
1515

1616
### Running the Application
1717
```bash
18-
bin/dev # Starts Rails server, CSS watcher, JS bundler, and Sidekiq workers
18+
bin/dev # Starts Rails server, CSS watcher, JS bundler
1919
```
2020

2121
### Testing
@@ -30,6 +30,12 @@ bin/rails test test/path/to/test.rb:42 # Run specific test line
3030
bin/rubocop # Ruby code linting
3131
bundle exec erb_lint --lint-all # ERB template linting
3232
bin/brakeman # Security vulnerability scanning
33+
bin/bundler-audit # Audit gems for known security defects
34+
```
35+
36+
### Local CI
37+
```bash
38+
bin/ci # Runs setup, rubocop, bundler-audit, brakeman, tests, and seeds
3339
```
3440

3541
### Database Operations
@@ -69,9 +75,10 @@ bin/rails dbconsole # Database console
6975
- State machines implemented with AASM gem
7076

7177
### Background Processing
72-
- Sidekiq for background jobs with Redis backend
73-
- Queue priorities: critical (10), mailers (5), default (2), low (1)
74-
- Monitor at `/madmin/sidekiq` in development
78+
- Solid Queue for background jobs (database-backed, no Redis needed)
79+
- Solid Cable for Action Cable (database-backed)
80+
- Solid Cache for caching in production/staging
81+
- Monitor jobs at `/madmin/jobs` (Mission Control)
7582

7683
### Testing Strategy
7784
- Minitest for all tests (models, controllers, integration, policies)
@@ -92,7 +99,7 @@ bin/rails dbconsole # Database console
9299
- Server binds to specific IP: `192.168.1.21:3000` (not localhost)
93100
- Mailbin for email testing at `/mailbin`
94101
- Admin interface at `/madmin`
95-
- Hot reload for CSS/JS changes via yarn watchers
102+
- Tailwind CSS compiled by tailwindcss-rails gem
96103

97104
### Important Conventions
98105
- Use `seed-fu` for database seeding (not standard Rails seeds)
@@ -105,7 +112,7 @@ bin/rails dbconsole # Database console
105112
- Configured for Render.com deployment
106113
- Build script: `bin/render-build.sh`
107114
- Web server: `bin/render-start.sh`
108-
- Background workers: `bin/render-start-sidekiq.sh`
115+
- Solid Queue runs in Puma via `SOLID_QUEUE_IN_PUMA=true`
109116

110117
## Code Quality Checks Before Committing
111118

Gemfile

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
44
ruby file: ".ruby-version"
55

66
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
7-
gem "rails", "~> 8.0.0"
7+
gem "rails", "~> 8.1"
88

99
gem "propshaft", "~> 1.0"
1010

1111
# Use postgresql as the database for Active Record
1212
gem "pg"
1313

1414
# Use the Puma web server [https://github.com/puma/puma]
15-
gem "puma", "~> 6.0"
15+
gem "puma", "~> 7.0"
1616

1717
# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
1818
gem "turbo-rails", "~> 2.0.3"
@@ -23,11 +23,11 @@ gem "stimulus-rails", "~> 1.0", ">= 1.0.2"
2323
# Build JSON APIs with ease [https://github.com/rails/jbuilder]
2424
gem "jbuilder", "~> 2.12"
2525

26-
# Use Redis adapter to run Action Cable in production
27-
gem "redis", "~> 5.1"
28-
29-
# Use Kredis to get higher-level data types in Redis [https://github.com/rails/kredis]
30-
# gem "kredis"
26+
# Solid adapters for queue, cache, and cable (database-backed, no Redis needed)
27+
gem "solid_queue"
28+
gem "solid_cable"
29+
gem "solid_cache"
30+
gem "mission_control-jobs"
3131

3232
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
3333
gem "tzinfo-data", platforms: %i[windows jruby]
@@ -50,16 +50,15 @@ gem "aasm"
5050
# https://github.com/aasm/aasm
5151
gem "after_commit_everywhere", "~> 1.4"
5252
gem "config"
53-
gem "sidekiq"
5453
gem "acts_as_tenant"
5554
gem "inline_svg", "~> 1.6"
5655
gem "pagy", "~> 9.0"
5756
gem "seed-fu", "~> 2.3"
5857
gem "whenever", require: false
5958
gem "madmin", github: "excid3/madmin"
6059
gem "valid_email2"
61-
gem "cssbundling-rails", "~> 1.4.0"
62-
gem "jsbundling-rails", "~> 1.3.0"
60+
gem "importmap-rails"
61+
gem "tailwindcss-rails", "~> 3.0"
6362
gem "rack-attack"
6463
# Fix LoadError: cannot load such file -- csv
6564
gem "csv", "~> 3.3"
@@ -68,6 +67,9 @@ group :development, :test do
6867
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
6968
gem "debug", platforms: %i[mri windows]
7069

70+
# Audits gems for known security defects (use config/bundler-audit.yml to ignore issues)
71+
gem "bundler-audit", require: false
72+
7173
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
7274
gem "brakeman", require: false
7375

@@ -78,8 +80,8 @@ group :development, :test do
7880

7981
gem "mailbin"
8082

81-
# Constrain minitest to 5.x for Rails 7.2 compatibility
82-
gem "minitest", "~> 5.0"
83+
# minitest 6.x extracted mock to a separate gem
84+
gem "minitest-mock"
8385

8486
# Optional debugging tools
8587
# gem "byebug", platforms: [:mri, :mingw, :x64_mingw]

0 commit comments

Comments
 (0)