diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 0000000..33ceadd --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,56 @@ +name: Node.js CI + +on: + pull_request: + branches: [ master ] + push: + branches: [ master ] +jobs: + test: + name: Test + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [12.x, 14.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - run: npm ci + name: Install dependencies + - name: Set Test Env + run: | + export NCM_API_TEST_LOGIN_PHONE=${{ secrets.NCM_API_TEST_LOGIN_PHONE }} + export NCM_API_TEST_LOGIN_PASSWORD=${{ secrets.NCM_API_TEST_LOGIN_PASSWORD }} + - name: Test + run: npm test + lint: + name: Lint + runs-on: ubuntu-latest + strategy: + matrix: + node-version: [14.x] + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + - uses: actions/cache@v2 + with: + path: ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + - run: npm ci + name: Install dependencies + - name: Lint + run: npm lint \ No newline at end of file diff --git a/package.json b/package.json index 648cdab..7dcec73 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "scripts": { "start": "node app.js", "test": "mocha -r intelli-espower-loader -t 20000 app.test.js --exit", - "lint-fix": "eslint --fix --ext .js app.js module/ util/ test/ " + "lint": "eslint **/*.{js,ts}", + "lint-fix": "eslint --fix **/*.{js,ts}" }, "keywords": [ "网易云音乐", diff --git a/test/login.test.js b/test/login.test.js index 0855afe..a9e5a42 100644 --- a/test/login.test.js +++ b/test/login.test.js @@ -3,12 +3,13 @@ const request = require('request') const host = global.host || 'http://localhost:3000' console.log('注意: 测试登录需在 test/login.test.js 中填写账号密码!!!'); - +const phone = '' +const password = '' describe('测试登录是否正常', () => { it('手机登录 code 应该等于200', done => { const qs = { - phone: phone, - password: password + phone: process.env.NCM_API_TEST_LOGIN_PHONE || phone || '', + password: process.env.NCM_API_TEST_LOGIN_PASSWORD || password || '' } request.get({url: `${host}/login/cellphone`, qs: qs}, (err, res, body) => {