Skip to content

Commit a67989c

Browse files
authored
🤖 TEST: Run test on GitHub Action (#19)
Only run test on Node.js >= 14
1 parent 3d04360 commit a67989c

File tree

21 files changed

+145
-131
lines changed

21 files changed

+145
-131
lines changed

‎.autod.conf.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ module.exports = {
1414
'autod',
1515
'eslint',
1616
'eslint-config-egg',
17-
'supertest',
1817
],
1918
exclude: [
2019
'./test/fixtures',

‎.github/workflows/nodejs.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# This workflow will do a clean install of node dependencies, build the source code and run tests across different versions of node
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3+
4+
name: Node.js CI
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
- master
11+
pull_request:
12+
branches:
13+
- main
14+
- master
15+
schedule:
16+
- cron: '0 2 * * *'
17+
18+
jobs:
19+
build:
20+
runs-on: ${{ matrix.os }}
21+
22+
services:
23+
mysql:
24+
image: mysql:5
25+
env:
26+
MYSQL_ALLOW_EMPTY_PASSWORD: true
27+
MYSQL_DATABASE: test
28+
ports:
29+
- 3306:3306
30+
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=5
31+
32+
strategy:
33+
fail-fast: false
34+
matrix:
35+
node-version: [14, 16, 18]
36+
os: [ubuntu-latest]
37+
38+
steps:
39+
- name: Checkout Git Source
40+
uses: actions/checkout@v2
41+
42+
- name: Use Node.js ${{ matrix.node-version }}
43+
uses: actions/setup-node@v1
44+
with:
45+
node-version: ${{ matrix.node-version }}
46+
47+
- name: Install Dependencies
48+
run: npm i
49+
50+
- name: Continuous Integration
51+
run: npm run ci
52+
53+
- name: Code Coverage
54+
uses: codecov/codecov-action@v1
55+
with:
56+
token: ${{ secrets.CODECOV_TOKEN }}

‎.travis.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,14 @@
11
# egg-mysql
22

33
[![NPM version][npm-image]][npm-url]
4-
[![build status][travis-image]][travis-url]
4+
[![Node.js CI](https://github.com/eggjs/egg-mysql/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-mysql/actions/workflows/nodejs.yml)
55
[![Test coverage][codecov-image]][codecov-url]
6-
[![Known Vulnerabilities][snyk-image]][snyk-url]
76
[![npm download][download-image]][download-url]
87

98
[npm-image]: https://img.shields.io/npm/v/egg-mysql.svg?style=flat-square
109
[npm-url]: https://npmjs.org/package/egg-mysql
11-
[travis-image]: https://img.shields.io/travis/eggjs/egg-mysql.svg?style=flat-square
12-
[travis-url]: https://travis-ci.org/eggjs/egg-mysql
1310
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-mysql.svg?style=flat-square
1411
[codecov-url]: https://codecov.io/github/eggjs/egg-mysql?branch=master
15-
[snyk-image]: https://snyk.io/test/npm/egg-mysql/badge.svg?style=flat-square
16-
[snyk-url]: https://snyk.io/test/npm/egg-mysql
1712
[download-image]: https://img.shields.io/npm/dm/egg-mysql.svg?style=flat-square
1813
[download-url]: https://npmjs.org/package/egg-mysql
1914

‎README.zh-CN.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,14 @@
11
# egg-mysql
22

33
[![NPM version][npm-image]][npm-url]
4-
[![build status][travis-image]][travis-url]
4+
[![Node.js CI](https://github.com/eggjs/egg-mysql/actions/workflows/nodejs.yml/badge.svg)](https://github.com/eggjs/egg-mysql/actions/workflows/nodejs.yml)
55
[![Test coverage][codecov-image]][codecov-url]
6-
[![David deps][david-image]][david-url]
7-
[![Known Vulnerabilities][snyk-image]][snyk-url]
86
[![npm download][download-image]][download-url]
97

108
[npm-image]: https://img.shields.io/npm/v/egg-mysql.svg?style=flat-square
119
[npm-url]: https://npmjs.org/package/egg-mysql
12-
[travis-image]: https://img.shields.io/travis/eggjs/egg-mysql.svg?style=flat-square
13-
[travis-url]: https://travis-ci.org/eggjs/egg-mysql
1410
[codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-mysql.svg?style=flat-square
1511
[codecov-url]: https://codecov.io/github/eggjs/egg-mysql?branch=master
16-
[david-image]: https://img.shields.io/david/eggjs/egg-mysql.svg?style=flat-square
17-
[david-url]: https://david-dm.org/eggjs/egg-mysql
18-
[snyk-image]: https://snyk.io/test/npm/egg-mysql/badge.svg?style=flat-square
19-
[snyk-url]: https://snyk.io/test/npm/egg-mysql
2012
[download-image]: https://img.shields.io/npm/dm/egg-mysql.svg?style=flat-square
2113
[download-url]: https://npmjs.org/package/egg-mysql
2214

‎appveyor.yml

Lines changed: 0 additions & 17 deletions
This file was deleted.

‎lib/mysql.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ function createOneClient(config, app) {
1717
config.user, config.host, config.port, config.database);
1818
const client = rds(config);
1919

20-
app.beforeStart(function* () {
21-
const rows = yield client.query('select now() as currentTime;');
20+
app.beforeStart(async () => {
21+
const rows = await client.query('select now() as currentTime;');
2222
const index = count++;
2323
app.coreLogger.info(`[egg-mysql] instance[${index}] status OK, rds currentTime: ${rows[0].currentTime}`);
2424
});

‎package.json

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@
55
"eggPlugin": {
66
"name": "mysql"
77
},
8+
"files": [
9+
"config",
10+
"lib",
11+
"agent.js",
12+
"app.js",
13+
"index.d.ts"
14+
],
815
"keywords": [
916
"egg",
1017
"eggPlugin",
@@ -13,22 +20,21 @@
1320
"database"
1421
],
1522
"dependencies": {
16-
"ali-rds": "^3.0.1"
23+
"ali-rds": "^3.4.0"
1724
},
1825
"devDependencies": {
19-
"autod": "^3.0.1",
20-
"egg": "latest-1",
21-
"egg-bin": "^4.7.0",
22-
"egg-ci": "^1.8.0",
23-
"egg-mock": "^3.17.1",
24-
"eslint": "^4.19.1",
25-
"eslint-config-egg": "^7.0.0",
26+
"autod": "^3.1.2",
27+
"egg": "^2.35.0",
28+
"egg-bin": "^4.19.0",
29+
"egg-ci": "^2.1.0",
30+
"egg-mock": "^4.2.1",
31+
"eslint": "^8.16.0",
32+
"eslint-config-egg": "^11.1.0",
2633
"git-contributor": "^1.0.10",
27-
"supertest": "^3.1.0",
28-
"utility": "^1.13.1"
34+
"utility": "^1.17.0"
2935
},
3036
"engines": {
31-
"node": ">=6.0.0"
37+
"node": ">=14.0.0"
3238
},
3339
"scripts": {
3440
"contributor": "git-contributor",
@@ -40,9 +46,14 @@
4046
"autod": "autod"
4147
},
4248
"ci": {
43-
"version": "6, 8",
49+
"version": "14, 16, 18",
4450
"license": true,
45-
"services": "mysql"
51+
"service": {
52+
"mysql": {
53+
"version": "5",
54+
"db": "test"
55+
}
56+
}
4657
},
4758
"repository": {
4859
"type": "git",

‎test/.setup.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
const execSync = require('child_process').execSync;
44

5-
execSync('mysql -uroot -e "create database IF NOT EXISTS test;"');
6-
execSync('mysql -uroot test < test/npm_auth.sql');
5+
execSync('mysql -uroot -h 127.0.0.1 -e "create database IF NOT EXISTS test;"');
6+
execSync('mysql -uroot -h 127.0.0.1 test < test/npm_auth.sql');
77
console.log('create table success');
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
'use strict';
22

3-
const co = require('co');
43
const fs = require('fs');
54
const path = require('path');
65

@@ -10,8 +9,8 @@ module.exports = function(agent) {
109
const p = path.join(__dirname, 'run/agent_result.json');
1110
fs.existsSync(p) && fs.unlinkSync(p);
1211

13-
co(function* () {
14-
const result = yield agent.mysql1.query('select now() as currentTime;');
12+
(async () => {
13+
const result = await agent.mysql1.query('select now() as currentTime;');
1514
fs.writeFileSync(p, JSON.stringify(result));
16-
}).then(done, done);
15+
})().then(done).catch(done);
1716
};

0 commit comments

Comments
 (0)