-
Notifications
You must be signed in to change notification settings - Fork 124
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
Postgresql in circle #4397
Postgresql in circle #4397
Conversation
c40bdd3
to
c7a8750
Compare
c7a8750
to
7c4aeec
Compare
...yrax/templates/db/migrate/20200617002029_change_sipity_entity_specific_responsibility.rb.erb
Show resolved
Hide resolved
...yrax/templates/db/migrate/20200617002029_change_sipity_entity_specific_responsibility.rb.erb
Outdated
Show resolved
Hide resolved
@@ -5,6 +5,67 @@ class TestAppGenerator < Rails::Generators::Base | |||
# so the following path gets us to /path/to/hyrax/spec/test_app_templates/ | |||
source_root File.expand_path('../../../../spec/test_app_templates/', __FILE__) | |||
|
|||
def conditional_postgresql_for_ci_environment | |||
# For now, postgresql is something we are looking at adding to CircleCI |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could all of this be handled by DATABASE_URL
instead? https://edgeguides.rubyonrails.org/configuring.html#configuring-a-database
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we could. I also believe we could then run postgresql OR sqlite locally for specs based on an ENV. That would be dreamy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did some further digging, and those ENV's currently come from CircleCI. Also, based on my read of that configuring a database, you'd be able to use DATABASE_URL for local development.
Perhaps this is something to bump to @rotated8 and samvera's orbs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jeremyf i think you can set environment variables for a job here, without requiring changes to the orb: https://github.com/samvera/hyrax/blob/master/.circleci/config.yml#L20-L22
i think adding a line like DATABASE_URL: 'postgresql://hyrax_user:hyrax_password@postgres/hyrax?pool=5'
might do the trick?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@no-reply I'll give it a go on my local machine; I'd love to remove some of that conditional logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
possibly it's okay to just hard code the CI config in multiple ENV variables as a first step, then refactor the duplication out after?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm hearing that it'd be nice if the orb exported a DATABASE_URL variable. So, samvera/samvera-circleci-orb#42
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rotated8 thanks, I'll get to hard-coding, and see about remediating that particular file. I'm a big fan of how small this PR is becoming.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The last set of commits and rebasing addresses the DATABASE_URL, and opts for the hard-coding as talked about in https://wiki.lyrasis.org/display/samvera/Samvera+Tech+Call+2020-07-15
It's much cleaner and removes several switches (though pushes people to locally use postgresql when they regen their internal test app).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh wow this looks great! thanks for your documentation.
i appreciate the personal nature of your code comments. :)
9d48fb9
to
add3dd4
Compare
So, even if these specs pass, there appears to be some "fails more than it passes" builds. I'm going to look into the DATABASE_URL, as I think that might help someone run both a sqlite and a postgresql instance in their dummy app (based on ENV). I also believe, at this point, that all Postgresql specific changes to the code-base have been merged via other PRs. |
add3dd4
to
7b17f6a
Compare
accc6a3
to
2c20f94
Compare
5e50e76
to
283b453
Compare
I rebased the work based on #4417 |
Our CircleCI orb gives us the ENV variables this setup uses.
283b453
to
a9f716d
Compare
a0aaaf0
to
253be42
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and pretty clean now!
I have only one small suggestion and a question.
- run: | ||
command: | | ||
cd .internal_test_app | ||
bundle install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need another bundle install here? It runs at the engine level right before this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know; I'll remove and find out. Brace yourselves, rebases are coming!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to remove this, but without the step, things fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for trying that out. Not in scope of this PR, but I wonder if this is another place that circleci caching could be utilized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I'd love to not run bundle install more than is necessary. This looks like it shouldn't be necessary, but I leave it up to the next person.
253be42
to
f33c213
Compare
@@ -0,0 +1,40 @@ | |||
# Greetings Hyrax developer, you may be surprised to see this file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
great!
these docs are helpful. i may take a pass at a docker version later on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀 🎸 ✨ 🥇
@@ -112,6 +114,9 @@ jobs: | |||
ruby_version: << parameters.ruby_version >> | |||
bundler_version: << parameters.bundler_version >> | |||
project: hyrax | |||
- run: | |||
command: | | |||
cd .internal_test_app |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you lost the migration installation and db:migrate in the rebase.
The errors that I'm seeing indicate that I may be missing some necessary build step. |
8edfdbd
to
29b81cf
Compare
Thanks @rotated8 for the previous leg of the journey. For both local development and CircleCI, this commit switches the default database from Sqlite to Postgresql. Intrepid developer, please note when next you regenerate the `.internal_test_app`, you will by default be generating it to use a Postgresql database. For now, I've included guidance on what to do in the `./.engine_cart.yml` file. Once you've regenerated your `.internal_test_app`, you'll need to export a DATABASE_URL (or update `.internal_test_app/config/database.yml`) to specify how you're connecting to Postgresql. This builds on the guidance in the [Rails Guides][1] around using a DATABASE_URL environment variable. [1]:https://edgeguides.rubyonrails.org/configuring.html#configuring-a-database Also, ensuring hyrax installs migrations in CirclCI At a future point, we'll likely need to update the developer Wiki, but for now, dear developer, you'll need to review the commit messages.
I do not believe this change column is likely used by adopters; It has to do with adding permissions to an individual Sipity::Entity. The change is necessary because the foreign key was created as a string, but the associated primary key on the other table was an integer. This is likely a bad copy paste job from ndlib/sipity
29b81cf
to
e9e9f65
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds optional Postgres setup for test database
cd4c970
Our CircleCI orb gives us the ENV variables this setup uses.
Adding postgresql to the engine cart build
ce1cd77
Thanks @rotated8 for the previous leg of the journey.
For both local development and CircleCI, this commit switches the default
database from Sqlite to Postgresql.
Intrepid developer, please note when next you regenerate the
.internal_test_app
, you will by default be generating it to use aPostgresql database. For now, I've included guidance on what to do in
the
./.engine_cart.yml
file.Once you've regenerated your
.internal_test_app
, you'll need to exporta DATABASE_URL (or update
.internal_test_app/config/database.yml
) tospecify how you're connecting to Postgresql.
This builds on the guidance in the Rails Guides around using a
DATABASE_URL environment variable.
Also, ensuring hyrax installs migrations in CirclCI
At a future point, we'll likely need to update the developer Wiki, but
for now, dear developer, you'll need to review the commit messages.
Changing column type [Needs Upgrade Notes]
f33c213
I do not believe this change column is likely used by adopters; It has
to do with adding permissions to an individual Sipity::Entity.
The change is necessary because the foreign key was created as a string,
but the associated primary key on the other table was an integer.
This is likely a bad copy paste job from ndlib/sipity