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

Provide initialization of Active Storage #30101

Merged

Conversation

@bogdanvlviv
Copy link
Contributor

@bogdanvlviv bogdanvlviv commented Aug 6, 2017

#30098 (comment)

Closes #30102

@rails-bot
Copy link

@rails-bot rails-bot commented Aug 6, 2017

r? @kaspth

(@rails-bot has picked a reviewer for you, use r? to override)

@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch 3 times, most recently Aug 6, 2017
@bogdanvlviv bogdanvlviv changed the title WIP: Provide initialization Active Storage when `rails new` WIP: Provide initialization Active Storage Aug 7, 2017
@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch 12 times, most recently Aug 7, 2017
@bogdanvlviv bogdanvlviv changed the title WIP: Provide initialization Active Storage Provide initialization of Active Storage Aug 7, 2017
@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch Aug 7, 2017
@bogdanvlviv
Copy link
Contributor Author

@bogdanvlviv bogdanvlviv commented Aug 7, 2017

After adding Active Storage by default, new apps take up more space.
I got the error Errno::ENOSPC: No space left on device - sendfile on travis-ci(https://travis-ci.org/rails/rails/builds/261890209) and my virtual machine.
The reason that we don't delete a generated app after finishing a test case, I looked at size /tmp and saw that it took up more than 4G space after rails/railties$ bundle exec rake test.
Looks like we must remove a generated app after a test's finishing.

This commit fixes it 02b64f4, but now there is another problem, it takes up more time for execution(https://travis-ci.org/rails/rails/builds/261934074).
Does anyone have any idea?

@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch Aug 8, 2017
railties/lib/rails/generators/app_base.rb Outdated
end

def comment_if(value) # :doc:
options[value] ? "# " : ""
comment =
if value.is_a?(String) || value.is_a?(Symbol)

This comment has been minimized.

@rafaelfranca

rafaelfranca Aug 8, 2017
Member

instead of type check better to check if the class respond to the value

This comment has been minimized.

@bogdanvlviv

bogdanvlviv Aug 9, 2017
Author Contributor

I Agree. Thanks.

railties/lib/rails/generators/rails/plugin/templates/rails/application.rb Outdated
require "action_controller/railtie"
require "action_view/railtie"
<%= comment_if :skip_action_mailer %>require "action_mailer/railtie"
require "active_job/railtie"
require "active_storage/engine"
<%= comment_if :skip_action_cable %>require "action_cable/engine"

This comment has been minimized.

@rafaelfranca

rafaelfranca Aug 8, 2017
Member

Why this was removed?

This comment has been minimized.

@bogdanvlviv

bogdanvlviv Aug 9, 2017
Author Contributor

Oops. I missed.

@rafaelfranca rafaelfranca added this to the 5.2.0 milestone Aug 8, 2017
@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch 2 times, most recently Aug 9, 2017
@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch Aug 11, 2017
@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Aug 11, 2017

Looking good so far. Could you rebase and fix the tests?

@y-yagi
Copy link
Member

@y-yagi y-yagi commented Oct 11, 2017

We also need skip_active_storage? check in template of Gemfile.

@@ -153,6 +153,7 @@ def build_app(options = {})

def teardown_app
ENV["RAILS_ENV"] = @prev_rails_env if @prev_rails_env
FileUtils.rm_rf(tmp_path)

This comment has been minimized.

@y-yagi

y-yagi Oct 11, 2017
Member

Why was this added?

This comment has been minimized.

@bogdanvlviv

bogdanvlviv Oct 11, 2017
Author Contributor

Intentionally, see description of commit Fix error Errno::ENOSPC: No space left on device - sendfile

@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch 3 times, most recently Oct 11, 2017
@bogdanvlviv
Copy link
Contributor Author

@bogdanvlviv bogdanvlviv commented Oct 11, 2017

The tests are green!

Thanks @y-yagi

@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch 6 times, most recently Oct 30, 2017
@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Nov 6, 2017

Could you squash the commits?

@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch Nov 6, 2017
@bogdanvlviv
Copy link
Contributor Author

@bogdanvlviv bogdanvlviv commented Nov 6, 2017

@rafaelfranca
Copy link
Member

@rafaelfranca rafaelfranca commented Nov 6, 2017

That are still too many commits related to the same change that can be squashed.

…record is used

Closes #30102

Revert part 787fe90

--skip-active-storage pass throughs `rails plugin new`

Add changelog entry about default initialization of Active Storage
@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch Nov 6, 2017
@bogdanvlviv
Copy link
Contributor Author

@bogdanvlviv bogdanvlviv commented Nov 6, 2017

I squashed one more time.

bogdanvlviv added 3 commits Aug 7, 2017
Omit `rails activestorage:install` for jdbcmysql, jdbc and shebang tests

AppGeneratorTest#test_config_jdbcmysql_database

  rails aborted!
  LoadError: Could not load 'active_record/connection_adapters/mysql_adapter'.
  Make sure that the adapter in config/database.yml is valid.
  If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
  the necessary adapter gem to the Gemfile.
  (compressed)
  bin/rails:4:in `<main>'
  Tasks: TOP => activestorage:install => environment
  (See full trace by running task with --trace)

AppGeneratorTest#test_config_jdbc_database

  rails aborted!
  LoadError: Could not load 'active_record/connection_adapters/jdbc_adapter'.
  Make sure that the adapter in config/database.yml is valid.
  If you use an adapter other than 'mysql2', 'postgresql' or 'sqlite3' add
  the necessary adapter gem to the Gemfile.
  (compressed)
  bin/rails:4:in `<main>'
  Tasks: TOP => activestorage:install => environment
  (See full trace by running task with --trace)

AppGeneratorTest#test_shebang_is_added_to_rails_file

  /home/ubuntu/.rbenv/versions/2.4.1/bin/ruby: no Ruby script found in input (LoadError)

Prevent PendingMigrationError in tests

 * Run `bin/rails db:migrate RAILS_ENV=test` in test_cases before start tests to prevent PendingMigrationError
 * FileUtils.rm_r("db/migrate")
 * --skip-active-storage

Fix failed tests in `railties/test/railties/engine_test.rb`

Related to #30111

Imporve `SharedGeneratorTests#test_default_frameworks_are_required_when_others_are_removed`

 - Explicitly skip active_storage
 - Ensure that skipped frameworks are commented
 - Ensure that default frameworks are not commented

Fix error `Errno::ENOSPC: No space left on device - sendfile`

Since `rails new` runs `rails active_storage:install`
that boots an app.

Since adding Bootsnap 0312a5c
during booting an app, it creates the cache:

   264K    tmp/cache/bootsnap-load-path-cache
   27M     tmp/cache/bootsnap-compile-cache

* teardown_app must remove app
… `rails new`
@bogdanvlviv bogdanvlviv force-pushed the bogdanvlviv:initialization-active_storage branch to cb8553c Nov 6, 2017
@rafaelfranca rafaelfranca merged commit 63f0c04 into rails:master Nov 6, 2017
2 checks passed
2 checks passed
codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@bogdanvlviv bogdanvlviv deleted the bogdanvlviv:initialization-active_storage branch Nov 6, 2017
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this pull request Nov 8, 2017
These were added in rails#30101, after rails#31084 it became redundant.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

8 participants