Skip to content

Commit b91ef1f

Browse files
committed
ci: add PlanetScale to CI
1 parent 7956989 commit b91ef1f

40 files changed

+230
-110
lines changed

.eslintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"extends": ["prettier", "eslint:recommended", "plugin:markdown/recommended"],
33
"parserOptions": {
4-
"ecmaVersion": 2017
4+
"ecmaVersion": 2022
55
},
66
"plugins": ["markdown", "async-await"],
77
"env": {

.github/workflows/ci-linux.yml

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
mysql-version: ["mysql:8.0.18", "mysql:8.0.22", "mysql:5.7"]
3434
use-compression: [0]
3535
use-tls: [0]
36+
mysql_connection_url_key: [""]
3637
# TODO - add mariadb to the matrix. currently few tests are broken due to mariadb incompatibilities
3738
include:
3839
- node-version: "16.x"
@@ -51,26 +52,32 @@ jobs:
5152
mysql-version: "mysql:5.7"
5253
use-compression: 0
5354
use-tls: 0
54-
- node-version: "12.x"
55-
mysql-version: "mysql:5.7"
56-
use-compression: 0
57-
use-tls: 0
58-
- filter: "test-select-1"
55+
- filter: "test-select-1" # a number of tests does not work with mysql 5.1 due to old sql syntax, just testing basic connection
5956
node-version: "16.x"
6057
mysql-version: "datagrip/mysql:5.1"
6158
use-compression: 0
6259
use-tls: 0
60+
- node-version: "18.x"
61+
mysql_connection_url_key: "PS_MYSQL_URL"
62+
use-compression: 0
63+
use-tls: 0
64+
env:
65+
MYSQL_CONNECTION_URL: ${{ secrets[matrix.mysql_connection_url_key] }}
6366

64-
name: Node.js ${{ matrix.node-version }} - DB ${{ matrix.mysql-version }} - SSL=${{matrix.use-tls}} Compression=${{matrix.use-compression}}
67+
name: Node.js ${{ matrix.node-version }} - DB ${{ matrix.mysql-version }}${{ matrix.mysql_connection_url_key }} - SSL=${{matrix.use-tls}} Compression=${{matrix.use-compression}}
6568

6669
steps:
6770
- uses: actions/checkout@v3
71+
6872
- name: Set up MySQL
69-
run: docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_ROOT_PASSWORD=${{ env.MYSQL_PASSWORD }} -e MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} -v $PWD/mysqldata:/var/lib/mysql/ -v $PWD/examples/custom-conf:/etc/mysql/conf.d -v $PWD/examples/ssl/certs:/certs -p ${{ env.MYSQL_PORT }}:3306 ${{ matrix.mysql-version }}
73+
if: ${{ !startsWith(env.MYSQL_CONNECTION_URL, 'mysql://') }}
74+
run: docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} -v $PWD/mysqldata:/var/lib/mysql/ -v $PWD/examples/custom-conf:/etc/mysql/conf.d -v $PWD/examples/ssl/certs:/certs -p ${{ env.MYSQL_PORT }}:3306 ${{ matrix.mysql-version }}
75+
7076
- name: Set up Node.js ${{ matrix.node-version }}
7177
uses: actions/setup-node@v3
7278
with:
7379
node-version: ${{ matrix.node-version }}
80+
7481
- name: Cache dependencies
7582
uses: actions/cache@v3
7683
with:
@@ -80,14 +87,16 @@ jobs:
8087

8188
- name: Install npm dependencies
8289
run: npm ci
90+
8391
- name: Wait mysql server is ready
92+
if: ${{ !startsWith(env.MYSQL_CONNECTION_URL, 'mysql://') }}
8493
run: node tools/wait-up.js
8594

8695
- name: Run tests
8796
run: FILTER=${{matrix.filter}} MYSQL_USE_TLS=${{ matrix.use-tls }} MYSQL_USE_COMPRESSION=${{ matrix.use-compression }} npm run coverage-test
8897

8998
- run: echo "coverage-artifact-name=`echo -n "${{github.run_id}}-${{ matrix.node-version }}-${{ matrix.mysql-version }}-${{matrix.use-tls}}-${{matrix.use-compression}}" | shasum | cut -d " " -f 1`" >> $GITHUB_ENV
90-
- uses: actions/upload-artifact@v2
99+
- uses: actions/upload-artifact@v3
91100
with:
92101
name: coverage-${{env.coverage-artifact-name}}
93102
path: coverage/cobertura-coverage.xml

package-lock.json

Lines changed: 0 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
"eslint-plugin-async-await": "0.0.0",
8181
"eslint-plugin-markdown": "^3.0.0",
8282
"husky": "^8.0.2",
83-
"is-async-supported": "^1.2.0",
8483
"lint-staged": "^13.0.3",
8584
"mocha": "^10.0.0",
8685
"portfinder": "^1.0.28",

