Skip to content

Commit

Permalink
fix pg host
Browse files Browse the repository at this point in the history
  • Loading branch information
marcogregorius committed Nov 25, 2022
1 parent 3a0ca58 commit c1eea2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ jobs:
BUNDLE_GEMFILE: ${{ matrix.gemfile }}
EXPERIMENTAL: ${{ matrix.experimental }}
JRUBY_OPTS: --debug
# Ruby version > 2.3 needs host 127.0.0.1 for GitHub Action to find Postgres.
# Ruby version <= 2.3 will throw random error from C if host is provided.
PG_HOST: ${{ matrix.ruby > 2.3 && '127.0.0.1' || null }} # workaround to ternary operator
steps:
- uses: actions/checkout@v3
- name: Setup ImageMagick policy
Expand Down
3 changes: 2 additions & 1 deletion spec/support/activerecord.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@

# Change this if PG is unavailable
dbconfig = {
:host => '127.0.0.1',
:adapter => 'postgresql',
:database => 'carrierwave_test',
:encoding => 'utf8',
:username => 'postgres',
:password => 'postgres'
}

dbconfig[:host] = ENV['PG_HOST'] unless ENV['PG_HOST'].nil?

database = dbconfig.delete(:database)

ActiveRecord::Base.establish_connection(dbconfig.merge(database: "template1"))
Expand Down

0 comments on commit c1eea2c

Please sign in to comment.