From ce721da8635e500714fc9ce41f65d17471d0ba6d Mon Sep 17 00:00:00 2001 From: Jonathan Raoult <2046871+jraoult@users.noreply.github.com> Date: Thu, 25 Apr 2024 17:29:51 +0100 Subject: [PATCH 1/4] Fix a regression to allow url config to be an object --- bin/node-pg-migrate.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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)) { From 80f6ac22d13ef8362ec10e63025b9b552e2d1e0d Mon Sep 17 00:00:00 2001 From: Jonathan Raoult <2046871+jraoult@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:03:31 +0100 Subject: [PATCH 2/4] Add integration test for config --- .github/workflows/postgres-test.yml | 74 ++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 6 deletions(-) diff --git a/.github/workflows/postgres-test.yml b/.github/workflows/postgres-test.yml index 491ef7e7..dbb22e22 100644 --- a/.github/workflows/postgres-test.yml +++ b/.github/workflows/postgres-test.yml @@ -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 ] + postgres_version: [ 12.18, 13.14, 14.11, 15.6, 16.2 ] fail-fast: false timeout-minutes: 10 @@ -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 @@ -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' + 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: @@ -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 From 8068d69df5213210ba190ea57cbacd9a030caeda Mon Sep 17 00:00:00 2001 From: Jonathan Raoult <2046871+jraoult@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:07:29 +0100 Subject: [PATCH 3/4] Fix formatting --- .github/workflows/postgres-test.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/postgres-test.yml b/.github/workflows/postgres-test.yml index dbb22e22..7696ee78 100644 --- a/.github/workflows/postgres-test.yml +++ b/.github/workflows/postgres-test.yml @@ -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] + postgres_version: [12.18, 13.14, 14.11, 15.6, 16.2] fail-fast: false timeout-minutes: 10 @@ -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 @@ -129,8 +129,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 @@ -304,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 From 4e090380dc34cb678daa9a9fd8372a5499ebf3ce Mon Sep 17 00:00:00 2001 From: Jonathan Raoult <2046871+jraoult@users.noreply.github.com> Date: Mon, 29 Apr 2024 14:19:11 +0100 Subject: [PATCH 4/4] Fix jobs and steps naming --- .github/workflows/postgres-test.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/postgres-test.yml b/.github/workflows/postgres-test.yml index 7696ee78..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,7 +125,7 @@ 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: + config-2-test: runs-on: ubuntu-latest strategy: matrix: @@ -151,7 +151,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 2 Test: pg-${{ matrix.postgres_version }}, node-${{ matrix.node_version }}, ubuntu-latest' steps: - name: Checkout uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4