diff --git a/.github/workflows/test_rails_70.yml b/.github/workflows/test_rails_70.yml new file mode 100644 index 00000000000..dbadb674a3f --- /dev/null +++ b/.github/workflows/test_rails_70.yml @@ -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 diff --git a/.gitignore b/.gitignore index 6a6d40c98b9..d23d4751d2a 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,4 @@ storage/ yarn-debug.log* .yarn-integrity .envrc +gemfiles/*.lock diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e8a142ff71c..a7239ed4a57 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -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 diff --git a/config/environments/development.rb b/config/environments/development.rb index 286edf5474d..ed6848afaa3 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -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 diff --git a/gemfiles/rails_70.gemfile b/gemfiles/rails_70.gemfile new file mode 100644 index 00000000000..7b2ca21dd4e --- /dev/null +++ b/gemfiles/rails_70.gemfile @@ -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'