diff --git a/.github/workflows/postgres-test.yml b/.github/workflows/postgres-test.yml index 491ef7e7..60fbe1c8 100644 --- a/.github/workflows/postgres-test.yml +++ b/.github/workflows/postgres-test.yml @@ -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: @@ -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 @@ -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: diff --git a/bin/node-pg-migrate.ts b/bin/node-pg-migrate.ts index d9450d79..4dddb088 100755 --- a/bin/node-pg-migrate.ts +++ b/bin/node-pg-migrate.ts @@ -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)) {