Skip to content

Commit 4c37c13

Browse files
committed
migrate last reference to postgres
1 parent 18bd865 commit 4c37c13

File tree

3 files changed

+22
-10
lines changed

3 files changed

+22
-10
lines changed

.github/workflows/ruby.yml

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ jobs:
5656
with:
5757
ruby-version: ${{ matrix.ruby-version }}
5858
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
59+
- name: Setup gdiff
60+
run: |
61+
sudo ln -s /usr/bin/diff /usr/bin/gdiff || true
5962
- name: Setup database
6063
run: |
6164
sudo service mysql start
@@ -91,9 +94,8 @@ jobs:
9194
postgres:
9295
image: postgres:17
9396
env:
94-
POSTGRES_USER: jruby
95-
POSTGRES_PASSWORD: jruby
96-
POSTGRES_HOST_AUTH_METHOD: trust
97+
POSTGRES_PASSWORD: postgres
98+
POSTGRES_DB: postgres
9799
ports:
98100
- 5432:5432
99101
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
@@ -120,10 +122,14 @@ jobs:
120122
with:
121123
ruby-version: ${{ matrix.ruby-version }}
122124
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
125+
- name: Setup gdiff
126+
run: |
127+
sudo ln -s /usr/bin/diff /usr/bin/gdiff || true
123128
- name: Setup database
124129
run: |
125-
PGPASSWORD=jruby psql -c "create database activerecord_unittest;" -U jruby
126-
PGPASSWORD=jruby psql -c "create database activerecord_unittest2;" -U jruby
130+
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER jruby WITH SUPERUSER CREATEDB LOGIN PASSWORD 'jruby';"
131+
PGPASSWORD=jruby psql -h localhost -d postgres -c "create database activerecord_unittest;" -U jruby
132+
PGPASSWORD=jruby psql -h localhost -d postgres -c "create database activerecord_unittest2;" -U jruby
127133
- name: Build
128134
run: |
129135
rake jar # compiles ext generates: lib/arjdbc/jdbc/adapter_java.jar
@@ -160,6 +166,9 @@ jobs:
160166
with:
161167
ruby-version: ${{ matrix.ruby-version }}
162168
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
169+
- name: Setup gdiff
170+
run: |
171+
sudo ln -s /usr/bin/diff /usr/bin/gdiff || true
163172
- name: Build
164173
run: |
165174
echo "JAVA_OPTS=$JAVA_OPTS"
@@ -235,9 +244,8 @@ jobs:
235244
postgres:
236245
image: postgres:17
237246
env:
238-
POSTGRES_USER: jruby
239-
POSTGRES_PASSWORD: jruby
240-
POSTGRES_HOST_AUTH_METHOD: trust
247+
POSTGRES_PASSWORD: postgres
248+
POSTGRES_DB: postgres
241249
ports:
242250
- 5432:5432
243251
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
@@ -265,6 +273,9 @@ jobs:
265273
with:
266274
ruby-version: ${{ matrix.ruby-version }}
267275
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
276+
- name: Setup PostgreSQL user
277+
run: |
278+
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER jruby WITH SUPERUSER CREATEDB LOGIN PASSWORD 'jruby';"
268279
- name: Build
269280
run: |
270281
rake jar

rakelib/db.rake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ GRANT ALL PRIVILEGES ON `test\_%`.* TO #{MYSQL_CONFIG[:username]}@localhost;
3939
task :postgresql do
4040
require File.expand_path('../../test/shared_helper', __FILE__)
4141
fail 'could not create test database: psql executable not found' unless psql = which('psql')
42-
fail 'could not create test database: missing "postgres" role' unless PostgresHelper.postgres_role?
42+
fail 'could not create test database: missing "jruby" role' unless PostgresHelper.postgres_role?
4343

4444
load 'test/db/postgres_config.rb' # rescue nil
4545
puts POSTGRES_CONFIG.inspect if $VERBOSE

test/shared_helper.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ module PostgresHelper
2525
class << self
2626
def postgres_role?(warn = nil)
2727
if psql = which('psql')
28-
if `#{psql} -c '\\l' -U jruby #{psql_params}2>&1` && $?.exitstatus == 0
28+
cmd = "PGPASSWORD=#{ENV['PGPASSWORD'] || 'jruby'} #{psql} -d postgres -c '\\l' -U jruby #{psql_params} 2>&1"
29+
if `#{cmd}` && $?.exitstatus == 0
2930
true
3031
else
3132
if warn.nil?

0 commit comments

Comments
 (0)