Skip to content

Commit 43591e4

Browse files
dadachiclaude
andcommitted
Replace Redis/Sidekiq with Solid Queue/Cable/Cache and add CI tooling
- Replace Sidekiq with Solid Queue (database-backed job processing) - Replace Redis-based Action Cable with Solid Cable - Add Solid Cache for production/staging caching - Add Mission Control Jobs dashboard at /madmin/jobs - Add multi-database config for cache, queue, cable databases - Add bin/ci local CI runner and bin/bundler-audit - Update CI workflow: add bundler-audit, RuboCop cache, remove Redis/Node - Remove bin/render-start-sidekiq.sh (Solid Queue runs in Puma) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 467f283 commit 43591e4

29 files changed

Lines changed: 426 additions & 170 deletions

.github/workflows/ci.yml

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010

1111
jobs:
1212
scan_ruby:
13-
timeout-minutes: 10
1413
runs-on: ubuntu-latest
1514

1615
steps:
@@ -25,9 +24,13 @@ jobs:
2524
- name: Scan for common Rails security vulnerabilities
2625
run: bin/brakeman --no-pager
2726

27+
- name: Scan for known security vulnerabilities in gems used
28+
run: bin/bundler-audit
29+
2830
lint:
29-
timeout-minutes: 10
3031
runs-on: ubuntu-latest
32+
env:
33+
RUBOCOP_CACHE_ROOT: tmp/rubocop
3134
steps:
3235
- name: Checkout code
3336
uses: actions/checkout@v4
@@ -37,15 +40,25 @@ jobs:
3740
with:
3841
bundler-cache: true
3942

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

43-
- name: Erb Lint
56+
- name: Lint ERB for consistent style
4457
run: bundle exec erb_lint --lint-all
4558

4659
test:
47-
timeout-minutes: 10
4860
runs-on: ubuntu-latest
61+
4962
services:
5063
postgres:
5164
image: postgres:latest
@@ -59,44 +72,25 @@ jobs:
5972
--health-interval 10s
6073
--health-timeout 5s
6174
--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
7075
7176
steps:
72-
- uses: actions/checkout@v4
77+
- name: Install dependencies
78+
run: sudo apt-get update && sudo apt-get install --no-install-recommends -y libvips
7379

74-
- name: Setup Ruby
80+
- name: Checkout code
81+
uses: actions/checkout@v4
82+
83+
- name: Set up Ruby
7584
uses: ruby/setup-ruby@v1
7685
with:
7786
bundler-cache: true
7887

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-
9188
- name: Run tests
9289
env:
9390
DATABASE_URL: postgres://postgres:password@localhost:5432/test
94-
REDIS_URL: redis://localhost:6379/0
9591
RAILS_ENV: test
9692
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
93+
run: bin/rails db:test:prepare test
10094

10195
- name: Keep screenshots from failed system tests
10296
uses: actions/upload-artifact@v4

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: 13 additions & 6 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.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, 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)
@@ -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: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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,7 +50,6 @@ 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"
@@ -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

