Skip to content

Commit

Permalink
fix: restore support url as an object in configuration (#1119)
Browse files Browse the repository at this point in the history
  • Loading branch information
jraoult authored Apr 29, 2024
1 parent 4bf487f commit b9cf8e9
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 3 deletions.
66 changes: 64 additions & 2 deletions .github/workflows/postgres-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ jobs:
env:
DATABASE_URL: postgres://ubuntu:ubuntu@localhost:5432/integration_test

config-test:
config-1-test:
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -87,7 +87,7 @@ jobs:
# Maps tcp port 5432 on service container to the host
- 5432:5432

name: 'Config Test: pg-${{ matrix.postgres_version }}, node-${{ matrix.node_version }}, ubuntu-latest'
name: 'Config 1 Test: pg-${{ matrix.postgres_version }}, node-${{ matrix.node_version }}, ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4
Expand Down Expand Up @@ -125,6 +125,68 @@ jobs:
- name: Integration Test
run: pnpm run migrate up -m test/migrations && pnpm run migrate down 0 -m test/migrations --timestamps

config-2-test:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [20]
postgres_version: [16.2]
fail-fast: false
timeout-minutes: 10

services:
postgres:
image: postgres:${{ matrix.postgres_version }}-alpine
env:
POSTGRES_USER: ubuntu
POSTGRES_PASSWORD: ubuntu
POSTGRES_DB: integration_test
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432

name: 'Config 2 Test: pg-${{ matrix.postgres_version }}, node-${{ matrix.node_version }}, ubuntu-latest'
steps:
- name: Checkout
uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4

- name: Install pnpm
uses: pnpm/action-setup@a3252b78c470c02df07e9d59298aecedc3ccdd6d # v3.0.0

- name: Set node version to ${{ matrix.node_version }}
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node_version }}
cache: 'pnpm'

- name: Install deps
run: pnpm install

- name: Build
run: pnpm run build

- name: Write URL object config
run: |
mkdir -p config
cat > config/default.json << 'EOF'
{
"db": {
"url": {
"connectionString": "postgres://ubuntu:ubuntu@localhost:5432/integration_test"
}
}
}
EOF
- name: Integration Test for URL object config
run: pnpm run migrate up -m test/migrations && pnpm run migrate down 0 -m test/migrations --timestamps

dotenv-test:
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion bin/node-pg-migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ function readJson(json: unknown): void {
tsconfigPath = applyIf(tsconfigPath, tsconfigArg, json, isString);

// @ts-expect-error: this is a TS 4.8 bug
if ('url' in json && json.url && isString(json.url)) {
if ('url' in json && json.url) {
// @ts-expect-error: this is a TS 4.8 bug
DB_CONNECTION ??= json.url;
} else if (isClientConfig(json)) {
Expand Down

0 comments on commit b9cf8e9

Please sign in to comment.