name: Test

on:
  push:
    branches:
      - dev

jobs:
  test-package:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [16.x]
    steps:
      # check it to your workflow can access it
      # from: https://github.com/actions/checkout
      - name: 1. 检出分支
        uses: actions/checkout@v2

      # from: https://github.com/actions/setup-node
      - name: 2. 设置Node.js
        uses: actions/setup-node@v2
        with:
          node-version: ${{ matrix.node-version }}

      - name: 3. 缓存
        uses: actions/cache@v2
        id: cache-dependencies
        with:
          path: node_modules
          key: ${{runner.OS}}-${{hashFiles('**/yarn.lock')}}

      - name: 4. 安装插件
        if: steps.cache-dependencies.outputs.cache-hit != 'true'
        run: |
          export TZ='Asia/Shanghai'
          yarn install

      - name: 5. 编译测试
        run: |
          export TZ='Asia/Shanghai'
          yarn build --if-present