test: correct the unit test item #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build | |
# 触发条件:在 push或合并请求 到 master 或 release开头的分支后 | |
on: | |
push: | |
branches: | |
- main | |
- alpha | |
- beta | |
pull_request: | |
branches: '*' | |
# 任务 | |
jobs: | |
quality: | |
# 服务器环境:最新版 Ubuntu | |
runs-on: ubuntu-latest | |
steps: | |
# 拉取代码 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.12.x | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'npm' | |
# 执行测试和打包操作 | |
- name: Install deps | |
run: npm ci | |
- name: Lint check | |
run: npm run lint | |
# 这条命令包含了测试 | |
- name: Unit tests | |
if: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/alpha' && github.ref != 'refs/heads/beta' }} | |
run: npm run test | |
release: | |
runs-on: ubuntu-latest | |
needs: [quality] | |
if: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/alpha' || github.ref == 'refs/heads/beta' }} | |
steps: | |
# 拉取代码 | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
persist-credentials: false | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18.12.x | |
registry-url: 'https://registry.npmjs.org' | |
cache: 'npm' | |
# 执行测试和打包操作 | |
- name: Install deps | |
run: npm ci | |
# 这条命令包含了测试和上传覆盖率 | |
- name: Coverage | |
run: npm run coveralls | |
- name: Release | |
run: npm run release | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |