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

feat: support Rails 7.1 #502

Merged
merged 12 commits into from
Nov 16, 2023
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,8 @@ jobs:
# "react", "sidekiq" etc.
APP_NAME: ${{ matrix.variant.name }}-demo
CONFIG_PATH: ${{ matrix.variant.config_path }}
SKIPS: "--skip-javascript ${{ matrix.variant.skips }}"
SKIPS: "--skip-javascript --skip-docker ${{ matrix.variant.skips }}"
PGUSER: postgres
PGPASSWORD: postgres
PGHOST: localhost
RAILS_SECRET_KEY_BASE: "placeholder"
ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY: "placeholder"
ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY: "placeholder"
ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT: "placeholder"
run: ./ci/bin/build-and-test
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ Before running this template, you must have the following installed on your
machine:

- Yarn v1.21.0 or later
- Rails 7.0.x
- Rails 7.1.x

The following are not strictly required to run the template but you will need it
to start the Rails app that this template creates:
Expand Down Expand Up @@ -192,15 +192,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 --template=https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
$ rails new my_app --no-rc --database=postgresql --skip-javascript --skip-docker --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 --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 --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 @@ -228,6 +228,7 @@ To make this the default Rails application template on your system, create a
# ~/.railsrc
-d postgresql
--skip-javascript
--skip-docker
-m https://raw.githubusercontent.com/ackama/rails-template/main/template.rb
```

Expand Down Expand Up @@ -275,7 +276,7 @@ $ CONFIG_PATH="ci/configs/react.yml" APP_NAME="enterprise" ./ci/bin/build-and-te
# because the template is run by `rails new` which uses the rails app dir as
# it's working dir, hence the `../` at the start.
#
$ rm -rf mydemoapp && CONFIG_PATH="../ci/configs/react.yml" rails new mydemoapp -d postgresql --skip-javascript -m ./template.rb
$ rm -rf mydemoapp && CONFIG_PATH="../ci/configs/react.yml" rails new mydemoapp -d postgresql --skip-javascript --skip-docker -m ./template.rb
```

Rubocop is configured for this repo and is run as part of CI. Run rubocop
Expand Down
2 changes: 1 addition & 1 deletion ci/bin/build-and-test
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ config_path = if ENV.fetch("CONFIG_PATH", "") == ""
end

config_env_var = %Q(CONFIG_PATH="#{config_path}") if config_path
skip_flags = ENV.fetch("SKIPS", "--skip-javascript")
skip_flags = ENV.fetch("SKIPS", "--skip-javascript --skip-docker")

puts "=" * 80
puts <<~EO_CONFIG_SUMMARY
Expand Down
7 changes: 4 additions & 3 deletions template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
require "shellwords"
require "pp"

RAILS_REQUIREMENT = "~> 7.0.3".freeze
RAILS_REQUIREMENT = "~> 7.1.1".freeze

##
# This single template file will be downloaded and run by the `rails new`
Expand Down Expand Up @@ -92,10 +92,10 @@ def apply_template! # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Met

copy_file "variants/backend-base/.node-version", ".node-version"

copy_file "variants/backend-base/Dockerfile", "Dockerfile"
copy_file "variants/backend-base/Dockerfile", "Dockerfile", force: true
copy_file "variants/backend-base/docker-compose.yml", "docker-compose.yml"
copy_file "variants/backend-base/.osv-detector.yml", ".osv-detector.yml"
copy_file "variants/backend-base/.dockerignore", ".dockerignore"
copy_file "variants/backend-base/.dockerignore", ".dockerignore", force: true

apply "variants/backend-base/Rakefile.rb"
apply "variants/backend-base/config.ru.rb"
Expand Down Expand Up @@ -304,6 +304,7 @@ def assert_valid_options
skip_test_unit: true,
skip_active_storage: false,
skip_javascript: true,
skip_docker: true,
edge: false
}
valid_options.each do |key, expected|
Expand Down
4 changes: 2 additions & 2 deletions variants/audit-logging/template.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
source_paths.unshift(File.dirname(__FILE__))

copy_file("variants/audit-logging/lib/auditor_log_formatter.rb", "lib/auditor_log_formatter.rb")
copy_file("variants/audit-logging/lib/audit_log_log_formatter.rb", "lib/audit_log_log_formatter.rb")
copy_file("variants/audit-logging/services/audit_log.rb", "app/services/audit_log.rb")
copy_file("variants/audit-logging/spec/services/audit_log_spec.rb", "spec/services/audit_log_spec.rb")

Expand All @@ -19,7 +19,7 @@

prepend_to_file "config/application.rb" do
<<~RUBY
require_relative "../lib/auditor_log_formatter"
require_relative "../lib/audit_log_log_formatter"
RUBY
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<title>
<%%= strip_tags(yield(:title)) + " " if content_for?(:title) %>
<%%= strip_tags(yield(:title)) + " - " if content_for?(:title) %>
<%= app_const_base.titleize %>
</title>

Expand All @@ -15,7 +15,7 @@
<%%= stylesheet_link_tag("application", media: "all", "data-turbolinks-track": "reload") %>

<%%# JavaScript must be in head for Turbolinks to work. %>
<%%= javascript_pack_tag "application", "data-turbolinks-track": "reload", defer: true %>
<%%= javascript_pack_tag "application", "data-turbolinks-track": "reload", defer: true, nonce: true %>

<%%= yield(:head) %>

Expand Down
4 changes: 4 additions & 0 deletions variants/backend-base/config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@
gsub_file "config/environments/development.rb",
"join('tmp', 'caching-dev.txt')",
'join("tmp/caching-dev.txt")'

gsub_file "config/environments/development.rb",
Copy link
Contributor

Choose a reason for hiding this comment

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

See issue #507 for discussion around this change

"config.action_controller.raise_on_missing_callback_actions = true",
"# config.action_controller.raise_on_missing_callback_actions = true"
Copy link

Choose a reason for hiding this comment

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

We are leaving this commented out for now and will land this PR.

4 changes: 4 additions & 0 deletions variants/backend-base/config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,7 @@
config.i18n.raise_on_missing_translations = true
RUBY
end

gsub_file "config/environments/test.rb",
"config.action_controller.raise_on_missing_callback_actions = true",
"# config.action_controller.raise_on_missing_callback_actions = true"
2 changes: 0 additions & 2 deletions variants/frontend-base/template.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
# Configure app/frontend

run "mv app/javascript app/frontend"
run "mkdir app/frontend/packs"
run "mv app/frontend/application.js app/frontend/packs/application.js"

copy_file "config/webpack/webpack.config.js", force: true

Expand Down
Loading