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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle less generator failure #1938

Merged
merged 7 commits into from
Sep 28, 2017
Merged

Conversation

deivid-rodriguez
Copy link
Contributor

馃帺 What? Why?

Our generator was crashing when run directly via decidim's executable (gem install decidim; decidim my_awesome_app). This is because bundler is not available in that case.

This PR fixes that, changes our tests so they catch this thing, and improves some extra related stuff.

馃搶 Related Issues

馃搵 Subtasks

None.

馃摲 Screenshots (optional)

None.

馃懟 GIF

todo_lo_que_ves

@ghost ghost added the in-progress label Sep 27, 2017
@mrcasals
Copy link
Contributor

@deivid-rodriguez CircleCI got an error:

https://circleci.com/gh/decidim/decidim/4663#queue-placeholder/containers/0

ActiveRecord::NoDatabaseError: FATAL: database "generator_test_app_development" does not exist

馃槙

@codecov
Copy link

codecov bot commented Sep 27, 2017

Codecov Report

Merging #1938 into master will decrease coverage by 0.01%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #1938      +/-   ##
==========================================
- Coverage   98.48%   98.47%   -0.02%     
==========================================
  Files        1145     1145              
  Lines       25737    25734       -3     
==========================================
- Hits        25347    25341       -6     
- Misses        390      393       +3

Copy link
Contributor

@mrcasals mrcasals left a comment

Choose a reason for hiding this comment

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

CircleCI has errors but somehow the build is green 馃槙

@deivid-rodriguez
Copy link
Contributor Author

deivid-rodriguez commented Sep 27, 2017

@mrcasals It's expected, it's because of d3d76c5. I changed it so that new people cloning a fresh repo are allowed to get an error on DB dropping (because the DB won't exist previously). Previously we workarounded this in CI by skipping this step via ENV["CI"], but since I'm allowing that to fail, maybe we no longer need it? I kind of like that the exact same thing is run on CI and on our machines.

What do you think?

And rename it so that specs don't fail on a freshly cloned repo (where
./tmp does not exist).
We can't asume bundler is available inside our generators, since it
will not when they are run through decidim executable.

Fixes the following crash:

```
/code/to/decidim/lib/generators/decidim/install_generator.rb:25:in
`bundle_install': uninitialized constant
Decidim::Generators::InstallGenerator::Bundler (NameError)
```
@mrcasals
Copy link
Contributor

Ah, I understand now. I find it a little weird that we get errors on the build but still everything's normal. Is there a way to check if the database exists before dropping?

Found this in a 2-second search on Google:

https://stackoverflow.com/a/25592558/2110884

def database_exists?
  ActiveRecord::Base.connection
rescue ActiveRecord::NoDatabaseError
  false
else
  true
end

What do you think?

mrcasals
mrcasals previously approved these changes Sep 28, 2017
@deivid-rodriguez
Copy link
Contributor Author

I did try that but couldn't get it working. Let me try spend another five minutes!

For example, on freshly cloned repos. As a result, we no longer need to
check for CI here.
So we can give it the standard "test name" and it doesn't affect our
"real" development application.
@deivid-rodriguez
Copy link
Contributor Author

@mrcasals I couldn't get DB existance detection working, but I added an alternative. What do you think of
70c7fa4?

Copy link
Contributor

@mrcasals mrcasals left a comment

Choose a reason for hiding this comment

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

Awesome!

@mrcasals mrcasals merged commit 46f82b9 into master Sep 28, 2017
@ghost ghost removed the in-progress label Sep 28, 2017
@deivid-rodriguez deivid-rodriguez deleted the fix/bundle_less_generator_failure branch September 28, 2017 09:29
mrcasals pushed a commit that referenced this pull request Sep 29, 2017
* Fix crash when running decidim executable

We can't asume bundler is available inside our generators, since it
will not when they are run through decidim executable.

Fixes the following crash:

```
/code/to/decidim/lib/generators/decidim/install_generator.rb:25:in
`bundle_install': uninitialized constant
Decidim::Generators::InstallGenerator::Bundler (NameError)
```

* Improve some test descriptions

* Test generator without flags

* Extract a shared example

* Extract test app name to a variable

And rename it so that specs don't fail on a freshly cloned repo (where
./tmp does not exist).

* Allow DB dropping to fail

For example, on freshly cloned repos. As a result, we no longer need to
check for CI here.

* Generate dev application in tests via bin/decidim

So we can give it the standard "test name" and it doesn't affect our
"real" development application.
@mrcasals mrcasals mentioned this pull request Sep 29, 2017
mrcasals pushed a commit that referenced this pull request Oct 2, 2017
* Fix crash when running decidim executable

We can't asume bundler is available inside our generators, since it
will not when they are run through decidim executable.

Fixes the following crash:

```
/code/to/decidim/lib/generators/decidim/install_generator.rb:25:in
`bundle_install': uninitialized constant
Decidim::Generators::InstallGenerator::Bundler (NameError)
```

* Improve some test descriptions

* Test generator without flags

* Extract a shared example

* Extract test app name to a variable

And rename it so that specs don't fail on a freshly cloned repo (where
./tmp does not exist).

* Allow DB dropping to fail

For example, on freshly cloned repos. As a result, we no longer need to
check for CI here.

* Generate dev application in tests via bin/decidim

So we can give it the standard "test name" and it doesn't affect our
"real" development application.
mrcasals added a commit that referenced this pull request Oct 5, 2017
* Don't use models in migrations (#1921)

* Run seeds in the same process as migrations

So we can detect bad model usage inside migrations.

* Don't swallow errors in app generation

The `rails_command` method shells out the target command, but swallows
any errors that may happen. In my opinion, this is bad because we really
want these commands to succeed, and since the output is usually long,
you might not notice that they have failed. In addition, if errors are
swallowed, it's really hard to unit test generators!

* Remove hardcoded models from migrations

And add a regression test for development app generation. To ensure that
these errors can be properly caught in the future.

* Prefer `abort` to `exit 1`

* Remove unnecessary `ActiveRecord::Base.connection`

In migrations, all that stuff in directly available.

* Silence test output

* Fix app generators (#1931)

* Bundle less generator failure (#1938)

* Fix crash when running decidim executable

We can't asume bundler is available inside our generators, since it
will not when they are run through decidim executable.

Fixes the following crash:

```
/code/to/decidim/lib/generators/decidim/install_generator.rb:25:in
`bundle_install': uninitialized constant
Decidim::Generators::InstallGenerator::Bundler (NameError)
```

* Improve some test descriptions

* Test generator without flags

* Extract a shared example

* Extract test app name to a variable

And rename it so that specs don't fail on a freshly cloned repo (where
./tmp does not exist).

* Allow DB dropping to fail

For example, on freshly cloned repos. As a result, we no longer need to
check for CI here.

* Generate dev application in tests via bin/decidim

So we can give it the standard "test name" and it doesn't affect our
"real" development application.

* Centralize dependencies (#1958)

* Style fixes in template Gemfile

* Centralize dependencies to a single Gemfile

* Upgrade dependencies

* Require survey TOS field on admin (#1980)

* Require survey TOS field on admin

* Add CHANGELOG entry

* Fix puma dep

* Fix input fields for single locale organizations (#1983)

* Fix input fields for single locale organizations

* Add CHANGELOG entry

* Bump version to 0.6.6

* Downgrade graphiql-rails

* Update CHANGELOG

* Use latest docker image on CircleCI
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants