Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to SOLID stack #2638

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 1 addition & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,7 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10

services:
postgres:
image: postgres:17-alpine
ports: ['5432:5432']
env:
POSTGRES_PASSWORD: postgres

redis:
image: redis:alpine
ports: ['6379:6379']

env:
DB_HOST: localhost
DB_USER: postgres
DB_PASSWORD: postgres
REDIS_URL: redis://localhost:6379/0
RAILS_ENV: test
CI: true
RUBY_YJIT_ENABLE: 1
Expand Down Expand Up @@ -56,7 +41,7 @@ jobs:
- name: Check for TypeScript errors
run: bin/yarn tsc

- name: Setup PostgreSQL
- name: Setup Database
run: bin/rails db:create

- name: Compile assets
Expand Down
3 changes: 3 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ AllCops:
- bin/**/*
- coverage/**/*
- db/schema.rb
- db/cable_schema.rb
- db/cache_schema.rb
- db/queue_schema.rb
- db/migrate/**/*
- log/**/*
- node_modules/**/*
Expand Down
2 changes: 0 additions & 2 deletions Brewfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
brew 'puma/puma/puma-dev'
brew 'postgresql@17'
brew 'redis'
brew 'overmind'
21 changes: 12 additions & 9 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,27 @@ gem 'phlex-rails'
# Heroicons extension for Phlex (https://github.com/nejdetkadir/phlex-heroicons)
gem 'phlex-heroicons', github: 'nejdetkadir/phlex-heroicons'

# Pg is the Ruby interface to the PostgreSQL RDBMS (https://github.com/ged/ruby-pg)
gem 'pg', '~> 1.1'
# Ruby library to interface with the SQLite3 database engine (http://www.sqlite.org). (https://github.com/sparklemotion/sqlite3-ruby)
gem 'sqlite3', '>= 2.1'

# Puma is a simple, fast, threaded, and highly parallel HTTP 1.1 server for Ruby/Rack applications (https://puma.io)
# A Ruby/Rack web server built for parallelism. (https://puma.io)
gem 'puma', '>= 5.0'

# A database backed ActiveSupport::Cache::Store (http://github.com/rails/solid_cache)
gem 'solid_cache'

# Database-backed Active Job backend. (https://github.com/rails/solid_queue)
gem 'solid_queue'

# Database-backed Action Cable backend. (https://github.com/rails/solid_cable)
gem 'solid_cable'

# Boot large ruby/rails apps faster (https://github.com/Shopify/bootsnap)
gem 'bootsnap', '>= 1.4.4', require: false

# Timezone Data for TZInfo (https://tzinfo.github.io)
gem 'tzinfo-data', platforms: %i[windows jruby]

# A Ruby client library for Redis (https://github.com/redis/redis-rb)
gem 'redis', '>= 4.0.1'

# Tame Rails' multi-line logging into a single line per request (https://github.com/roidrage/lograge)
gem 'lograge'

Expand All @@ -47,9 +53,6 @@ gem 'rack-canonical-host'
# Brotli compression for Rack responses (http://github.com/marcotc/rack-brotli/)
gem 'rack-brotli'

# Simple, efficient background processing for Ruby (https://sidekiq.org)
gem 'sidekiq'

# Lock staging servers from search engines and prying eyes. (http://lockup.interdiscipline.com)
gem 'lockup', github: 'interdiscipline/lockup'

