Skip to content

Commit 23cbd83

Browse files
authored
test: use workflow services (#25)
fengmk2/github-actions#1
1 parent d3fa13c commit 23cbd83

File tree

3 files changed

+20
-72
lines changed

3 files changed

+20
-72
lines changed

.github/workflows/nodejs.yml

Lines changed: 12 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,18 @@
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
1+
name: CI
52

63
on:
74
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
5+
branches: [ master ]
316

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@v3
44-
with:
45-
node-version: ${{ matrix.node-version }}
46-
47-
- name: Install Dependencies
48-
run: npm i
7+
pull_request:
8+
branches: [ master ]
499

50-
- name: Continuous Integration
51-
run: npm run ci
10+
workflow_dispatch: {}
5211

53-
- name: Code Coverage
54-
uses: codecov/codecov-action@v3
55-
with:
56-
token: ${{ secrets.CODECOV_TOKEN }}
12+
jobs:
13+
Job:
14+
name: Node.js
15+
uses: fengmk2/github-actions/.github/workflows/node-test-mysql.yml@master
16+
with:
17+
os: 'ubuntu-latest'
18+
version: '14, 16, 18'

package.json

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,13 @@
2323
"ali-rds": "^4.0.1"
2424
},
2525
"devDependencies": {
26-
"egg": "^3.5.0",
27-
"egg-bin": "^5.5.0",
28-
"egg-ci": "^2.1.0",
29-
"egg-mock": "^5.2.1",
26+
"egg": "^3.15.0",
27+
"egg-bin": "^6.1.2",
28+
"egg-mock": "^5.10.6",
3029
"eslint": "^8.16.0",
3130
"eslint-config-egg": "^12.1.0",
32-
"git-contributor": "^1.0.10",
33-
"tsd": "^0.25.0",
34-
"utility": "^1.17.0"
31+
"git-contributor": "^2.0.0",
32+
"tsd": "^0.25.0"
3533
},
3634
"engines": {
3735
"node": ">=14.0.0"
@@ -45,16 +43,6 @@
4543
"lint": "eslint .",
4644
"ci": "npm run lint && npm run cov"
4745
},
48-
"ci": {
49-
"version": "14, 16, 18",
50-
"license": true,
51-
"service": {
52-
"mysql": {
53-
"version": "5",
54-
"db": "test"
55-
}
56-
}
57-
},
5846
"repository": {
5947
"type": "git",
6048
"url": "git+https://github.com/eggjs/egg-mysql.git"

test/mysql.test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
'use strict';
2-
31
const assert = require('assert');
4-
const mm = require('egg-mock');
5-
const utility = require('utility');
2+
const { randomUUID } = require('crypto');
63
const path = require('path');
74
const fs = require('fs');
5+
const mm = require('egg-mock');
86

97
describe('test/mysql.test.js', () => {
108
let app;
11-
const uid = utility.randomString();
9+
const uid = randomUUID();
1210

1311
before(() => {
1412
app = mm.app({

0 commit comments

Comments
 (0)