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

@rails-bot
Copy link

r? @kaspth

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

@bogdanvlviv bogdanvlviv force-pushed the initialization-active_storage branch 3 times, most recently from f71e14d to 989d72e Compare August 7, 2017 04:28
@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 initialization-active_storage branch 12 times, most recently from c5d740f to 780f237 Compare August 7, 2017 14:01
@bogdanvlviv bogdanvlviv changed the title WIP: Provide initialization Active Storage Provide initialization of Active Storage Aug 7, 2017
@bogdanvlviv bogdanvlviv force-pushed the initialization-active_storage branch from 168fe2f to 8aae5f1 Compare August 7, 2017 16:05
@bogdanvlviv
Copy link
Contributor Author

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 initialization-active_storage branch from 02b64f4 to b49509d Compare August 8, 2017 16:06
end

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

Choose a reason for hiding this comment

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

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I Agree. Thanks.

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"
Copy link
Member

Choose a reason for hiding this comment

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

Why this was removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. I missed.

@rafaelfranca rafaelfranca added this to the 5.2.0 milestone Aug 8, 2017
@bogdanvlviv bogdanvlviv force-pushed the initialization-active_storage branch 2 times, most recently from 4d9b6c5 to 2130d10 Compare August 9, 2017 06:13
@rafaelfranca
Copy link
Member

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

:skip_sprockets,
:skip_action_cable
),
skip_active_storage?
Copy link
Member

@y-yagi y-yagi Oct 11, 2017

Choose a reason for hiding this comment

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

I think that specifying skip_active_storage directly is more simpler.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah it is simpler, but I think it is more correctly use skip_active_storage?

@y-yagi
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

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

Why was this added?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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

@bogdanvlviv bogdanvlviv force-pushed the initialization-active_storage branch 3 times, most recently from 2e75442 to 8406d91 Compare October 11, 2017 16:00
@bogdanvlviv
Copy link
Contributor Author

The tests are green!

Thanks @y-yagi

@bogdanvlviv bogdanvlviv force-pushed the initialization-active_storage branch 6 times, most recently from 69dccd2 to b203d31 Compare November 2, 2017 21:54
@rafaelfranca
Copy link
Member

Could you squash the commits?

@bogdanvlviv
Copy link
Contributor Author

@rafaelfranca done

@rafaelfranca
Copy link
Member

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

…record is used

Closes rails#30102

Revert part 787fe90

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

Add changelog entry about default initialization of Active Storage
@bogdanvlviv
Copy link
Contributor Author

I squashed one more time.

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 rails#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
@rafaelfranca rafaelfranca merged commit 63f0c04 into rails:master Nov 6, 2017
@bogdanvlviv bogdanvlviv deleted the initialization-active_storage branch November 6, 2017 22:26
bogdanvlviv added a commit to bogdanvlviv/rails that referenced this pull request Nov 8, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants