Skip to content

Commit 5074155

Browse files
committed
[misc] deno CI addition
1 parent 6ec05d6 commit 5074155

28 files changed

+126
-80
lines changed

.github/workflows/ci.yml

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ jobs:
3636
name: build matrix
3737
uses: mariadb-corporation/connector-ci-build-matrix@main
3838
with:
39-
additional-matrix: '[{"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "node": 24}, {"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "node": 20}]'
39+
additional-matrix: '[{"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "node": 24}, {"name": "MariaDB 11.4", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "node": 20}, {"name": "MariaDB 11.4 - DENO", "os": "ubuntu-latest", "db-type": "community", "db-tag": "11.4", "deno": "lts"}]'
4040

4141
ci:
42-
name: ${{ matrix.name }}${{ matrix.node != 22 && format(' - node {0}', matrix.node) || '' }}
42+
name: ${{ matrix.name }}${{ !matrix.deno && matrix.node != 22 && format(' - node {0}', matrix.node) || '' }}
4343
needs: setup
4444
timeout-minutes: 50
4545
strategy:
@@ -66,13 +66,22 @@ jobs:
6666
os: ${{ matrix.os }}
6767

6868
- uses: actions/setup-node@v4
69+
if: ${{ !matrix.deno }}
6970
with:
7071
node-version: ${{ matrix.node }}
7172

73+
- name: Setup Deno
74+
uses: denoland/setup-deno@v2
75+
if: ${{ matrix.deno }}
76+
with:
77+
deno-version: ${{ matrix.deno }}
78+
7279
- name: Install dependencies
80+
if: ${{ !matrix.deno }}
7381
run: npm install
7482

75-
- name: Run Tests
83+
- name: Run Tests node
84+
if: ${{ !matrix.deno }}
7685
run: npm run coverage:test
7786
env:
7887
LOCAL_DB: ${{ steps.setup-env.outputs.database-type }}
@@ -81,7 +90,19 @@ jobs:
8190
DB_VERSION: ${{ matrix.db-tag }}
8291
TEST_TRACE: 'true'
8392

93+
- name: Run Tests deno
94+
if: ${{ matrix.deno }}
95+
run: |
96+
deno task test
97+
env:
98+
LOCAL_DB: ${{ steps.setup-env.outputs.database-type }}
99+
DB_TYPE: ${{ matrix.db-type }}
100+
TEST_DB_SERVER_CERT: ${{ matrix.db-type == 'container' && './.github/workflows/certs/server.crt' || '' }}
101+
DB_VERSION: ${{ matrix.db-tag }}
102+
TEST_TRACE: 'true'
103+
84104
- name: Download Codecov uploader
105+
if: ${{ !matrix.deno }}
85106
shell: bash
86107
run: |
87108
case "$RUNNER_OS" in
@@ -105,6 +126,7 @@ jobs:
105126
106127
- name: Generate Coverage Report
107128
shell: bash
129+
if: ${{ !matrix.deno }}
108130
run: |
109131
npm run coverage:create
110132
case "$RUNNER_OS" in

deno.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"vitest": "npm:[email protected]"
1212
},
1313
"tasks": {
14-
"test": "deno run -A npm:vitest test/integration/query.test.js"
14+
"test": "deno run -A npm:vitest test/**/*.js"
1515
},
1616
"fmt": {
1717
"files": {

test/base.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ export function getEnv(key) {
121121
return undefined;
122122
}
123123

124+
export function isWindows() {
125+
if (typeof Deno !== 'undefined') {
126+
return 'windows' === Deno.build.os;
127+
}
128+
return process.platform === 'win32';
129+
}
130+
124131
export function isLocalDb() {
125132
const localEnv = getEnv('LOCAL_DB');
126133
return localEnv === 'local' || localEnv === undefined;

test/integration/auth-plugin.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
'use strict';
55

6-
import * as base from '../base.js';
76
import Conf from '../conf.js';
87
import { assert, describe, test, beforeAll, afterAll } from 'vitest';
98

109
import fs from 'node:fs';
1110
import os from 'node:os';
1211
import path from 'node:path';
13-
import { isMaxscale, getHostSuffix, getEnv, createConnection, isLocalDb } from '../base.js';
12+
import { isMaxscale, getHostSuffix, getEnv, createConnection, isLocalDb, isWindows } from '../base.js';
1413

1514
describe.concurrent('authentication plugin', () => {
1615
let rsaPublicKey = getEnv('TEST_RSA_PUBLIC_KEY');
@@ -157,7 +156,7 @@ describe.concurrent('authentication plugin', () => {
157156

158157
test('name pipe authentication plugin', async ({ skip }) => {
159158
if (
160-
process.platform !== 'win32' ||
159+
!isWindows() ||
161160
isMaxscale(shareConn) ||
162161
!shareConn.info.isMariaDB() ||
163162
!shareConn.info.hasMinVersion(10, 1, 11) ||
@@ -193,7 +192,7 @@ describe.concurrent('authentication plugin', () => {
193192
test('unix socket authentication plugin', async ({ skip }) => {
194193
if (
195194
isMaxscale(shareConn) ||
196-
process.platform === 'win32' ||
195+
isWindows() ||
197196
!shareConn.info.isMariaDB() ||
198197
!shareConn.info.hasMinVersion(10, 1, 11) ||
199198
!isLocalDb() ||

test/integration/batch-callback.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
'use strict';
55

66
import * as base from '../base.js';
7-
import * as Capabilities from '../../lib/const/capabilities';
7+
import * as Capabilities from '../../lib/const/capabilities.js';
88
import fs from 'node:fs';
99
import os from 'node:os';
1010
import path from 'node:path';

test/integration/batch-geometry-type.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import * as base from '../base.js';
77
import Conf from '../conf.js';
8-
import * as Capabilities from '../../lib/const/capabilities';
8+
import * as Capabilities from '../../lib/const/capabilities.js';
99
import { assert, describe, test, beforeAll, afterAll } from 'vitest';
1010
import { createConnection } from '../base.js';
1111

test/integration/cluster.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
'use strict';
55

66
import Conf from '../conf.js';
7-
import * as basePromise from '../../promise';
8-
import * as baseCallback from '../../callback';
9-
import Proxy from '../tools/proxy';
7+
import * as basePromise from '../../promise.js';
8+
import * as baseCallback from '../../callback.js';
9+
import Proxy from '../tools/proxy.js';
1010
import { createConnection, isMaxscale } from '../base.js';
1111
import { assert, expect, describe, test, beforeAll, afterAll, beforeEach } from 'vitest';
1212

test/integration/connection-meta.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
// Copyright (c) 2015-2025 MariaDB Corporation Ab
33

44
'use strict';
5-
import * as basePromise from '../../promise';
6-
import * as baseCallback from '../../callback';
5+
import * as basePromise from '../../promise.js';
6+
import * as baseCallback from '../../callback.js';
77
import * as base from '../base.js';
88
import { createConnection, isMaxscale } from '../base.js';
99
import { getEnv } from '../base.js';

test/integration/connection-opts.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ describe.sequential('connection option', () => {
6464
});
6565

6666
test.sequential('timezone Z', async ({ skip }) => {
67+
if (!process) return skip();
6768
// node.js before v13 doesn't permit setting TZ value repeatedly
6869
if (parseInt(process.versions.node.split('.')[0]) <= 12) return skip();
6970

@@ -93,6 +94,7 @@ describe.sequential('connection option', () => {
9394
});
9495

9596
test.sequential('timezone +10h00', async ({ skip }) => {
97+
if (!process) return;
9698
// node.js before v13 doesn't permit setting TZ value repeatedly
9799
if (parseInt(process.versions.node.split('.')[0]) <= 12) return skip();
98100

@@ -111,6 +113,7 @@ describe.sequential('connection option', () => {
111113
});
112114

113115
test.sequential('timezone Etc/GMT-10', async ({ skip }) => {
116+
if (!process) return skip();
114117
// node.js before v13 doesn't permit setting TZ value repeatedly
115118
if (parseInt(process.versions.node.split('.')[0]) <= 12) return skip();
116119

@@ -129,6 +132,7 @@ describe.sequential('connection option', () => {
129132
});
130133

131134
test.sequential('timezone GMT+10', async ({ skip }) => {
135+
if (!process) return skip();
132136
// node.js before v13 doesn't permit setting TZ value repeatedly
133137
if (parseInt(process.versions.node.split('.')[0]) <= 12) return skip();
134138

@@ -159,6 +163,7 @@ describe.sequential('connection option', () => {
159163
});
160164

161165
test.sequential('Server with different tz', async ({ skip }) => {
166+
if (!process) return skip();
162167
// node.js before v13 doesn't permit setting TZ value repeatedly
163168
if (parseInt(process.versions.node.split('.')[0]) <= 12) return skip();
164169
if (isMaxscale(shareConn)) return skip();

test/integration/connection.test.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import Collations from '../../lib/const/collations.js';
77
import Conf from '../conf.js';
8-
import Connection from '../../lib/connection';
9-
import ConnOptions from '../../lib/config/connection-options';
8+
import Connection from '../../lib/connection.js';
9+
import ConnOptions from '../../lib/config/connection-options.js';
1010
import { isMaxscale, getHostSuffix, createConnection, createCallbackConnection, utf8Collation } from '../base.js';
1111
import { expect, assert, describe, test, beforeAll, afterAll } from 'vitest';
1212

@@ -114,7 +114,9 @@ describe.concurrent('connection', () => {
114114
assert.isTrue(err.message.includes('close forced'));
115115
resolve();
116116
});
117-
process.nextTick(conn.__tests.getSocket().destroy.bind(conn.__tests.getSocket(), new Error('close forced')));
117+
setTimeout(() => {
118+
conn.__tests.getSocket().destroy(new Error('close forced'));
119+
}, 0);
118120
});
119121
});
120122

@@ -126,7 +128,9 @@ describe.concurrent('connection', () => {
126128
assert.isTrue(err.message.includes('Connection timeout: failed to create socket after'));
127129
resolve();
128130
});
129-
process.nextTick(conn.__tests.getSocket().destroy.bind(conn.__tests.getSocket()));
131+
setTimeout(() => {
132+
conn.__tests.getSocket().destroy();
133+
}, 0);
130134
});
131135
});
132136

@@ -760,25 +764,25 @@ describe.concurrent('connection', () => {
760764
test('pause socket', async () => {
761765
const conn = await createConnection();
762766
conn.pause();
763-
const startTime = process.hrtime();
767+
const startTime = performance.now();
764768
setTimeout(() => {
765769
conn.resume();
766770
}, 500);
767771

768772
const rows = await conn.query("SELECT '1'");
769773
assert.deepEqual(rows, [{ 1: '1' }]);
770-
const diff = process.hrtime(startTime);
774+
const diff = performance.now() - startTime;
771775
await conn.end();
772776
//query has taken more than 500ms
773-
assert.isTrue(diff[1] > 499000000, ' diff[1]:' + diff[1] + ' expected to be more than 500000000');
777+
assert.isTrue(diff > 499, ' diff:' + diff + ' expected to be more than 500');
774778
});
775779

776780
test('pause socket callback', async () => {
777781
const conn = createCallbackConnection();
778782
await new Promise((resolve, reject) => {
779783
conn.connect((err) => {
780784
conn.pause();
781-
const startTime = process.hrtime();
785+
const startTime = performance.now();
782786
setTimeout(() => {
783787
conn.resume();
784788
}, 500);
@@ -788,9 +792,9 @@ describe.concurrent('connection', () => {
788792
reject(err);
789793
} else {
790794
assert.deepEqual(rows, [{ 1: '1' }]);
791-
const diff = process.hrtime(startTime);
795+
const diff = performance.now() - startTime;
792796
//query has taken more than 500ms
793-
assert.isTrue(diff[1] > 499000000, ' diff[1]:' + diff[1] + ' expected to be more than 500000000');
797+
assert.isTrue(diff > 499, ' diff:' + diff + ' expected to be more than 500');
794798
conn.end();
795799
resolve();
796800
}
@@ -934,7 +938,7 @@ describe.concurrent('connection', () => {
934938
});
935939
throw new Error('must have thrown error !');
936940
} catch (err) {
937-
console.log(err);
941+
// console.log(err);
938942
assert.equal(err.sqlState, 'HY000', err.message);
939943
assert.equal(err.code, 'ER_MUST_CHANGE_PASSWORD_LOGIN');
940944
} finally {

0 commit comments

Comments
 (0)