From 997b743d3d7d9f3cd51ee304e74ff033530609f0 Mon Sep 17 00:00:00 2001 From: Igal Klebanov Date: Thu, 24 Oct 2024 15:34:50 +0300 Subject: [PATCH] ci: test against older TypeScript versions. (#1192) --- .github/workflows/test.yml | 43 +++++++++++++ package-lock.json | 8 +-- package.json | 2 +- src/query-builder/merge-query-builder.ts | 3 +- test/node/src/test-setup.ts | 79 +++++++++++++----------- test/node/src/transaction.test.ts | 2 +- test/node/tsconfig.json | 3 +- 7 files changed, 94 insertions(+), 46 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 966734093..bd08c9035 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,6 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: [18.x, 20.x, 22.x] @@ -41,6 +42,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: node-version: [18.x, 20.x, 22.x] @@ -67,6 +69,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: deno-version: [1.46.x] @@ -98,6 +101,7 @@ jobs: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: bun-version: [1.1.26] @@ -167,3 +171,42 @@ jobs: - name: Run cloudflare workers test run: npm run test:cloudflare-workers + + older-typescript-version: + name: Older TypeScript version + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + typescript-version: [ + ^4.6, # 28.2.2022 https://devblogs.microsoft.com/typescript/announcing-typescript-4-6/ + ^4.7, # 24.5.2022 https://devblogs.microsoft.com/typescript/announcing-typescript-4-7/ + ^4.8, # 25.8.2022 https://devblogs.microsoft.com/typescript/announcing-typescript-4-8/ + ^4.9, # 15.11.2022 https://devblogs.microsoft.com/typescript/announcing-typescript-4-9/ + ^5.0, # 16.3.2023 https://devblogs.microsoft.com/typescript/announcing-typescript-5-0/ + ^5.2, # 24.8.2023 https://devblogs.microsoft.com/typescript/announcing-typescript-5-1/ https://devblogs.microsoft.com/typescript/announcing-typescript-5-2/ + ^5.3, # 20.11.2023 https://devblogs.microsoft.com/typescript/announcing-typescript-5-3/ + ^5.4, # 6.3.2024 https://devblogs.microsoft.com/typescript/announcing-typescript-5-4/ + ] + + steps: + - uses: actions/checkout@v4 + + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 18.x + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run build with newer TypeScript + run: npm run build + + - name: Install older TypeScript + run: npm i -D typescript@${{ matrix.typescript-version }} tsd@${{ fromJson('{ "^4.6":"0.20.0", "^4.7":"0.22.0", "^4.8":"0.24.1", "^4.9":"0.27.0", "^5.0":"0.28.1", "^5.2":"0.29.0", "^5.3":"0.30.7", "^5.4":"0.31.2" }')[matrix.typescript-version] }} + + - name: Run tests with older TypeScript + run: npm run test:typings && npm run test:node:build diff --git a/package-lock.json b/package-lock.json index ccb093e18..164783d7a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,7 +35,7 @@ "tarn": "^3.0.2", "tedious": "^19.0.0", "tsd": "^0.31.1", - "typescript": "^5.6.2" + "typescript": "^5.6.3" }, "engines": { "node": ">=14.0.0" @@ -4190,9 +4190,9 @@ } }, "node_modules/typescript": { - "version": "5.6.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.2.tgz", - "integrity": "sha512-NW8ByodCSNCwZeghjN3o+JX5OFH0Ojg6sadjEKY4huZ52TqbJTJnDo5+Tw98lSy63NZvi4n+ez5m2u5d4PkZyw==", + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", "dev": true, "bin": { "tsc": "bin/tsc", diff --git a/package.json b/package.json index cbd571092..fc96cec28 100644 --- a/package.json +++ b/package.json @@ -97,6 +97,6 @@ "tarn": "^3.0.2", "tedious": "^19.0.0", "tsd": "^0.31.1", - "typescript": "^5.6.2" + "typescript": "^5.6.3" } } diff --git a/src/query-builder/merge-query-builder.ts b/src/query-builder/merge-query-builder.ts index 8bb9881a7..141d585bc 100644 --- a/src/query-builder/merge-query-builder.ts +++ b/src/query-builder/merge-query-builder.ts @@ -1,4 +1,4 @@ -import { AliasedExpression, type Expression } from '../expression/expression.js' +import { AliasedExpression, Expression } from '../expression/expression.js' import { InsertQueryNode } from '../operation-node/insert-query-node.js' import { MergeQueryNode } from '../operation-node/merge-query-node.js' import { OperationNodeSource } from '../operation-node/operation-node-source.js' @@ -45,7 +45,6 @@ import { SimplifySingleResult, SqlBool, } from '../util/type-utils.js' -import { InsertQueryBuilder } from './insert-query-builder.js' import { MergeResult } from './merge-result.js' import { NoResultError, diff --git a/test/node/src/test-setup.ts b/test/node/src/test-setup.ts index 987add26b..0c1e866e7 100644 --- a/test/node/src/test-setup.ts +++ b/test/node/src/test-setup.ts @@ -122,48 +122,53 @@ if (process.env.TEST_TRANSFORMER) { export const POOL_SIZE = 20 -export const DIALECT_CONFIGS = { - postgres: { - database: 'kysely_test', - host: 'localhost', - user: 'kysely', - port: 5434, - max: POOL_SIZE, - } satisfies PoolConfig, - - mysql: { - database: 'kysely_test', - host: 'localhost', - user: 'kysely', - password: 'kysely', - port: 3308, - // Return big numbers as strings just like pg does. - supportBigNumbers: true, - bigNumberStrings: true, +const POSTGRES_CONFIG: PoolConfig = { + database: 'kysely_test', + host: 'localhost', + user: 'kysely', + port: 5434, + max: POOL_SIZE, +} - connectionLimit: POOL_SIZE, - } satisfies PoolOptions, +const MYSQL_CONFIG: PoolOptions = { + database: 'kysely_test', + host: 'localhost', + user: 'kysely', + password: 'kysely', + port: 3308, + // Return big numbers as strings just like pg does. + supportBigNumbers: true, + bigNumberStrings: true, + + connectionLimit: POOL_SIZE, +} - mssql: { - authentication: { - options: { - password: 'KyselyTest0', - userName: 'sa', - }, - type: 'default', - }, +const MSSQL_CONFIG: ConnectionConfiguration = { + authentication: { options: { - connectTimeout: 3000, - database: 'kysely_test', - port: 21433, - trustServerCertificate: true, + password: 'KyselyTest0', + userName: 'sa', }, - server: 'localhost', - } satisfies ConnectionConfiguration, - - sqlite: { - databasePath: ':memory:', + type: 'default', + }, + options: { + connectTimeout: 3000, + database: 'kysely_test', + port: 21433, + trustServerCertificate: true, }, + server: 'localhost', +} + +const SQLITE_CONFIG = { + databasePath: ':memory:', +} + +export const DIALECT_CONFIGS = { + postgres: POSTGRES_CONFIG, + mysql: MYSQL_CONFIG, + mssql: MSSQL_CONFIG, + sqlite: SQLITE_CONFIG, } export const DB_CONFIGS: PerDialect = { diff --git a/test/node/src/transaction.test.ts b/test/node/src/transaction.test.ts index 2c7ec2afa..a0e6e4a30 100644 --- a/test/node/src/transaction.test.ts +++ b/test/node/src/transaction.test.ts @@ -66,7 +66,7 @@ for (const dialect of DIALECTS) { 'repeatable read', 'serializable', ...(dialect === 'mssql' ? (['snapshot'] as const) : []), - ] satisfies IsolationLevel[]) { + ] as const) { it(`should set the transaction isolation level as "${isolationLevel}"`, async () => { await ctx.db .transaction() diff --git a/test/node/tsconfig.json b/test/node/tsconfig.json index 098395738..83e6196bb 100644 --- a/test/node/tsconfig.json +++ b/test/node/tsconfig.json @@ -3,6 +3,7 @@ "include": ["src/**/*"], "compilerOptions": { "module": "CommonJS", - "outDir": "dist" + "outDir": "dist", + "skipLibCheck": true } }