Skip to content

Commit 04455ba

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

File tree

2 files changed

+36
-2
lines changed

2 files changed

+36
-2
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

test/shared_helper.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,19 @@ 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"
31-
if `#{cmd}` && $?.exitstatus == 0
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+
36+
puts "DEBUG: Checking postgres role with command: #{cmd}"
37+
output = `#{cmd}`
38+
exit_status = $?.exitstatus
39+
puts "DEBUG: Command output: #{output}"
40+
puts "DEBUG: Exit status: #{exit_status}"
41+
42+
if exit_status == 0
3243
true
3344
else
3445
if warn.nil?
@@ -38,6 +49,9 @@ def postgres_role?(warn = nil)
3849
send(:warn, warn) if warn # warn == false disables warnings
3950
false
4051
end
52+
else
53+
puts "DEBUG: psql executable not found!"
54+
false
4155
end
4256
end
4357
alias_method :have_postgres?, :postgres_role?

0 commit comments

Comments
 (0)