From 0c9e644e22c6121290815b4b1741b1b554222e11 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Sat, 25 May 2024 20:53:31 +0800 Subject: [PATCH 1/9] add deno smoke test action --- .github/workflows/ci-linux.yml | 50 ++++++++++++++++++++++++++++++++++ test/deno.ts | 26 ++++++++++++++++++ 2 files changed, 76 insertions(+) create mode 100644 test/deno.ts diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index c33bb6877b..e524af5880 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -108,3 +108,53 @@ jobs: FILTER: test-select-1|test-select-ssl run: bun run test:bun timeout-minutes: 1 + + tests-linux-deno: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + deno-version: [latest, canary] + mysql-version: ["mysql:8.0.33"] + use-compression: [0, 1] + use-tls: [0,1] + + name: Deno ${{ matrix.deno-version }} - DB ${{ matrix.mysql-version }} - SSL=${{matrix.use-tls}} Compression=${{matrix.use-compression}} + + steps: + - uses: actions/checkout@v4 + - name: Set up MySQL + run: docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} -v $PWD/mysqldata:/var/lib/mysql/ -v $PWD/test/fixtures/custom-conf:/etc/mysql/conf.d -v $PWD/test/fixtures/ssl/certs:/certs -p ${{ env.MYSQL_PORT }}:3306 ${{ matrix.mysql-version }} + + - name: Set up Deno ${{ matrix.deno-version }} + uses: denoland/setup-deno@v1 + with: + bun-version: ${{ matrix.deno-version }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.npm + key: npm-linux-${{ hashFiles('package-lock.json') }} + restore-keys: npm-linux- + + - name: Install npm dependencies + run: npm ci + + - name: Wait mysql server is ready + run: node tools/wait-up.js + + # todo: check what we need to do to run all tests with deno + - name: run tests + env: + MYSQL_USER: ${{ env.MYSQL_USER }} + MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} + MYSQL_PORT: ${{ env.MYSQL_PORT }} + MYSQL_USE_COMPRESSION: ${{ matrix.use-compression }} + MYSQL_USE_TLS: ${{ matrix.use-tls }} + run: deno test --allow-net --allow-env --allow-read --allow-write --allow-plugin --unstable test/deno.ts + timeout-minutes: 1 \ No newline at end of file diff --git a/test/deno.ts b/test/deno.ts new file mode 100644 index 0000000000..211c76176e --- /dev/null +++ b/test/deno.ts @@ -0,0 +1,26 @@ +import { createRequire } from 'node:module' +const require = createRequire(import.meta.url); +const mysql = require('../index.js'); + +const connection = mysql.createConnection({ + host: Deno.env.MYSQL_HOST, + port: Deno.env.MYSQL_PORT, + username: Deno.env.MYSQL_USER, + password: Deno.env.MYSQL_PASSWORD, + database: Deno.env.MYSQL_DATABASE, +}); + +connection.on('error', (err) => { + console.error(err); + Deno.exit(1); +}); + +connection.on('connect', () => { + connection.query('SELECT 1 + 1 AS solution', (err, rows) => { + if (err) { + console.error(err); + Deno.exit(1); + } + connection.end(); + }); +}); \ No newline at end of file From 396bd18c95366fc8c4c9b3c851e4ba01878999cd Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Sat, 25 May 2024 21:09:49 +0800 Subject: [PATCH 2/9] fix action --- .github/workflows/ci-linux.yml | 98 +++++++++++++++++----------------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index e524af5880..957c755e9a 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -109,52 +109,52 @@ jobs: run: bun run test:bun timeout-minutes: 1 - tests-linux-deno: - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - deno-version: [latest, canary] - mysql-version: ["mysql:8.0.33"] - use-compression: [0, 1] - use-tls: [0,1] - - name: Deno ${{ matrix.deno-version }} - DB ${{ matrix.mysql-version }} - SSL=${{matrix.use-tls}} Compression=${{matrix.use-compression}} - - steps: - - uses: actions/checkout@v4 - - name: Set up MySQL - run: docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} -v $PWD/mysqldata:/var/lib/mysql/ -v $PWD/test/fixtures/custom-conf:/etc/mysql/conf.d -v $PWD/test/fixtures/ssl/certs:/certs -p ${{ env.MYSQL_PORT }}:3306 ${{ matrix.mysql-version }} - - - name: Set up Deno ${{ matrix.deno-version }} - uses: denoland/setup-deno@v1 - with: - bun-version: ${{ matrix.deno-version }} - - - name: Set up Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - name: Cache dependencies - uses: actions/cache@v4 - with: - path: ~/.npm - key: npm-linux-${{ hashFiles('package-lock.json') }} - restore-keys: npm-linux- - - - name: Install npm dependencies - run: npm ci - - - name: Wait mysql server is ready - run: node tools/wait-up.js - - # todo: check what we need to do to run all tests with deno - - name: run tests - env: - MYSQL_USER: ${{ env.MYSQL_USER }} - MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} - MYSQL_PORT: ${{ env.MYSQL_PORT }} - MYSQL_USE_COMPRESSION: ${{ matrix.use-compression }} - MYSQL_USE_TLS: ${{ matrix.use-tls }} - run: deno test --allow-net --allow-env --allow-read --allow-write --allow-plugin --unstable test/deno.ts - timeout-minutes: 1 \ No newline at end of file + tests-linux-deno: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + deno-version: [latest, canary] + mysql-version: ["mysql:8.0.33"] + use-compression: [0, 1] + use-tls: [0,1] + + name: Deno ${{ matrix.deno-version }} - DB ${{ matrix.mysql-version }} - SSL=${{matrix.use-tls}} Compression=${{matrix.use-compression}} + + steps: + - uses: actions/checkout@v4 + - name: Set up MySQL + run: docker run -d -e MYSQL_ALLOW_EMPTY_PASSWORD=1 -e MYSQL_DATABASE=${{ env.MYSQL_DATABASE }} -v $PWD/mysqldata:/var/lib/mysql/ -v $PWD/test/fixtures/custom-conf:/etc/mysql/conf.d -v $PWD/test/fixtures/ssl/certs:/certs -p ${{ env.MYSQL_PORT }}:3306 ${{ matrix.mysql-version }} + + - name: Set up Deno ${{ matrix.deno-version }} + uses: denoland/setup-deno@v1 + with: + deno-version: ${{ matrix.deno-version }} + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Cache dependencies + uses: actions/cache@v4 + with: + path: ~/.npm + key: npm-linux-${{ hashFiles('package-lock.json') }} + restore-keys: npm-linux- + + - name: Install npm dependencies + run: npm ci + + - name: Wait mysql server is ready + run: node tools/wait-up.js + + # todo: check what we need to do to run all tests with deno + - name: run tests + env: + MYSQL_USER: ${{ env.MYSQL_USER }} + MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} + MYSQL_PORT: ${{ env.MYSQL_PORT }} + MYSQL_USE_COMPRESSION: ${{ matrix.use-compression }} + MYSQL_USE_TLS: ${{ matrix.use-tls }} + run: deno test --allow-net --allow-env --allow-read --allow-write --allow-plugin --unstable test/deno.ts + timeout-minutes: 1 \ No newline at end of file From 4644d0328b62a8a06bb6fd929cd190e232621aab Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Sat, 25 May 2024 21:27:22 +0800 Subject: [PATCH 3/9] lint --- .github/workflows/ci-linux.yml | 2 +- test/deno.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 957c755e9a..619850fcf7 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -114,7 +114,7 @@ jobs: strategy: fail-fast: false matrix: - deno-version: [latest, canary] + deno-version: [v1.43.6, canary] mysql-version: ["mysql:8.0.33"] use-compression: [0, 1] use-tls: [0,1] diff --git a/test/deno.ts b/test/deno.ts index 211c76176e..5a48306270 100644 --- a/test/deno.ts +++ b/test/deno.ts @@ -1,4 +1,4 @@ -import { createRequire } from 'node:module' +import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); const mysql = require('../index.js'); @@ -16,11 +16,11 @@ connection.on('error', (err) => { }); connection.on('connect', () => { - connection.query('SELECT 1 + 1 AS solution', (err, rows) => { + connection.query('SELECT 1 + 1 AS solution', (err) => { if (err) { - console.error(err); - Deno.exit(1); + console.error(err); + Deno.exit(1); } connection.end(); - }); -}); \ No newline at end of file + }); +}); From 7e267798c7bfa3cf76bb38921776c4c0eb1c8c81 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Sat, 25 May 2024 21:48:33 +0800 Subject: [PATCH 4/9] use explicit padding in publicEncrypt --- lib/auth_plugins/caching_sha2_password.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/auth_plugins/caching_sha2_password.js b/lib/auth_plugins/caching_sha2_password.js index 4245f934ea..866326363c 100644 --- a/lib/auth_plugins/caching_sha2_password.js +++ b/lib/auth_plugins/caching_sha2_password.js @@ -36,7 +36,10 @@ function encrypt(password, scramble, key) { Buffer.from(`${password}\0`, 'utf8'), scramble ); - return crypto.publicEncrypt(key, stage1); + return crypto.publicEncrypt({ + key, + padding: crypto.constants.RSA_PKCS1_OAEP_PADDING + }, stage1); } module.exports = (pluginOptions = {}) => ({ connection }) => { From d6f67f1b39923e7037f8a0e68d208f41e9a5bf08 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Sat, 25 May 2024 21:54:53 +0800 Subject: [PATCH 5/9] fix deno args --- .github/workflows/ci-linux.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index 619850fcf7..9df30a8cd1 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -156,5 +156,5 @@ jobs: MYSQL_PORT: ${{ env.MYSQL_PORT }} MYSQL_USE_COMPRESSION: ${{ matrix.use-compression }} MYSQL_USE_TLS: ${{ matrix.use-tls }} - run: deno test --allow-net --allow-env --allow-read --allow-write --allow-plugin --unstable test/deno.ts + run: deno test --allow-net --allow-env --allow-read test/deno.ts timeout-minutes: 1 \ No newline at end of file From ec7864599cb8ed773d34a384422f474cc16ea019 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Sat, 25 May 2024 22:10:06 +0800 Subject: [PATCH 6/9] fix test --- test/deno.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/deno.ts b/test/deno.ts index 5a48306270..24b7e6fd80 100644 --- a/test/deno.ts +++ b/test/deno.ts @@ -1,22 +1,22 @@ -import { createRequire } from 'node:module'; +import { createRequire } from "https://deno.land/std@0.177.0/node/module.ts"; const require = createRequire(import.meta.url); const mysql = require('../index.js'); const connection = mysql.createConnection({ - host: Deno.env.MYSQL_HOST, - port: Deno.env.MYSQL_PORT, - username: Deno.env.MYSQL_USER, - password: Deno.env.MYSQL_PASSWORD, - database: Deno.env.MYSQL_DATABASE, + host: Deno.env.get('MYSQL_HOST'), + port: Deno.env.get('MYSQL_PORT'), + username: Deno.env.get('MYSQL_USER'), + password: Deno.env.get('MYSQL_PASSWORD'), + database: Deno.env.get('MYSQL_DATABASE'), }); -connection.on('error', (err) => { +connection.on('error', (err: Error) => { console.error(err); Deno.exit(1); }); connection.on('connect', () => { - connection.query('SELECT 1 + 1 AS solution', (err) => { + connection.query('SELECT 1 + 1 AS solution', (err: Error) => { if (err) { console.error(err); Deno.exit(1); From 897482a9cc76ff7faf54ed982419d5323dfb38db Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 27 May 2024 09:20:01 +1000 Subject: [PATCH 7/9] use node:module --- test/deno.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/deno.ts b/test/deno.ts index 24b7e6fd80..155483864f 100644 --- a/test/deno.ts +++ b/test/deno.ts @@ -1,4 +1,4 @@ -import { createRequire } from "https://deno.land/std@0.177.0/node/module.ts"; +import { createRequire } from "node:module"; const require = createRequire(import.meta.url); const mysql = require('../index.js'); From d3acac70e7455d4cd75018d98e07f01ed4c9b71e Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 27 May 2024 09:39:08 +1000 Subject: [PATCH 8/9] temporarily disable eslint for deno --- test/deno.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/deno.ts b/test/deno.ts index 155483864f..0d9495293b 100644 --- a/test/deno.ts +++ b/test/deno.ts @@ -1,3 +1,6 @@ +// TODO: fix "[warn] Code style issues found in the above file. Run Prettier to fix." error +/* eslint-disable */ + import { createRequire } from "node:module"; const require = createRequire(import.meta.url); const mysql = require('../index.js'); @@ -5,7 +8,7 @@ const mysql = require('../index.js'); const connection = mysql.createConnection({ host: Deno.env.get('MYSQL_HOST'), port: Deno.env.get('MYSQL_PORT'), - username: Deno.env.get('MYSQL_USER'), + user: Deno.env.get('MYSQL_USER'), password: Deno.env.get('MYSQL_PASSWORD'), database: Deno.env.get('MYSQL_DATABASE'), }); From 806487b643fce1c0ed168bf94885ff6b4c549b20 Mon Sep 17 00:00:00 2001 From: Andrey Sidorov Date: Mon, 27 May 2024 09:43:57 +1000 Subject: [PATCH 9/9] prettier --- test/deno.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/test/deno.ts b/test/deno.ts index 0d9495293b..ae5e6ba987 100644 --- a/test/deno.ts +++ b/test/deno.ts @@ -1,7 +1,4 @@ -// TODO: fix "[warn] Code style issues found in the above file. Run Prettier to fix." error -/* eslint-disable */ - -import { createRequire } from "node:module"; +import { createRequire } from 'node:module'; const require = createRequire(import.meta.url); const mysql = require('../index.js');