Gemfile.lock

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ GEM
113113
brakeman (8.0.4)
114114
racc
115115
builder (3.3.0)
116+
bundler-audit (0.9.3)
117+
bundler (>= 1.2.0)
118+
thor (~> 1.0)
116119
capybara (3.40.0)
117120
addressable
118121
matrix
@@ -162,12 +165,17 @@ GEM
162165
rubocop (>= 1)
163166
smart_properties
164167
erubi (1.13.1)
168+
et-orbi (1.4.0)
169+
tzinfo
165170
ffi (1.17.3-aarch64-linux-gnu)
166171
ffi (1.17.3-arm-linux-gnu)
167172
ffi (1.17.3-arm64-darwin)
168173
ffi (1.17.3-x86-linux-gnu)
169174
ffi (1.17.3-x86_64-darwin)
170175
ffi (1.17.3-x86_64-linux-gnu)
176+
fugit (1.12.1)
177+
et-orbi (~> 1.4)
178+
raabro (~> 1.4)
171179
globalid (1.3.0)
172180
activesupport (>= 6.1)
173181
hashdiff (1.2.1)
@@ -229,6 +237,16 @@ GEM
229237
drb (~> 2.0)
230238
prism (~> 1.5)
231239
minitest-mock (5.27.0)
240+
mission_control-jobs (1.1.0)
241+
actioncable (>= 7.1)
242+
actionpack (>= 7.1)
243+
activejob (>= 7.1)
244+
activerecord (>= 7.1)
245+
importmap-rails (>= 1.2.1)
246+
irb (~> 1.13)
247+
railties (>= 7.1)
248+
stimulus-rails
249+
turbo-rails
232250
msgpack (1.8.0)
233251
net-imap (0.6.3)
234252
date
@@ -285,6 +303,7 @@ GEM
285303
nio4r (~> 2.0)
286304
pundit (2.5.2)
287305
activesupport (>= 3.0.0)
306+
raabro (1.4.0)
288307
racc (1.8.1)
289308
rack (3.2.5)
290309
rack-attack (6.8.0)
@@ -335,10 +354,6 @@ GEM
335354
erb
336355
psych (>= 4.0.0)
337356
tsort
338-
redis (5.4.1)
339-
redis-client (>= 0.22.0)
340-
redis-client (0.27.0)
341-
connection_pool
342357
regexp_parser (2.11.3)
343358
reline (0.6.3)
344359
io-console (~> 0.5)
@@ -390,13 +405,23 @@ GEM
390405
rexml (~> 3.2, >= 3.2.5)
391406
rubyzip (>= 1.2.2, < 4.0)
392407
websocket (~> 1.0)
393-
sidekiq (8.1.1)
394-
connection_pool (>= 3.0.0)
395-
json (>= 2.16.0)
396-
logger (>= 1.7.0)
397-
rack (>= 3.2.0)
398-
redis-client (>= 0.26.0)
399408
smart_properties (1.17.0)
409+
solid_cable (3.0.12)
410+
actioncable (>= 7.2)
411+
activejob (>= 7.2)
412+
activerecord (>= 7.2)
413+
railties (>= 7.2)
414+
solid_cache (1.0.10)
415+
activejob (>= 7.2)
416+
activerecord (>= 7.2)
417+
railties (>= 7.2)
418+
solid_queue (1.3.2)
419+
activejob (>= 7.1)
420+
activerecord (>= 7.1)
421+
concurrent-ruby (>= 1.3.1)
422+
fugit (~> 1.11)
423+
railties (>= 7.1)
424+
thor (>= 1.3.1)
400425
stimulus-rails (1.3.4)
401426
railties (>= 6.0.0)
402427
stringio (3.2.0)
@@ -451,6 +476,7 @@ DEPENDENCIES
451476
after_commit_everywhere (~> 1.4)
452477
bootsnap (>= 1.4.2)
453478
brakeman
479+
bundler-audit
454480
capybara (>= 3.39)
455481
config
456482
cssbundling-rails (~> 1.4.0)
@@ -466,6 +492,7 @@ DEPENDENCIES
466492
madmin!
467493
mailbin
468494
minitest-mock
495+
mission_control-jobs
469496
nokogiri (>= 1.12.5)
470497
overcommit
471498
pagy (~> 9.0)
@@ -476,11 +503,12 @@ DEPENDENCIES
476503
rack-attack
477504
rack-cors
478505
rails (~> 8.1)
479-
redis (~> 5.1)
480506
rubocop-rails-omakase
481507
seed-fu (~> 2.3)
482508
selenium-webdriver (>= 4.20.1)
483-
sidekiq
509+
solid_cable
510+
solid_cache
511+
solid_queue
484512
stimulus-rails (~> 1.0, >= 1.0.2)
485513
turbo-rails (~> 2.0.3)
486514
tzinfo-data

Procfile.dev

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
web: bin/rails server -p $PORT -b 192.168.1.21
22
css: yarn build:css --watch
33
js: yarn build --reload
4-
sidekiq: bundle exec sidekiq -C config/sidekiq.yml

bin/bundler-audit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
require_relative "../config/boot"
3+
require "bundler/audit/cli"
4+
5+
ARGV.concat %w[ --config config/bundler-audit.yml ] if ARGV.empty? || ARGV.include?("check")
6+
Bundler::Audit::CLI.start

bin/ci

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env ruby
2+
require_relative "../config/boot"
3+
require "active_support/continuous_integration"
4+
5+
CI = ActiveSupport::ContinuousIntegration
6+
require_relative "../config/ci.rb"

bin/render-start-sidekiq.sh

Lines changed: 0 additions & 17 deletions
This file was deleted.

bin/render-start.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
# exit on error
44
set -o errexit
55

6+
export SOLID_QUEUE_IN_PUMA=${SOLID_QUEUE_IN_PUMA:-true}
7+
68
if [[ "${IS_PULL_REQUEST}" == "true" ]]; then
79
echo "IS_PULL_REQUEST is set. Setting staging environment variables and starting server."
810
export RAILS_ENV=staging

0 commit comments

Comments
 (0)