Skip to content

Commit e0462b6

Browse files
committed
attempt to fix the previous build
1 parent e5b59c6 commit e0462b6

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

.github/workflows/ruby.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,21 @@ jobs:
122122
with:
123123
ruby-version: ${{ matrix.ruby-version }}
124124
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
125+
- name: Install PostgreSQL 17 client
126+
run: |
127+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
128+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
129+
sudo apt-get update
130+
sudo apt-get install -y postgresql-client-17
125131
- name: Setup gdiff
126132
run: |
127133
sudo ln -s /usr/bin/diff /usr/bin/gdiff || true
128134
- name: Setup database
129135
run: |
130136
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER arjdbc WITH SUPERUSER CREATEDB LOGIN PASSWORD 'arjdbc';"
137+
echo "Testing connection as arjdbc user..."
138+
PGPASSWORD=arjdbc psql -h localhost -d postgres -U arjdbc -c '\l'
139+
echo "Exit status: $?"
131140
PGPASSWORD=arjdbc psql -h localhost -d postgres -c "create database activerecord_unittest;" -U arjdbc
132141
PGPASSWORD=arjdbc psql -h localhost -d postgres -c "create database activerecord_unittest2;" -U arjdbc
133142
- name: Build
@@ -273,9 +282,20 @@ jobs:
273282
with:
274283
ruby-version: ${{ matrix.ruby-version }}
275284
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
285+
- name: Install PostgreSQL 17 client
286+
run: |
287+
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
288+
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
289+
sudo apt-get update
290+
sudo apt-get install -y postgresql-client-17
276291
- name: Setup PostgreSQL user
277292
run: |
278293
PGPASSWORD=postgres psql -h localhost -U postgres -c "CREATE USER arjdbc WITH SUPERUSER CREATEDB LOGIN PASSWORD 'arjdbc';"
294+
- name: Test PostgreSQL connection
295+
run: |
296+
echo "Testing connection as arjdbc user..."
297+
PGPASSWORD=arjdbc psql -h localhost -d postgres -U arjdbc -c '\l'
298+
echo "Exit status: $?"
279299
- name: Build
280300
run: |
281301
rake jar

rakelib/db.rake

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,13 @@ CREATE DATABASE #{POSTGRES_CONFIG[:database]} OWNER #{POSTGRES_CONFIG[:username]
5353
ENCODING '#{POSTGRES_CONFIG[:encoding]}' LC_COLLATE '#{POSTGRES_CONFIG[:collate]}' LC_CTYPE '#{POSTGRES_CONFIG[:collate]}';
5454
SQL
5555

56-
params = { '-U' => ENV['PGUSER'] || 'arjdbc' }
56+
params = { '-U' => ENV['PGUSER'] || 'arjdbc', '-d' => 'postgres' }
57+
params['-h'] = ENV['PGHOST'] if ENV['PGHOST']
58+
params['-p'] = ENV['PGPORT'] if ENV['PGPORT']
5759
params['-q'] = nil unless $VERBOSE
5860

5961
puts "Creating PostgreSQL (test) database: #{POSTGRES_CONFIG[:database]}"
60-
sh "cat #{script.path} | #{psql} #{params.to_a.join(' ')}", verbose: $VERBOSE
62+
sh "PGPASSWORD=#{ENV['PGPASSWORD'] || 'arjdbc'} cat #{script.path} | #{psql} #{params.to_a.join(' ')}", verbose: $VERBOSE
6163
end
6264
task postgres: :postgresql
6365

test/shared_helper.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ def postgres_role?(warn = nil)
2727
if psql = which('psql')
2828
user = ENV['PGUSER'] || 'arjdbc'
2929
password = ENV['PGPASSWORD'] || 'arjdbc'
30-
cmd = "PGPASSWORD=#{password} #{psql} -d postgres -c '\\l' -U #{user} #{psql_params} 2>&1"
30+
host = ENV['PGHOST'] || 'localhost'
31+
port = ENV['PGPORT'] || '5432'
32+
33+
# Use simpler command with explicit parameters
34+
cmd = "PGPASSWORD=#{password} #{psql} -h #{host} -p #{port} -d postgres -U #{user} -c '\\q' 2>&1"
35+
3136
if `#{cmd}` && $?.exitstatus == 0
3237
true
3338
else

0 commit comments

Comments
 (0)