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

[WIP] Rails 7.0のアップグレード準備 #3294

Closed
wants to merge 4 commits into from
Closed
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
62 changes: 62 additions & 0 deletions .github/workflows/test_rails_70.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: Test Rails 7

on:
push:
branches: rails7

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-latest
timeout-minutes: 30

env:
RAILS_ENV: test
DATABASE_URL: "postgres://postgres:postgres@localhost/ci_test"
TZ: 'Asia/Tokyo'
BUNDLE_GEMFILE: 'gemfiles/rails_70.gemfile'
BUNDLE_DEPLOYMENT: "false"
DISABLE_SPRING: "1"

services:
postgres:
image: postgres
ports:
- 5432:5432
env:
POSTGRES_PASSWORD: postgres
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5

steps:
- uses: actions/checkout@v2

- name: Copy Gemfile.lock to gemfiles directory
run: cp Gemfile.lock ${{ env.BUNDLE_GEMFILE }}.lock

- uses: sinsoku/setup-ruby@respect_bundle_deployment
with:
bundler-cache: true

- name: Cache node modules
uses: actions/cache@v2.1.4
with:
path: node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-node-

- name: yarn install
run: yarn install --check-files

- name: Setup test DB
run: bundle exec rails db:setup

- name: Run tests
run: bundle exec rails test:all
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ storage/
yarn-debug.log*
.yarn-integrity
.envrc
gemfiles/*.lock
6 changes: 5 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ def set_available_emojis
def set_host_for_disk_storage
return unless %i[local test].include? Rails.application.config.active_storage.service

ActiveStorage::Current.host = request.base_url
if Rails::VERSION::STRING.start_with?('7.0')
ActiveSupport::Deprecation.silence { ActiveStorage::Current.host = request.base_url }
else
ActiveStorage::Current.host = request.base_url
end
end

def require_card
Expand Down
12 changes: 7 additions & 5 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,11 @@
config.action_controller.asset_host = "http://localhost:3000"
config.action_mailer.asset_host = "http://localhost:3000"

config.after_initialize do
Bullet.enable = true
Bullet.add_footer = true
Bullet.bullet_logger = true
end
unless Rails::VERSION::STRING.start_with?("7.0")
config.after_initialize do
Bullet.enable = true
Bullet.add_footer = true
Bullet.bullet_logger = true
end
end
end
16 changes: 16 additions & 0 deletions gemfiles/rails_70.gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# frozen_string_literal: true

eval_gemfile File.expand_path('../Gemfile', __dir__)

# 依存関係を上書きするため、一度gemの依存を削除
overwrite_gems = %w[rails acts-as-taggable-on meta-tags zeitwerk data_migrate ransack bullet any_login]
dependencies.delete_if { |d| overwrite_gems.include?(d.name) }

gem 'rails', github: 'rails/rails', tag: 'v7.0.1'

gem 'any_login', github: 'igorkasyanchuk/any_login'
gem 'data_migrate', '7.0.2'
gem 'ransack', '2.5.0'
gem 'zeitwerk', '2.5.4'
gem 'acts-as-taggable-on', '9.0.1'
gem 'meta-tags', '2.16.0'