From 9fd1df36d854911454edada5e183d20acf5b97bb Mon Sep 17 00:00:00 2001 From: Takumi Shotoku Date: Sun, 19 Sep 2021 14:12:09 +0900 Subject: [PATCH 1/4] =?UTF-8?q?ci:=20Rails=207.0=E3=81=A7=E3=83=86?= =?UTF-8?q?=E3=82=B9=E3=83=88=E3=82=92=E5=AE=9F=E8=A1=8C=E3=81=99=E3=82=8B?= =?UTF-8?q?=E8=A8=AD=E5=AE=9A=E3=82=92=E8=BF=BD=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test_rails_70.yml | 58 +++++++++++++++++++++++++++++ .gitignore | 1 + config/environments/development.rb | 12 +++--- gemfiles/rails_70.gemfile | 41 ++++++++++++++++++++ 4 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/test_rails_70.yml create mode 100644 gemfiles/rails_70.gemfile diff --git a/.github/workflows/test_rails_70.yml b/.github/workflows/test_rails_70.yml new file mode 100644 index 00000000000..6795db007c1 --- /dev/null +++ b/.github/workflows/test_rails_70.yml @@ -0,0 +1,58 @@ +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' + 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 + + - uses: ruby/setup-ruby@v1 + 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/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..21af9c03e9e --- /dev/null +++ b/gemfiles/rails_70.gemfile @@ -0,0 +1,41 @@ +# frozen_string_literal: true + +eval_gemfile File.expand_path('../Gemfile', __dir__) + +# gemをGitHubから取得し、tmp/repos/に置く +git_clone = lambda do |repo| + github_uri = "https://github.com/#{repo}.git" + name = repo.split('/').last + dest = File.expand_path("../tmp/repos/#{name}", __dir__) + + system "git clone --depth 1 #{github_uri} #{dest}" unless File.exist?(dest) + dest +end + +# Rails 7.0.alpha2でも使えるようにgemspecを書き換え +replace_deps = lambda do |name, path| + spec_path = File.expand_path("#{name}.gemspec", path) + new_content = File.read(spec_path).gsub('< 6.2', '< 7.0') + File.write(spec_path, new_content) +end + +# 依存関係を上書きするため、一度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.0.alpha2' + +gem 'any_login', github: 'igorkasyanchuk/any_login' +gem 'data_migrate', github: 'podia/data-migrate', branch: 'rails-7' +gem 'ransack', github: 'activerecord-hackery/ransack' +gem 'zeitwerk', github: 'fxn/zeitwerk', tag: 'v2.5.0.beta3' + +# gemspecを上書きする +repos = { + 'acts-as-taggable-on' => git_clone['mbleigh/acts-as-taggable-on'], + 'meta-tags' => git_clone['kpumuk/meta-tags'] +} +repos.each { |name, path| replace_deps[name, path] } + +gem 'acts-as-taggable-on', path: repos['acts-as-taggable-on'] +gem 'meta-tags', path: repos['meta-tags'] From 87352ff1e83134f8c0bfe0de8b75ab0909c9f685 Mon Sep 17 00:00:00 2001 From: Takumi Shotoku Date: Sun, 19 Sep 2021 14:52:31 +0900 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20=E8=AD=A6=E5=91=8A=E3=81=8C=E5=A4=A7?= =?UTF-8?q?=E9=87=8F=E3=81=AB=E5=87=BA=E3=82=8B=E3=81=9F=E3=82=81=E4=B8=80?= =?UTF-8?q?=E6=97=A6=E7=84=A1=E8=A6=96=E3=81=99=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 From 9a973bffd1ce6080e7f5a0551a39a78af9cfbe00 Mon Sep 17 00:00:00 2001 From: Takumi Shotoku Date: Mon, 20 Sep 2021 11:26:00 +0900 Subject: [PATCH 3/4] =?UTF-8?q?ci:=20Rails=207.0=E3=81=AB=E9=96=A2?= =?UTF-8?q?=E4=BF=82=E3=81=AA=E3=81=84gem=E3=81=AE=E3=82=A2=E3=83=83?= =?UTF-8?q?=E3=83=97=E3=82=B0=E3=83=AC=E3=83=BC=E3=83=89=E3=82=92=E6=8A=91?= =?UTF-8?q?=E6=AD=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test_rails_70.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test_rails_70.yml b/.github/workflows/test_rails_70.yml index 6795db007c1..dbadb674a3f 100644 --- a/.github/workflows/test_rails_70.yml +++ b/.github/workflows/test_rails_70.yml @@ -18,6 +18,7 @@ jobs: DATABASE_URL: "postgres://postgres:postgres@localhost/ci_test" TZ: 'Asia/Tokyo' BUNDLE_GEMFILE: 'gemfiles/rails_70.gemfile' + BUNDLE_DEPLOYMENT: "false" DISABLE_SPRING: "1" services: @@ -36,7 +37,10 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: ruby/setup-ruby@v1 + - 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 From 601ba9040dc1a4d406b758e8ca067bdf38f33f57 Mon Sep 17 00:00:00 2001 From: Takumi Shotoku Date: Sun, 30 Jan 2022 18:21:15 +0900 Subject: [PATCH 4/4] ci: upgrade gems --- gemfiles/rails_70.gemfile | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) diff --git a/gemfiles/rails_70.gemfile b/gemfiles/rails_70.gemfile index 21af9c03e9e..7b2ca21dd4e 100644 --- a/gemfiles/rails_70.gemfile +++ b/gemfiles/rails_70.gemfile @@ -2,40 +2,15 @@ eval_gemfile File.expand_path('../Gemfile', __dir__) -# gemをGitHubから取得し、tmp/repos/に置く -git_clone = lambda do |repo| - github_uri = "https://github.com/#{repo}.git" - name = repo.split('/').last - dest = File.expand_path("../tmp/repos/#{name}", __dir__) - - system "git clone --depth 1 #{github_uri} #{dest}" unless File.exist?(dest) - dest -end - -# Rails 7.0.alpha2でも使えるようにgemspecを書き換え -replace_deps = lambda do |name, path| - spec_path = File.expand_path("#{name}.gemspec", path) - new_content = File.read(spec_path).gsub('< 6.2', '< 7.0') - File.write(spec_path, new_content) -end - # 依存関係を上書きするため、一度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.0.alpha2' +gem 'rails', github: 'rails/rails', tag: 'v7.0.1' gem 'any_login', github: 'igorkasyanchuk/any_login' -gem 'data_migrate', github: 'podia/data-migrate', branch: 'rails-7' -gem 'ransack', github: 'activerecord-hackery/ransack' -gem 'zeitwerk', github: 'fxn/zeitwerk', tag: 'v2.5.0.beta3' - -# gemspecを上書きする -repos = { - 'acts-as-taggable-on' => git_clone['mbleigh/acts-as-taggable-on'], - 'meta-tags' => git_clone['kpumuk/meta-tags'] -} -repos.each { |name, path| replace_deps[name, path] } - -gem 'acts-as-taggable-on', path: repos['acts-as-taggable-on'] -gem 'meta-tags', path: repos['meta-tags'] +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'