Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restore support url as an object in configuration #1119

Merged
merged 4 commits into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
74 changes: 68 additions & 6 deletions .github/workflows/postgres-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [18, 20]
postgres_version: [12.18, 13.14, 14.11, 15.6, 16.2]
node_version: [ 18, 20 ]
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved
postgres_version: [ 12.18, 13.14, 14.11, 15.6, 16.2 ]
fail-fast: false
timeout-minutes: 10

Expand Down Expand Up @@ -65,8 +65,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [20]
postgres_version: [16.2]
node_version: [ 20 ]
postgres_version: [ 16.2 ]
fail-fast: false
timeout-minutes: 10

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-url-object-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 Test: pg-${{ matrix.postgres_version }}, node-${{ matrix.node_version }}, ubuntu-latest'
Shinigami92 marked this conversation as resolved.
Show resolved Hide resolved
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 Expand Up @@ -242,8 +304,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node_version: [20]
postgres_version: [16.2]
node_version: [ 20 ]
postgres_version: [ 16.2 ]
fail-fast: false
timeout-minutes: 10

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