test/common.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ exports.waitDatabaseReady = function(callback) {
5454
};
5555

5656
exports.createConnection = function(args) {
57+
58+
const driver = require('../index.js');
59+
if (!args?.port && process.env.MYSQL_CONNECTION_URL) {
60+
return driver.createConnection({ ...args, uri: process.env.MYSQL_CONNECTION_URL })
61+
}
62+
5763
if (!args) {
5864
args = {};
5965
}
@@ -80,8 +86,6 @@ exports.createConnection = function(args) {
8086
connectTimeout: args && args.connectTimeout,
8187
};
8288

83-
// previously we had an adapter logic to benchmark against mysqljs/mysql and libmariaclient
84-
const driver = require('../index.js');
8589
const conn = driver.createConnection(params);
8690
return conn;
8791
};
@@ -114,10 +118,15 @@ exports.getConfig = function(input) {
114118
};
115119

116120
exports.createPool = function(args) {
121+
let driver = require('../index.js');
122+
if (!args?.port && process.env.MYSQL_CONNECTION_URL) {
123+
return driver.createPool({ ...args, uri: process.env.MYSQL_CONNECTION_URL })
124+
}
125+
117126
if (!args) {
118127
args = {};
119128
}
120-
let driver = require('../index.js');
129+
121130
if (process.env.BENCHMARK_MYSQL1) {
122131
driver = require('mysql');
123132
}
@@ -126,9 +135,9 @@ exports.createPool = function(args) {
126135
};
127136

128137
exports.createPoolCluster = function(args = {}) {
129-
let driver = require('../index.js');
130-
if (process.env.BENCHMARK_MYSQL1) {
131-
driver = require('mysql');
138+
const driver = require('../index.js');
139+
if (!args?.port && process.env.MYSQL_CONNECTION_URL) {
140+
return driver.createPoolCluster({ ...args, uri: process.env.MYSQL_CONNECTION_URL })
132141
}
133142
return driver.createPoolCluster(args)
134143
}

test/integration/connection/encoding/test-charset-results.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
'use strict';
22

3+
if (`${process.env.MYSQL_CONNECTION_URL}`.includes('pscale_pw_')) {
4+
console.log('skipping test for planetscale (unsupported non utf8 charsets)');
5+
process.exit(0);
6+
}
7+
38
const mysql = require('../../../../index.js');
49
const common = require('../../../common');
510
const connection = common.createConnection();

test/integration/connection/encoding/test-client-encodings.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
'use strict';
22

3+
if (`${process.env.MYSQL_CONNECTION_URL}`.includes('pscale_pw_')) {
4+
console.log('skipping test for planetscale (unsupported non utf8 charsets)');
5+
process.exit(0);
6+
}
7+
38
const common = require('../../../common');
49
const assert = require('assert');
510

test/integration/connection/encoding/test-non-bmp-chars.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
const common = require('../../../common');
44
const assert = require('assert');
55

6+
if (`${process.env.MYSQL_CONNECTION_URL}`.includes('pscale_pw_')) {
7+
console.log('skipping test for planetscale');
8+
process.exit(0);
9+
}
10+
611
// 4 bytes in utf8
712
const pileOfPoo = '💩';
813

test/integration/connection/encoding/test-track-encodings.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ const text = 'привет, мир';
88

99
connection.query('SET character_set_client=koi8r', err => {
1010
assert.ifError(err);
11-
connection.query('SELECT ?', [text], (err, rows) => {
11+
connection.query(`SELECT ? as result`, [text], (err, rows) => {
1212
assert.ifError(err);
13-
assert.equal(rows[0][text], text);
13+
assert.equal(rows[0].result, text);
1414
connection.query('SET character_set_client=cp1251', err => {
1515
assert.ifError(err);
16-
connection.query('SELECT ?', [text], (err, rows) => {
16+
connection.query(`SELECT ? as result`, [text], (err, rows) => {
1717
assert.ifError(err);
18-
assert.equal(rows[0][text], text);
18+
assert.equal(rows[0].result, text);
1919
connection.end();
2020
});
2121
});

test/integration/connection/test-binary-charset-string.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ const common = require('../../common');
44
const connection = common.createConnection();
55
const assert = require('assert');
66

7+
// TODO - this could be re-enabled
8+
if (`${process.env.MYSQL_CONNECTION_URL}`.includes('pscale_pw_')) {
9+
console.log('skipping test for planetscale');
10+
process.exit(0);
11+
}
12+
713
let rows = undefined;
814
let fields = undefined;
915
let rows1 = undefined;

0 commit comments

Comments
 (0)