crspec 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +67 -17
  3. data/benchmark/README.md +56 -0
  4. data/benchmark/run.rb +72 -0
  5. data/benchmark/spec/user_service_crspec_spec.rb +15 -0
  6. data/benchmark/spec/user_service_rspec_spec.rb +16 -0
  7. data/benchmark/target_service.rb +12 -0
  8. data/benchmark/test/user_service_test.rb +18 -0
  9. data/demo.rb +6 -3
  10. data/lib/crspec/cli.rb +34 -3
  11. data/lib/crspec/configuration.rb +59 -0
  12. data/lib/crspec/example_group.rb +31 -0
  13. data/lib/crspec/execution_context.rb +1 -1
  14. data/lib/crspec/generators/init.rb +94 -0
  15. data/lib/crspec/matchers.rb +55 -0
  16. data/lib/crspec/mock/double.rb +8 -1
  17. data/lib/crspec/rails/database_isolation.rb +6 -15
  18. data/lib/crspec/rails/parallel.rb +1 -1
  19. data/lib/crspec/rails/request_helpers.rb +96 -0
  20. data/lib/crspec/transpiler/cli.rb +6 -6
  21. data/lib/crspec/version.rb +1 -1
  22. data/lib/crspec.rb +3 -0
  23. data/samples/book_store/.dockerignore +51 -0
  24. data/samples/book_store/.gitattributes +9 -0
  25. data/samples/book_store/.github/dependabot.yml +12 -0
  26. data/samples/book_store/.github/workflows/ci.yml +130 -0
  27. data/samples/book_store/.gitignore +35 -0
  28. data/samples/book_store/.kamal/hooks/docker-setup.sample +3 -0
  29. data/samples/book_store/.kamal/hooks/post-app-boot.sample +3 -0
  30. data/samples/book_store/.kamal/hooks/post-deploy.sample +14 -0
  31. data/samples/book_store/.kamal/hooks/post-proxy-reboot.sample +3 -0
  32. data/samples/book_store/.kamal/hooks/pre-app-boot.sample +3 -0
  33. data/samples/book_store/.kamal/hooks/pre-build.sample +51 -0
  34. data/samples/book_store/.kamal/hooks/pre-connect.sample +47 -0
  35. data/samples/book_store/.kamal/hooks/pre-deploy.sample +122 -0
  36. data/samples/book_store/.kamal/hooks/pre-proxy-reboot.sample +3 -0
  37. data/samples/book_store/.kamal/secrets +20 -0
  38. data/samples/book_store/.rubocop.yml +8 -0
  39. data/samples/book_store/.ruby-version +1 -0
  40. data/samples/book_store/Dockerfile +77 -0
  41. data/samples/book_store/Gemfile +67 -0
  42. data/samples/book_store/Gemfile.lock +572 -0
  43. data/samples/book_store/README.md +24 -0
  44. data/samples/book_store/Rakefile +6 -0
  45. data/samples/book_store/app/assets/images/.keep +0 -0
  46. data/samples/book_store/app/assets/stylesheets/application.css +10 -0
  47. data/samples/book_store/app/controllers/application_controller.rb +2 -0
  48. data/samples/book_store/app/controllers/books_controller.rb +30 -0
  49. data/samples/book_store/app/controllers/comments_controller.rb +21 -0
  50. data/samples/book_store/app/controllers/concerns/.keep +0 -0
  51. data/samples/book_store/app/controllers/users_controller.rb +21 -0
  52. data/samples/book_store/app/helpers/application_helper.rb +2 -0
  53. data/samples/book_store/app/helpers/books_helper.rb +2 -0
  54. data/samples/book_store/app/helpers/comments_helper.rb +2 -0
  55. data/samples/book_store/app/helpers/users_helper.rb +2 -0
  56. data/samples/book_store/app/javascript/application.js +3 -0
  57. data/samples/book_store/app/javascript/controllers/application.js +9 -0
  58. data/samples/book_store/app/javascript/controllers/hello_controller.js +7 -0
  59. data/samples/book_store/app/javascript/controllers/index.js +4 -0
  60. data/samples/book_store/app/jobs/application_job.rb +7 -0
  61. data/samples/book_store/app/mailers/application_mailer.rb +4 -0
  62. data/samples/book_store/app/models/application_record.rb +3 -0
  63. data/samples/book_store/app/models/book.rb +10 -0
  64. data/samples/book_store/app/models/comment.rb +6 -0
  65. data/samples/book_store/app/models/concerns/.keep +0 -0
  66. data/samples/book_store/app/models/user.rb +4 -0
  67. data/samples/book_store/app/views/layouts/application.html.erb +29 -0
  68. data/samples/book_store/app/views/layouts/mailer.html.erb +13 -0
  69. data/samples/book_store/app/views/layouts/mailer.text.erb +1 -0
  70. data/samples/book_store/app/views/pwa/manifest.json.erb +22 -0
  71. data/samples/book_store/app/views/pwa/service-worker.js +26 -0
  72. data/samples/book_store/bin/brakeman +7 -0
  73. data/samples/book_store/bin/bundler-audit +6 -0
  74. data/samples/book_store/bin/ci +6 -0
  75. data/samples/book_store/bin/dev +2 -0
  76. data/samples/book_store/bin/docker-entrypoint +8 -0
  77. data/samples/book_store/bin/importmap +4 -0
  78. data/samples/book_store/bin/jobs +6 -0
  79. data/samples/book_store/bin/kamal +16 -0
  80. data/samples/book_store/bin/rails +4 -0
  81. data/samples/book_store/bin/rake +4 -0
  82. data/samples/book_store/bin/rubocop +8 -0
  83. data/samples/book_store/bin/setup +35 -0
  84. data/samples/book_store/bin/thrust +5 -0
  85. data/samples/book_store/config/application.rb +27 -0
  86. data/samples/book_store/config/boot.rb +4 -0
  87. data/samples/book_store/config/bundler-audit.yml +5 -0
  88. data/samples/book_store/config/cable.yml +17 -0
  89. data/samples/book_store/config/cache.yml +16 -0
  90. data/samples/book_store/config/ci.rb +24 -0
  91. data/samples/book_store/config/credentials.yml.enc +1 -0
  92. data/samples/book_store/config/database.yml +45 -0
  93. data/samples/book_store/config/deploy.yml +119 -0
  94. data/samples/book_store/config/environment.rb +5 -0
  95. data/samples/book_store/config/environments/development.rb +78 -0
  96. data/samples/book_store/config/environments/production.rb +90 -0
  97. data/samples/book_store/config/environments/test.rb +53 -0
  98. data/samples/book_store/config/importmap.rb +7 -0
  99. data/samples/book_store/config/initializers/assets.rb +7 -0
  100. data/samples/book_store/config/initializers/content_security_policy.rb +29 -0
  101. data/samples/book_store/config/initializers/filter_parameter_logging.rb +8 -0
  102. data/samples/book_store/config/initializers/inflections.rb +16 -0
  103. data/samples/book_store/config/locales/en.yml +31 -0
  104. data/samples/book_store/config/puma.rb +42 -0
  105. data/samples/book_store/config/queue.yml +18 -0
  106. data/samples/book_store/config/recurring.yml +15 -0
  107. data/samples/book_store/config/routes.rb +17 -0
  108. data/samples/book_store/config/storage.yml +27 -0
  109. data/samples/book_store/config.ru +6 -0
  110. data/samples/book_store/db/cable_schema.rb +11 -0
  111. data/samples/book_store/db/cache_schema.rb +12 -0
  112. data/samples/book_store/db/migrate/20260731035441_create_users.rb +10 -0
  113. data/samples/book_store/db/migrate/20260731035506_create_books.rb +11 -0
  114. data/samples/book_store/db/migrate/20260731035528_create_comments.rb +11 -0
  115. data/samples/book_store/db/queue_schema.rb +129 -0
  116. data/samples/book_store/db/schema.rb +39 -0
  117. data/samples/book_store/db/seeds.rb +9 -0
  118. data/samples/book_store/lib/tasks/.keep +0 -0
  119. data/samples/book_store/log/.keep +0 -0
  120. data/samples/book_store/public/400.html +135 -0
  121. data/samples/book_store/public/404.html +135 -0
  122. data/samples/book_store/public/406-unsupported-browser.html +135 -0
  123. data/samples/book_store/public/422.html +135 -0
  124. data/samples/book_store/public/500.html +135 -0
  125. data/samples/book_store/public/icon.png +0 -0
  126. data/samples/book_store/public/icon.svg +3 -0
  127. data/samples/book_store/public/robots.txt +1 -0
  128. data/samples/book_store/script/.keep +0 -0
  129. data/samples/book_store/spec/models/book_spec.rb +42 -0
  130. data/samples/book_store/spec/models/comment_spec.rb +22 -0
  131. data/samples/book_store/spec/models/user_advanced_spec.rb +27 -0
  132. data/samples/book_store/spec/models/user_spec.rb +30 -0
  133. data/samples/book_store/spec/rails_helper.rb +36 -0
  134. data/samples/book_store/spec/rails_parallel_spec.rb +23 -0
  135. data/samples/book_store/spec/requests/books_spec.rb +21 -0
  136. data/samples/book_store/spec/requests/users_spec.rb +14 -0
  137. data/samples/book_store/spec/services/inventory_service_spec.rb +28 -0
  138. data/samples/book_store/spec/services/time_dependent_service_spec.rb +26 -0
  139. data/samples/book_store/spec/spec_helper.rb +16 -0
  140. data/samples/book_store/spec/system/book_store_system_spec.rb +18 -0
  141. data/samples/book_store/storage/.keep +0 -0
  142. data/samples/book_store/test/controllers/.keep +0 -0
  143. data/samples/book_store/test/controllers/books_controller_test.rb +7 -0
  144. data/samples/book_store/test/controllers/comments_controller_test.rb +7 -0
  145. data/samples/book_store/test/controllers/users_controller_test.rb +7 -0
  146. data/samples/book_store/test/fixtures/books.yml +11 -0
  147. data/samples/book_store/test/fixtures/comments.yml +11 -0
  148. data/samples/book_store/test/fixtures/files/.keep +0 -0
  149. data/samples/book_store/test/fixtures/users.yml +9 -0
  150. data/samples/book_store/test/helpers/.keep +0 -0
  151. data/samples/book_store/test/integration/.keep +0 -0
  152. data/samples/book_store/test/mailers/.keep +0 -0
  153. data/samples/book_store/test/models/.keep +0 -0
  154. data/samples/book_store/test/models/book_test.rb +7 -0
  155. data/samples/book_store/test/models/comment_test.rb +7 -0
  156. data/samples/book_store/test/models/user_test.rb +7 -0
  157. data/samples/book_store/test/test_helper.rb +15 -0
  158. data/samples/book_store/tmp/.keep +0 -0
  159. data/samples/book_store/tmp/pids/.keep +0 -0
  160. data/samples/book_store/tmp/storage/.keep +0 -0
  161. data/samples/book_store/vendor/.keep +0 -0
  162. data/samples/book_store/vendor/javascript/.keep +0 -0
  163. data/test/crspec/configuration_test.rb +76 -0
  164. metadata +152 -2
