Skip to content

Rails 8 #573

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

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
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
36 changes: 19 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Run Rubocop
run: bundle exec rubocop

test_generated_apps:
apps: # GitHub UI truncates job names so keep this short
permissions:
contents: read
runs-on: ubuntu-latest
Expand All @@ -82,21 +82,22 @@ jobs:
js_package_manager:
- name: npm
installer: npm
- name: yarn_berry
installer: yarn
linker: pnp
- name: yarn_berry
installer: yarn
linker: node-modules
- name: yarn_berry
installer: yarn
linker: pnpm
- name: yarn_classic
installer: yarn
- name: pnpm
installer: pnpm
- name: bun
installer: bun
# TODO: temp disable to make CI easier to grok
# - name: yarn_berry
# installer: yarn
# linker: pnp
# - name: yarn_berry
# installer: yarn
# linker: node-modules
# - name: yarn_berry
# installer: yarn
# linker: pnpm
# - name: yarn_classic
# installer: yarn
# - name: pnpm
# installer: pnpm
# - name: bun
# installer: bun
variant:
- name: defaults
config_path: 'ackama_rails_template.config.yml'
Expand Down Expand Up @@ -203,7 +204,8 @@ jobs:
# "react", "sidekiq" etc.
APP_NAME: ${{ matrix.variant.name }}-demo
CONFIG_PATH: ${{ matrix.variant.config_path }}
SKIPS: '--skip-javascript --skip-docker ${{ matrix.variant.skips }}'
# prettier-ignore
SKIPS: '--skip-javascript --skip-docker --skip-kamal --skip-solid ${{ matrix.variant.skips }}'
PGUSER: postgres
PGPASSWORD: postgres
PGHOST: localhost
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,15 @@ $ wget https://raw.githubusercontent.com/ackama/rails-template/main/ackama_rails

# Create a new app using the template. Template options will be taken from
# ./ackama_rails_template.config.yml
$ rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
$ rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --skip-kamal --skip-solid --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb

# Example 2
# #########

# Create a custom config YAML file, saving as ./my_custom_config.yml

# Template options will be taken from ../my_custom_config.yml (relative to the new app directory)
$ CONFIG_PATH=../my_custom_config.yml rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
$ CONFIG_PATH=../my_custom_config.yml rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --skip-kamal --skip-solid --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
```

Here are some additional options you can add to this command. We don't
Expand Down Expand Up @@ -230,6 +230,8 @@ To make this the default Rails application template on your system, create a
-d postgresql
--skip-javascript
--skip-docker
--skip-kamal
--skip-solid
-m https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
```

Expand Down
4 changes: 2 additions & 2 deletions target_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# This is stored in a separate file so we can share it between the template and
# our CI configuration.
target_rails_major_minor: '7.2' # specify as major.minor
target_rails_major_minor: '8.0' # specify as major.minor

# Set this to the minimum version of Ruby that the chosen Rails version supports.
minimum_ruby_major_minor: '3.1'
minimum_ruby_major_minor: '3.2'
5 changes: 5 additions & 0 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met
# but also after `shakapacker:install` and after Rails has initialized the git
# repo
after_bundle do # rubocop:disable Metrics/BlockLength
TERMINAL.puts_header "START after_bundle block"

require_package_json_gem

apply "variants/backend-base/lib/template.rb"
Expand All @@ -157,6 +159,7 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met
# its own `spec/` directory
remove_dir "test"

TERMINAL.puts_header "START bin/setup"
run_with_clean_bundler_env "bin/setup"

apply "variants/frontend-base/template.rb"
Expand Down Expand Up @@ -249,6 +252,8 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met

# Run prettier one last time to ensure that everything is formatted
apply_prettier_all_over

TERMINAL.puts_header "END after_bundle block"
end
end

Expand Down
2 changes: 2 additions & 0 deletions variants/accessibility/Gemfile.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
TERMINAL.puts_header "Installing accessibility checking gems"

insert_into_file! "Gemfile", after: /gem "selenium-webdriver"\n/ do
<<~GEMS

Expand Down
9 changes: 6 additions & 3 deletions variants/backend-base/Gemfile.tt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ ruby File.read(".ruby-version")
gem "rails", "<%= Rails.version %>"
gem "puma"
gem "pg"
gem 'dotenv-rails', require: "dotenv/load"
gem "dotenv-rails", require: "dotenv/load"
gem "bootsnap", require: false

gem "shakapacker"
Expand All @@ -15,10 +15,13 @@ gem "okcomputer"
gem "sentry-ruby"
gem "sentry-rails"

# Use Active Model has_secure_password [https://guides.rubyonrails.org/active_model_basics.html#securepassword]
# gem "bcrypt", "~> 3.1.7"

gem "rack-canonical-host"

# The original asset pipeline for Rails [https://github.com/rails/sprockets-rails]
gem "sprockets-rails"
# The modern asset pipeline for Rails [https://github.com/rails/propshaft]
gem "propshaft"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: Verify we still need propshaft given we use shakapacker.


# Hotwire's SPA-like page accelerator [https://turbo.hotwired.dev]
gem "turbo-rails"
Expand Down
16 changes: 1 addition & 15 deletions variants/backend-base/config/environments/production.rb
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
insert_into_file! "config/environments/production.rb",
after: /# config\.assets\.css_compressor = :sass\n/ do
<<-RUBY

# Disable minification since it adds a *huge* amount of time to precompile.
# Anyway, gzip alone gets us about 70% of the benefits of minify+gzip.
config.assets.css_compressor = false
RUBY
end

gsub_file! "config/environments/production.rb",
"config.force_ssl = true",
<<~RUBY
Expand Down Expand Up @@ -46,10 +36,7 @@
'ENV.fetch("RAILS_LOG_LEVEL", "info")',
'ENV.fetch("RAILS_LOG_LEVEL", ENV.fetch("LOG_LEVEL", "info"))'

gsub_file! "config/environments/production.rb",
"ActiveSupport::Logger.new(STDOUT)",
"ActiveSupport::Logger.new($stdout)"

# TODO: https://github.com/ackama/rails-template/issues/569
insert_into_file! "config/environments/production.rb",
after: /.*config\.public_file_server\.enabled.*\n/ do
<<~'RUBY'
Expand Down Expand Up @@ -81,7 +68,6 @@
config.public_file_server.headers = {
"Cache-Control" => "public, s-maxage=#{365.days.seconds}, max-age=#{365.days.seconds}"
}

RUBY
end

Expand Down
2 changes: 1 addition & 1 deletion variants/bullet/template.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
insert_into_file! "Gemfile", after: /^group :development, :test do\n/ do
<<~GEMS
gem "bullet"
gem "bullet", ">= 8.0" # Rails 8+ requires Bullet 8+
GEMS
end

Expand Down
Loading