Skip to content

Commit 182bb69

Browse files
justin808claude
andcommitted
Address PR review feedback: fix bin/ci, puma, ActionCable, and config defaults
- Rewrite bin/ci to use plain Ruby (TutorialCI module) instead of non-existent ActiveSupport::ContinuousIntegration DSL - Add test asset build step to CI pipeline - Use bin/conductor-exec wrapper for all CI commands - Restore worker_timeout 3600 for development in puma.rb - Restore default thread count to 5 in puma.rb - Comment out solid_queue plugin (gem not in Gemfile) - Make PRODUCTION_HOST optional with conditional guard - Make deprecation reporting configurable via RAILS_REPORT_DEPRECATIONS env var - Restore conditional cache store toggle in development.rb - Preserve to_time_preserves_timezone = false in application.rb - Use action_cable_meta_tag for client-side WebSocket URL construction - Add actionCableUrl.js helper to read cable URL from meta tag Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b3dfe81 commit 182bb69

10 files changed

Lines changed: 61 additions & 45 deletions

File tree

app/views/layouts/application.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<%= javascript_pack_tag('data-turbolinks-track': true, defer: true) %>
2626

2727
<%= csrf_meta_tags %>
28+
<%= action_cable_meta_tag %>
2829
</head>
2930
<body class="min-h-screen flex flex-col bg-sky-50 text-gray-700">
3031
<%= yield :body_content %>

bin/ci

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
#!/usr/bin/env ruby
2-
require_relative "../config/boot"
3-
require "active_support/continuous_integration"
2+
# frozen_string_literal: true
43

5-
CI = ActiveSupport::ContinuousIntegration
6-
require_relative "../config/ci.rb"
4+
require "English"
5+
require_relative "../config/ci"
6+
7+
def run_step(name, command)
8+
puts "\n== #{name} =="
9+
puts "$ #{command}"
10+
system(command)
11+
return if $CHILD_STATUS.success?
12+
13+
warn "\nStep failed: #{name}"
14+
exit($CHILD_STATUS.exitstatus || 1)
15+
end
16+
17+
TutorialCI::STEPS.each do |name, command|
18+
run_step(name, command)
19+
end
20+
21+
puts "\nAll CI steps passed."

client/app/bundles/comments/components/CommentBox/CommentBox.jsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@ import React from 'react';
22
import PropTypes from 'prop-types';
33
import Immutable from 'immutable';
44
import _ from 'lodash';
5+
import * as ActionCable from '@rails/actioncable';
56
import { injectIntl } from 'react-intl';
67
import BaseComponent from 'libs/components/BaseComponent';
8+
import actionCableUrl from 'libs/actionCableUrl';
79
import SelectLanguage from 'libs/i18n/selectLanguage';
810
import { defaultMessages, defaultLocale } from 'libs/i18n/default';
911
import CommentForm from './CommentForm/CommentForm';
@@ -34,11 +36,7 @@ class CommentBox extends BaseComponent {
3436

3537
subscribeChannel() {
3638
const { messageReceived } = this.props.actions;
37-
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
38-
const cableUrl = `${protocol}${window.location.hostname}:${window.location.port}/cable`;
39-
// ActionCable is a global added through webpack.providePlugin
40-
// eslint-disable-next-line no-undef
41-
this.cable = ActionCable.createConsumer(cableUrl);
39+
this.cable = ActionCable.createConsumer(actionCableUrl());
4240

4341
/* eslint no-console: ["error", { allow: ["log"] }] */
4442
this.cable.subscriptions.create(

client/app/controllers/comments_controller.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as ActionCable from '@rails/actioncable';
33
import * as marked from 'marked';
44
import { gfmHeadingId } from 'marked-gfm-heading-id';
55
import { mangle } from 'marked-mangle';
6+
import actionCableUrl from 'libs/actionCableUrl';
67

78
marked.use(gfmHeadingId());
89
marked.use(mangle());
@@ -47,10 +48,7 @@ export default class CommentsController extends Controller {
4748
connect() {
4849
console.log('connected to Stimulus comments_controller');
4950

50-
const protocol = window.location.protocol === 'https:' ? 'wss://' : 'ws://';
51-
const cableUrl = `${protocol}${window.location.hostname}:${window.location.port}/cable`;
52-
53-
this.cable = ActionCable.createConsumer(cableUrl);
51+
this.cable = ActionCable.createConsumer(actionCableUrl());
5452

5553
this.cable.subscriptions.create('CommentsChannel', {
5654
connected: () => {

client/app/libs/actionCableUrl.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default function actionCableUrl() {
2+
const cableMetaTag = document.querySelector("meta[name='action-cable-url']");
3+
return cableMetaTag ? cableMetaTag.getAttribute('content') : undefined;
4+
}

config/application.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ class Application < Rails::Application
1313
# Initialize configuration defaults for originally generated Rails version.
1414
config.load_defaults 8.1
1515

16+
# Preserve historical app behavior for Time#to_time conversions.
17+
config.active_support.to_time_preserves_timezone = false
18+
1619
# Please, add to the `ignore` list any other `lib` subdirectories that do
1720
# not contain `.rb` files, or that should not be reloaded or eager loaded.
1821
# Common ones are `templates`, `generators`, or `middleware`, for example.

config/ci.rb

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
# frozen_string_literal: true
22

3-
# Run using bin/ci
4-
5-
CI.run do
6-
step "Setup", "bin/setup --skip-server"
7-
8-
step "Style: Ruby", "bin/rubocop"
9-
step "Style: JavaScript", "yarn lint:eslint"
10-
11-
step "Tests: RSpec", "bin/rspec"
12-
step "Tests: Jest", "yarn test:client"
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
3+
module TutorialCI
4+
STEPS = [
5+
["Setup", "bin/conductor-exec bin/setup --skip-server"],
6+
["Style: Ruby", "bin/conductor-exec bin/rubocop"],
7+
["Style: JavaScript", "bin/conductor-exec yarn lint:eslint"],
8+
[
9+
"Build: Test assets",
10+
"RAILS_ENV=test bin/conductor-exec bin/rails react_on_rails:generate_packs && " \
11+
"bin/conductor-exec yarn res:build && " \
12+
"bin/conductor-exec yarn build:test",
13+
],
14+
["Tests: RSpec", "bin/conductor-exec bin/rspec"],
15+
["Tests: Jest", "bin/conductor-exec yarn test:client"],
16+
].freeze
2417
end

config/environments/development.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,12 @@
2323
config.action_controller.perform_caching = true
2424
config.action_controller.enable_fragment_cache_logging = true
2525
config.public_file_server.headers = { "cache-control" => "public, max-age=#{2.days.to_i}" }
26+
config.cache_store = :memory_store
2627
else
2728
config.action_controller.perform_caching = false
29+
config.cache_store = :null_store
2830
end
2931

30-
# Change to :null_store to avoid any caching.
31-
config.cache_store = :memory_store
32-
3332
# Store uploaded files on the local file system (see config/storage.yml for options).
3433
config.active_storage.service = :local
3534

config/environments/production.rb

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848
# Prevent health checks from clogging up the logs.
4949
config.silence_healthcheck_path = "/up"
5050

51-
# Don't log any deprecations.
52-
config.active_support.report_deprecations = false
51+
# Keep deprecations visible by default so upgrades don't hide breaking changes.
52+
config.active_support.report_deprecations = ENV["RAILS_REPORT_DEPRECATIONS"] != "false"
5353

5454
# Replace the default in-process memory cache store with a durable alternative.
5555
# config.cache_store = :mem_cache_store
@@ -93,6 +93,9 @@
9393
# config.host_authorization = { exclude: ->(request) { request.path == "/up" } }
9494

9595
# Action Cable endpoint configuration
96-
config.action_cable.url = "wss://#{ENV.fetch('PRODUCTION_HOST')}/cable"
97-
config.action_cable.allowed_request_origins = ["https://#{ENV.fetch('PRODUCTION_HOST')}"]
96+
production_host = ENV["PRODUCTION_HOST"]
97+
if production_host.present?
98+
config.action_cable.url = "wss://#{production_host}/cable"
99+
config.action_cable.allowed_request_origins = ["https://#{production_host}"]
100+
end
98101
end

config/puma.rb

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,25 @@
2121
# Global VM Lock (GVL) it has diminishing returns and will degrade the
2222
# response time (latency) of the application.
2323
#
24-
# The default is set to 3 threads as it's deemed a decent compromise between
25-
# throughput and latency for the average Rails application.
24+
# The default is 5 threads in the Rails template.
2625
#
2726
# Any libraries that use a connection pool or another resource pool should
2827
# be configured to provide at least as many connections as the number of
2928
# threads. This includes Active Record's `pool` parameter in `database.yml`.
30-
threads_count = ENV.fetch("RAILS_MAX_THREADS", 3)
29+
threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
3130
threads threads_count, threads_count
3231

32+
# Allow long-running requests in development (e.g. debugger breakpoints).
33+
worker_timeout 3600 if ENV.fetch("RAILS_ENV", "development") == "development"
34+
3335
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
3436
port ENV.fetch("PORT", 3000)
3537

3638
# Allow puma to be restarted by `bin/rails restart` command.
3739
plugin :tmp_restart
3840

3941
# Run the Solid Queue supervisor inside of Puma for single-server deployments.
40-
plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
42+
# plugin :solid_queue if ENV["SOLID_QUEUE_IN_PUMA"]
4143

4244
# Specify the PID file. Defaults to tmp/pids/server.pid in development.
4345
# In other environments, only set the PID file if requested.

0 commit comments

Comments
 (0)