Expand Down
43 changes: 29 additions & 14 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ GEM
drb (2.2.1)
dry-cli (1.2.0)
erubi (1.13.1)
et-orbi (1.2.11)
tzinfo
factory_bot (6.5.0)
activesupport (>= 5.0.0)
factory_bot_rails (6.4.4)
Expand All @@ -134,6 +136,9 @@ GEM
ffi (1.17.1-x86_64-linux-gnu)
ffi (1.17.1-x86_64-linux-musl)
formatador (1.1.0)
fugit (1.11.1)
et-orbi (~> 1, >= 1.2.11)
raabro (~> 1.4)
globalid (1.2.1)
activesupport (>= 6.1)
guard (2.19.1)
Expand Down Expand Up @@ -226,7 +231,6 @@ GEM
parser (3.3.7.0)
ast (~> 2.4.1)
racc
pg (1.5.9)
phlex (1.11.0)
phlex-rails (1.2.2)
phlex (>= 1.10, < 2)
Expand All @@ -240,6 +244,7 @@ GEM
public_suffix (6.0.1)
puma (6.5.0)
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.8.1)
rack (3.1.8)
rack-brotli (2.0.0)
Expand Down Expand Up @@ -296,10 +301,6 @@ GEM
rdoc (6.11.0)
psych (>= 4.0.0)
redcarpet (3.6.0)
redis (5.3.0)
redis-client (>= 0.22.0)
redis-client (0.23.2)
connection_pool
regexp_parser (2.10.0)
reline (0.6.0)
io-console (~> 0.5)
Expand Down Expand Up @@ -361,18 +362,31 @@ GEM
ruby-progressbar (1.13.0)
securerandom (0.4.1)
shellany (0.0.1)
sidekiq (7.3.8)
base64
connection_pool (>= 2.3.0)
logger
rack (>= 2.2.4)
redis-client (>= 0.22.2)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
solid_cable (3.0.5)
actioncable (>= 7.2)
activejob (>= 7.2)
activerecord (>= 7.2)
railties (>= 7.2)
solid_cache (1.0.6)
activejob (>= 7.2)
activerecord (>= 7.2)
railties (>= 7.2)
solid_queue (1.1.2)
activejob (>= 7.1)
activerecord (>= 7.1)
concurrent-ruby (>= 1.3.1)
fugit (~> 1.11.0)
railties (>= 7.1)
thor (~> 1.3.1)
sqlite3 (2.5.0-arm64-darwin)
sqlite3 (2.5.0-x86_64-linux-gnu)
sqlite3 (2.5.0-x86_64-linux-musl)
stimulus-rails (1.3.4)
railties (>= 6.0.0)
stringio (3.1.2)
Expand Down Expand Up @@ -436,15 +450,13 @@ DEPENDENCIES
lograge
lookbook
ostruct
pg (~> 1.1)
phlex-heroicons!
phlex-rails
puma (>= 5.0)
rack-brotli
rack-canonical-host
rack-cors
rails (~> 8.0.0)
redis (>= 4.0.1)
rexml
rorvswild
rspec-rails
Expand All @@ -455,8 +467,11 @@ DEPENDENCIES
rubocop-rails
rubocop-rspec
rubocop-rspec_rails
sidekiq
simplecov
solid_cable
solid_cache
solid_queue
sqlite3 (>= 2.1)
stimulus-rails
turbo-rails
tzinfo-data
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ There are two sister repositories:
- [Ruby](https://www.ruby-lang.org/de/) 3.4
- [Ruby on Rails](https://rubyonrails.org/) 8.0
- [ActionCable](https://guides.rubyonrails.org/action_cable_overview.html) for WebSocket communication
- [PostgreSQL](https://www.postgresql.org/) for using as SQL database
- [Sidekiq](https://sidekiq.org/) for background processing
- [Redis](https://redis.io/) for Caching, ActionCable, and Sidekiq
- [SQLite](https://www.sqlite.org/) for using as SQL database
- [SolideQueue](https://github.com/rails/solid_queue) for background processing

### Frontend

Expand Down Expand Up @@ -175,7 +174,7 @@ git clone [email protected]:templatus/templatus-hotwire.git
cd templatus-hotwire
```

2. Install PostgreSQL, Redis, and puma-dev (if not already present). On a Mac with HomeBrew, run this to install from the `Brewfile`:
2. Install puma-dev (if not already present). On a Mac with HomeBrew, run this to install from the `Brewfile`:

```bash
brew bundle
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/cypress/cleanup_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ def destroy
tables.delete 'schema_migrations'
tables.each do |table|
sanitized_table = ActiveRecord::Base.connection.quote_table_name(table)
ActiveRecord::Base.connection.execute(
"TRUNCATE #{sanitized_table} CASCADE",
)
ActiveRecord::Base.connection.execute("DELETE FROM #{sanitized_table}")
end

head :ok
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/application_job.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class ApplicationJob < ActiveJob::Base
# Automatically retry jobs that encountered a deadlock
# retry_on ActiveRecord::Deadlocked
#

# Most jobs are safe to ignore if the underlying records are no longer available
# discard_on ActiveJob::DeserializationError
end
4 changes: 2 additions & 2 deletions app/models/click.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# Table name: clicks
#
# id :bigint not null, primary key
# ip :inet not null
# id :integer not null, primary key
# ip :string not null
# user_agent :string not null
# created_at :datetime not null
#
Expand Down
49 changes: 4 additions & 45 deletions app/views/components/about_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,26 +54,10 @@ def feature(item)

dd(class: 'mt-2 text-base text-gray-600 ml-9') do
plain item[:description]

sidekiq_link if item[:gem] == 'sidekiq'
end
end
end

def sidekiq_link
p(class: 'mt-2 text-xs') do
plain ' → '

a(
href: sidekiq_web_path,
class: 'font-medium uppercase hover:underline',
data: {
turbo: false,
},
) { 'Admin frontend' }
end
end

FEATURES = [
{
name: 'The backend',
Expand All @@ -93,10 +77,10 @@ def sidekiq_link
'Rails is a web application development framework written in the Ruby programming language. It is designed to make programming web applications easier by making assumptions about what every developer needs to get started.',
},
{
name: 'PostgreSQL',
href: 'https://www.postgresql.org/',
name: 'SQLite',
href: 'https://www.sqlite.org/',
description:
'PostgreSQL is a powerful, open source object-relational database system with over 30 years of active development that has earned it a strong reputation for reliability, feature robustness, and performance.',
'SQLite is a C-language library that implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine. SQLite is the most used database engine in the world. ',
},
{
name: 'Puma',
Expand All @@ -105,18 +89,6 @@ def sidekiq_link
description:
'Puma is a simple, fast, multi-threaded, and highly concurrent HTTP 1.1 server for Ruby/Rack applications.',
},
{
name: 'Redis',
href: 'https://redis.io/',
description:
'Redis is an open source, in-memory data structure store, used as a database, cache, and message broker.',
},
{
name: 'Sidekiq',
gem: 'sidekiq',
href: 'https://sidekiq.org/',
description: 'Simple, efficient background processing for Ruby',
},
],
},
{
Expand Down Expand Up @@ -251,14 +223,6 @@ def alpine_version
# :nocov:
end

def postgres_version
ActiveRecord::Base.connection.select_value('SHOW server_version;')
end

def redis_version
Redis.new.info['redis_version']
end

def ruby_version
RUBY_VERSION
end
Expand All @@ -272,12 +236,7 @@ def external_version(name)
Rails
.cache
.fetch('versions', expires_in: 1.hour) do
{
'Alpine Linux' => alpine_version,
'PostgreSQL' => postgres_version,
'Redis' => redis_version,
'Ruby' => ruby_version,
}
{ 'Alpine Linux' => alpine_version, 'Ruby' => ruby_version }
end

@external_version[name]
Expand Down
6 changes: 6 additions & 0 deletions bin/jobs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env ruby

require_relative '../config/environment'
require 'solid_queue/cli'

SolidQueue::Cli.start(ARGV)
Loading
Loading