Skip to content

Commit f6b1e0b

Browse files
committed
use box-local PG
1 parent c443456 commit f6b1e0b

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

.github/workflows/ci.yml

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,32 +17,56 @@ jobs:
1717
- run: bundle exec standardrb
1818

1919
suite-tests:
20-
services:
21-
postgres:
22-
image: postgres
23-
env:
24-
POSTGRES_PASSWORD: postgres
25-
port: "5432:5432"
26-
options: >-
27-
--health-cmd pg_isready
28-
--health-interval 10s
29-
--health-timeout 5s
30-
--health-retries 5
20+
# services:
21+
# postgres:
22+
# image: postgres
23+
# env:
24+
# POSTGRES_PASSWORD: postgres
25+
# port: "5432:5432"
26+
# options: >-
27+
# --health-cmd pg_isready
28+
# --health-interval 10s
29+
# --health-timeout 5s
30+
# --health-retries 5
3131
needs:
3232
- linting
3333
runs-on: ubuntu-latest
3434
env:
3535
RAILS_ENV: test
3636
DISABLE_SPRING: 1
3737
SIMPLE_SERVER_DATABASE_HOST: localhost
38-
SIMPLE_SERVER_DATABASE_USERNAME: postgres
38+
SIMPLE_SERVER_DATABASE_USERNAME: simple_testuser
3939
SIMPLE_SERVER_DATABASE_PASSWORD: postgres
4040
TEST_ENV_NUMBER: 1
4141
steps:
4242
- uses: actions/checkout@v4
4343
- uses: ruby/setup-ruby@v1
4444
with:
4545
bundler-cache: true
46+
- name: Turn on local Postgres
47+
run: |
48+
echo "$(pg_config --bindir)" >> $GITHUB_PATH
49+
50+
echo "Initializing database cluster..."
51+
export PGHOST="${RUNNER_TEMP//\\//}/postgres
52+
export PGDATA="$PGHOST/pgdata"
53+
mkdir -p "$PGDATA"
54+
55+
echo "Creating default headless passsword..."
56+
export PWFILE="$RUNNER_TEMP/pwfile"
57+
echo "postgres" > "$PWFILE"
58+
initdb --pgdata="$PGDATA" --username="postgres" --pwfile="$PWFILE"
59+
60+
echo "Starting Postgresql..."
61+
echo "unix_socket_directories = '$PGHOST'" >> "$PGDATA/postgresql.conf"
62+
pg_ctl start
63+
64+
echo "Creating user..."
65+
psql --host "$PGHOST" --username="postgres" --dbname="postgres" --command="CREATE USER $SIMPLE_SERVER_DATABASE_USERNAME PASSWORD '$SIMPLE_SERVER_DATABASE_PASSWORD'" --command="\du"
66+
67+
# (optional; because it would be created by Rails)
68+
# echo "Creating database..."
69+
# createdb --owner="$SIMPLE_SERVER_DATABASE_USERNAME" --username="postgres" "$PGDATABASE"
4670
- name: Setup DB
4771
run: bundle exec rake db:prepare
4872
- run: bundle exec rspec

0 commit comments

Comments
 (0)