@@ -0,0 +1,21 @@
1
+ class UsersController < ApplicationController
2
+ def index
3
+ users = User.all
4
+ render json: users
5
+ end
6
+
7
+ def create
8
+ user = User.new(user_params)
9
+ if user.save
10
+ render json: user, status: :created
11
+ else
12
+ render json: { errors: user.errors.full_messages }, status: :unprocessable_entity
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def user_params
19
+ params.require(:user).permit(:name, :email)
20
+ end
21
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module BooksHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module CommentsHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module UsersHelper
2
+ end
@@ -0,0 +1,3 @@
1
+ // Configure your import map in config/importmap.rb. Read more: https://github.com/rails/importmap-rails
2
+ import "@hotwired/turbo-rails"
3
+ import "controllers"
@@ -0,0 +1,9 @@
1
+ import { Application } from "@hotwired/stimulus"
2
+
3
+ const application = Application.start()
4
+
5
+ // Configure Stimulus development experience
6
+ application.debug = false
7
+ window.Stimulus = application
8
+
9
+ export { application }
@@ -0,0 +1,7 @@
1
+ import { Controller } from "@hotwired/stimulus"
2
+
3
+ export default class extends Controller {
4
+ connect() {
5
+ this.element.textContent = "Hello World!"
6
+ }
7
+ }
@@ -0,0 +1,4 @@
1
+ // Import and register all your controllers from the importmap via controllers/**/*_controller
2
+ import { application } from "controllers/application"
3
+ import { eagerLoadControllersFrom } from "@hotwired/stimulus-loading"
4
+ eagerLoadControllersFrom("controllers", application)
@@ -0,0 +1,7 @@
1
+ class ApplicationJob < ActiveJob::Base
2
+ # Automatically retry jobs that encountered a deadlock
3
+ # retry_on ActiveRecord::Deadlocked
4
+
5
+ # Most jobs are safe to ignore if the underlying records are no longer available
6
+ # discard_on ActiveJob::DeserializationError
7
+ end
@@ -0,0 +1,4 @@
1
+ class ApplicationMailer < ActionMailer::Base
2
+ default from: "from@example.com"
3
+ layout "mailer"
4
+ end
@@ -0,0 +1,3 @@
1
+ class ApplicationRecord < ActiveRecord::Base
2
+ primary_abstract_class
3
+ end
@@ -0,0 +1,10 @@
1
+ class Book < ApplicationRecord
2
+ has_many :comments, foreign_key: "books_id", dependent: :destroy
3
+
4
+ validates :name, presence: true
5
+ validates :author, presence: true
6
+
7
+ def summary
8
+ "#{name} by #{author}"
9
+ end
10
+ end
@@ -0,0 +1,6 @@
1
+ class Comment < ApplicationRecord
2
+ belongs_to :book, foreign_key: "books_id"
3
+
4
+ validates :title, presence: true
5
+ validates :text, presence: true
6
+ end
File without changes
@@ -0,0 +1,4 @@
1
+ class User < ApplicationRecord
2
+ validates :name, presence: true
3
+ validates :email, presence: true
4
+ end
@@ -0,0 +1,29 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title><%= content_for(:title) || "Book Store" %></title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <meta name="apple-mobile-web-app-capable" content="yes">
7
+ <meta name="application-name" content="Book Store">
8
+ <meta name="mobile-web-app-capable" content="yes">
9
+ <%= csrf_meta_tags %>
10
+ <%= csp_meta_tag %>
11
+
12
+ <%= yield :head %>
13
+
14
+ <%# Enable PWA manifest for installable apps (make sure to enable in config/routes.rb too!) %>
15
+ <%#= tag.link rel: "manifest", href: pwa_manifest_path(format: :json) %>
16
+
17
+ <link rel="icon" href="/icon.png" type="image/png">
18
+ <link rel="icon" href="/icon.svg" type="image/svg+xml">
19
+ <link rel="apple-touch-icon" href="/icon.png">
20
+
21
+ <%# Includes all stylesheet files in app/assets/stylesheets %>
22
+ <%= stylesheet_link_tag :app, "data-turbo-track": "reload" %>
23
+ <%= javascript_importmap_tags %>
24
+ </head>
25
+
26
+ <body>
27
+ <%= yield %>
28
+ </body>
29
+ </html>
@@ -0,0 +1,13 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
+ <style>
6
+ /* Email styles need to be inline */
7
+ </style>
8
+ </head>
9
+
10
+ <body>
11
+ <%= yield %>
12
+ </body>
13
+ </html>
@@ -0,0 +1 @@
1
+ <%= yield %>
@@ -0,0 +1,22 @@
1
+ {
2
+ "name": "BookStore",
3
+ "icons": [
4
+ {
5
+ "src": "/icon.png",
6
+ "type": "image/png",
7
+ "sizes": "512x512"
8
+ },
9
+ {
10
+ "src": "/icon.png",
11
+ "type": "image/png",
12
+ "sizes": "512x512",
13
+ "purpose": "maskable"
14
+ }
15
+ ],
16
+ "start_url": "/",
17
+ "display": "standalone",
18
+ "scope": "/",
19
+ "description": "BookStore.",
20
+ "theme_color": "red",
21
+ "background_color": "red"
22
+ }
@@ -0,0 +1,26 @@
1
+ // Add a service worker for processing Web Push notifications:
2
+ //
3
+ // self.addEventListener("push", async (event) => {
4
+ // const { title, options } = await event.data.json()
5
+ // event.waitUntil(self.registration.showNotification(title, options))
6
+ // })
7
+ //
8
+ // self.addEventListener("notificationclick", function(event) {
9
+ // event.notification.close()
10
+ // event.waitUntil(
11
+ // clients.matchAll({ type: "window" }).then((clientList) => {
12
+ // for (let i = 0; i < clientList.length; i++) {
13
+ // let client = clientList[i]
14
+ // let clientPath = (new URL(client.url)).pathname
15
+ //
16
+ // if (clientPath == event.notification.data.path && "focus" in client) {
17
+ // return client.focus()
18
+ // }
19
+ // }
20
+ //
21
+ // if (clients.openWindow) {
22
+ // return clients.openWindow(event.notification.data.path)
23
+ // }
24
+ // })
25
+ // )
26
+ // })
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+
5
+ ARGV.unshift("--ensure-latest")
6
+
7
+ load Gem.bin_path("brakeman", "brakeman")
@@ -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
@@ -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"
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env ruby
2
+ exec "./bin/rails", "server", *ARGV
@@ -0,0 +1,8 @@
1
+ #!/bin/bash -e
2
+
3
+ # If running the rails server then create or migrate existing database
4
+ if [ "${@: -2:1}" == "./bin/rails" ] && [ "${@: -1:1}" == "server" ]; then
5
+ ./bin/rails db:prepare
6
+ fi
7
+
8
+ exec "${@}"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../config/application"
4
+ require "importmap/commands"
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative "../config/environment"
4
+ require "solid_queue/cli"
5
+
6
+ SolidQueue::Cli.start(ARGV)
@@ -0,0 +1,16 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'kamal' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12
+
13
+ require "rubygems"
14
+ require "bundler/setup"
15
+
16
+ load Gem.bin_path("kamal", "kamal")
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path("../config/application", __dir__)
3
+ require_relative "../config/boot"
4
+ require "rails/commands"
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../config/boot"
3
+ require "rake"
4
+ Rake.application.run
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+
5
+ # Explicit RuboCop config increases performance slightly while avoiding config confusion.
6
+ ARGV.unshift("--config", File.expand_path("../.rubocop.yml", __dir__))
7
+
8
+ load Gem.bin_path("rubocop", "rubocop")
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+ require "fileutils"
3
+
4
+ APP_ROOT = File.expand_path("..", __dir__)
5
+
6
+ def system!(*args)
7
+ system(*args, exception: true)
8
+ end
9
+
10
+ FileUtils.chdir APP_ROOT do
11
+ # This script is a way to set up or update your development environment automatically.
12
+ # This script is idempotent, so that you can run it at any time and get an expectable outcome.
13
+ # Add necessary setup steps to this file.
14
+
15
+ puts "== Installing dependencies =="
16
+ system("bundle check") || system!("bundle install")
17
+
18
+ # puts "\n== Copying sample files =="
19
+ # unless File.exist?("config/database.yml")
20
+ # FileUtils.cp "config/database.yml.sample", "config/database.yml"
21
+ # end
22
+
23
+ puts "\n== Preparing database =="
24
+ system! "bin/rails db:prepare"
25
+ system! "bin/rails db:reset" if ARGV.include?("--reset")
26
+
27
+ puts "\n== Removing old logs and tempfiles =="
28
+ system! "bin/rails log:clear tmp:clear"
29
+
30
+ unless ARGV.include?("--skip-server")
31
+ puts "\n== Starting development server =="
32
+ STDOUT.flush # flush the output before exec(2) so that it displays
33
+ exec "bin/dev"
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+ require "rubygems"
3
+ require "bundler/setup"
4
+
5
+ load Gem.bin_path("thruster", "thrust")
@@ -0,0 +1,27 @@
1
+ require_relative "boot"
2
+
3
+ require "rails/all"
4
+
5
+ # Require the gems listed in Gemfile, including any gems
6
+ # you've limited to :test, :development, or :production.
7
+ Bundler.require(*Rails.groups)
8
+
9
+ module BookStore
10
+ class Application < Rails::Application
11
+ # Initialize configuration defaults for originally generated Rails version.
12
+ config.load_defaults 8.1
13
+
14
+ # Please, add to the `ignore` list any other `lib` subdirectories that do
15
+ # not contain `.rb` files, or that should not be reloaded or eager loaded.
16
+ # Common ones are `templates`, `generators`, or `middleware`, for example.
17
+ config.autoload_lib(ignore: %w[assets tasks])
18
+
19
+ # Configuration for the application, engines, and railties goes here.
20
+ #
21
+ # These settings can be overridden in specific environments using the files
22
+ # in config/environments, which are processed later.
23
+ #
24
+ # config.time_zone = "Central Time (US & Canada)"
25
+ # config.eager_load_paths << Rails.root.join("extras")
26
+ end
27
+ end
@@ -0,0 +1,4 @@
1
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
2
+
3
+ require "bundler/setup" # Set up gems listed in the Gemfile.
4
+ require "bootsnap/setup" # Speed up boot time by caching expensive operations.
@@ -0,0 +1,5 @@
1
+ # Audit all gems listed in the Gemfile for known security problems by running bin/bundler-audit.
2
+ # CVEs that are not relevant to the application can be enumerated on the ignore list below.
3
+
4
+ ignore:
5
+ - CVE-THAT-DOES-NOT-APPLY
@@ -0,0 +1,17 @@
1
+ # Async adapter only works within the same process, so for manually triggering cable updates from a console,
2
+ # and seeing results in the browser, you must do so from the web console (running inside the dev process),
3
+ # not a terminal started via bin/rails console! Add "console" to any action or any ERB template view
4
+ # to make the web console appear.
5
+ development:
6
+ adapter: async
7
+
8
+ test:
9
+ adapter: test
10
+
11
+ production:
12
+ adapter: solid_cable
13
+ connects_to:
14
+ database:
15
+ writing: cable
16
+ polling_interval: 0.1.seconds
17
+ message_retention: 1.day
@@ -0,0 +1,16 @@
1
+ default: &default
2
+ store_options:
3
+ # Cap age of oldest cache entry to fulfill retention policies
4
+ # max_age: <%= 60.days.to_i %>
5
+ max_size: <%= 256.megabytes %>
6
+ namespace: <%= Rails.env %>
7
+
8
+ development:
9
+ <<: *default
10
+
11
+ test:
12
+ <<: *default
13
+
14
+ production:
15
+ database: cache
16
+ <<: *default
@@ -0,0 +1,24 @@
1
+ # Run using bin/ci
2
+
3
+ CI.run do
4
+ step "Setup", "bin/setup --skip-server"
5
+
6
+ step "Style: Ruby", "bin/rubocop"
7
+
8
+ step "Security: Gem audit", "bin/bundler-audit"
9
+ step "Security: Importmap vulnerability audit", "bin/importmap audit"
10
+ step "Security: Brakeman code analysis", "bin/brakeman --quiet --no-pager --exit-on-warn --exit-on-error"
11
+ step "Tests: Rails", "bin/rails test"
12
+ step "Tests: Seeds", "env RAILS_ENV=test bin/rails db:seed:replant"
13
+
14
+ # Optional: Run system tests
15
+ # step "Tests: System", "bin/rails test:system"
16
+
17
+ # Optional: set a green GitHub commit status to unblock PR merge.
18
+ # Requires the `gh` CLI and `gh extension install basecamp/gh-signoff`.
19
+ # if success?
20
+ # step "Signoff: All systems go. Ready for merge and deploy.", "gh signoff"
21
+ # else
22
+ # failure "Signoff: CI failed. Do not merge or deploy.", "Fix the issues and try again."
23
+ # end
24
+ end
@@ -0,0 +1 @@
1
+ ojAe8w7sOsZkF8EHzorZ9K6yWXWLfAVJgZWQBwbWQ63/7NWXCSbf10eBnB03wp2wmCqATLLZCoKkT2HjNRPjItQioHu6kWHsJ1sHA9YJLfx8XRGShstu6mKesjzeh2koM3Ro8UueDGvDiX1InmGnhVnxZFkpPEkPM4ynb9ZRflP6Jh5i52jnPDBT98NHeZ4386h5mI9/IE830gmlgsnseAe56yolpvoeKcF+mPfdInMVQs392FsddUKVcsswSL7AdXJfY1hNSKQF5ZVA1PoBOUEg8CaG+IITHG6qK1PifSWgO0Ujv2wCo0dBY25G+eyeAUWVhXzhH1tXrZ+XExOrkkxmn3FUVcdQuIH+0xZCwkte9yoqG9lLHXNosd5VsQ2E0rWElsOo3sYAmgGXXm5BmTwOMbkLzKr4jPO4QhThd5C8+h39uv+0ErxNglJc8K4fh3d3GeENee5JXaI4SA7MJ+y9B8OhjrkAxjLdxnaRV++cqu4UyL27ROhH--ocr0VqVdu0Ywi3Ny--c1PbrAzy1cZg6mdR6mTolw==
@@ -0,0 +1,45 @@
1
+ # SQLite. Versions 3.8.0 and up are supported.
2
+ # gem install sqlite3
3
+ #
4
+ # Ensure the SQLite 3 gem is defined in your Gemfile
5
+ # gem "sqlite3"
6
+ #
7
+ default: &default
8
+ adapter: sqlite3
9
+ max_connections: <%= ENV.fetch("RAILS_MAX_THREADS") { 50 } %>
10
+ timeout: 10000
11
+ pool: 50
12
+ journal_mode: wal
13
+
14
+ development:
15
+ <<: *default
16
+ database: storage/development.sqlite3
17
+
18
+ # Warning: The database defined as "test" will be erased and
19
+ # re-generated from your development database when you run "rake".
20
+ # Do not set this db to the same as development or production.
21
+ test:
22
+ <<: *default
23
+ database: storage/test.sqlite3
24
+ pool: 50
25
+ timeout: 10000
26
+ journal_mode: wal
27
+
28
+ # Store production database in the storage/ directory, which by default
29
+ # is mounted as a persistent Docker volume in config/deploy.yml.
30
+ production:
31
+ primary:
32
+ <<: *default
33
+ database: storage/production.sqlite3
34
+ cache:
35
+ <<: *default
36
+ database: storage/production_cache.sqlite3
37
+ migrations_paths: db/cache_migrate
38
+ queue:
39
+ <<: *default
40
+ database: storage/production_queue.sqlite3
41
+ migrations_paths: db/queue_migrate
42
+ cable:
43
+ <<: *default
44
+ database: storage/production_cable.sqlite3
45
+ migrations_paths: db/cable_migrate
@@ -0,0 +1,119 @@
1
+ # Name of your application. Used to uniquely configure containers.
2
+ service: book_store
3
+
4
+ # Name of the container image (use your-user/app-name on external registries).
5
+ image: book_store
6
+
7
+ # Deploy to these servers.
8
+ servers:
9
+ web:
10
+ - 192.168.0.1
11
+ # job:
12
+ # hosts:
13
+ # - 192.168.0.1
14
+ # cmd: bin/jobs
15
+
16
+ # Enable SSL auto certification via Let's Encrypt and allow for multiple apps on a single web server.
17
+ # If used with Cloudflare, set encryption mode in SSL/TLS setting to "Full" to enable CF-to-app encryption.
18
+ #
19
+ # Using an SSL proxy like this requires turning on config.assume_ssl and config.force_ssl in production.rb!
20
+ #
21
+ # Don't use this when deploying to multiple web servers (then you have to terminate SSL at your load balancer).
22
+ #
23
+ # proxy:
24
+ # ssl: true
25
+ # host: app.example.com
26
+
27
+ # Where you keep your container images.
28
+ registry:
29
+ # Alternatives: hub.docker.com / registry.digitalocean.com / ghcr.io / ...
30
+ server: localhost:5555
31
+
32
+ # Needed for authenticated registries.
33
+ # username: your-user
34
+
35
+ # Always use an access token rather than real password when possible.
36
+ # password:
37
+ # - KAMAL_REGISTRY_PASSWORD
38
+
39
+ # Inject ENV variables into containers (secrets come from .kamal/secrets).
40
+ env:
41
+ secret:
42
+ - RAILS_MASTER_KEY
43
+ clear:
44
+ # Run the Solid Queue Supervisor inside the web server's Puma process to do jobs.
45
+ # When you start using multiple servers, you should split out job processing to a dedicated machine.
46
+ SOLID_QUEUE_IN_PUMA: true
47
+
48
+ # Set number of processes dedicated to Solid Queue (default: 1)
49
+ # JOB_CONCURRENCY: 3
50
+
51
+ # Set number of cores available to the application on each server (default: 1).
52
+ # WEB_CONCURRENCY: 2
53
+
54
+ # Match this to any external database server to configure Active Record correctly
55
+ # Use book_store-db for a db accessory server on same machine via local kamal docker network.
56
+ # DB_HOST: 192.168.0.2
57
+
58
+ # Log everything from Rails
59
+ # RAILS_LOG_LEVEL: debug
60
+
61
+ # Aliases are triggered with "bin/kamal <alias>". You can overwrite arguments on invocation:
62
+ # "bin/kamal logs -r job" will tail logs from the first server in the job section.
63
+ aliases:
64
+ console: app exec --interactive --reuse "bin/rails console"
65
+ shell: app exec --interactive --reuse "bash"
66
+ logs: app logs -f
67
+ dbc: app exec --interactive --reuse "bin/rails dbconsole --include-password"
68
+
69
+ # Use a persistent storage volume for sqlite database files and local Active Storage files.
70
+ # Recommended to change this to a mounted volume path that is backed up off server.
71
+ volumes:
72
+ - "book_store_storage:/rails/storage"
73
+
74
+ # Bridge fingerprinted assets, like JS and CSS, between versions to avoid
75
+ # hitting 404 on in-flight requests. Combines all files from new and old
76
+ # version inside the asset_path.
77
+ asset_path: /rails/public/assets
78
+
79
+ # Configure the image builder.
80
+ builder:
81
+ arch: amd64
82
+
83
+ # # Build image via remote server (useful for faster amd64 builds on arm64 computers)
84
+ # remote: ssh://docker@docker-builder-server
85
+ #
86
+ # # Pass arguments and secrets to the Docker build process
87
+ # args:
88
+ # RUBY_VERSION: ruby-4.0.2
89
+ # secrets:
90
+ # - GITHUB_TOKEN
91
+ # - RAILS_MASTER_KEY
92
+
93
+ # Use a different ssh user than root
94
+ # ssh:
95
+ # user: app
96
+
97
+ # Use accessory services (secrets come from .kamal/secrets).
98
+ # accessories:
99
+ # db:
100
+ # image: mysql:8.0
101
+ # host: 192.168.0.2
102
+ # # Change to 3306 to expose port to the world instead of just local network.
103
+ # port: "127.0.0.1:3306:3306"
104
+ # env:
105
+ # clear:
106
+ # MYSQL_ROOT_HOST: '%'
107
+ # secret:
108
+ # - MYSQL_ROOT_PASSWORD
109
+ # files:
110
+ # - config/mysql/production.cnf:/etc/mysql/my.cnf
111
+ # - db/production.sql:/docker-entrypoint-initdb.d/setup.sql
112
+ # directories:
113
+ # - data:/var/lib/mysql
114
+ # redis:
115
+ # image: valkey/valkey:8
116
+ # host: 192.168.0.2
117
+ # port: 6379
118
+ # directories:
119
+ # - data:/data
@@ -0,0 +1,5 @@
1
+ # Load the Rails application.
2
+ require_relative "application"
3
+
4
+ # Initialize the Rails application.
5
+ Rails.application.initialize!