name: 'coverage'
on:
  workflow_dispatch:
  push:
    branches:
      - master
      - main
  pull_request:
    branches:
      - master
      - main
jobs:
  coverage:
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, '[skip ci]')"
    env:
      CI_JOB_NUMBER: 1
      
    strategy:
      matrix:
        node-version: [ 17 ]
      
    steps:
      - uses: actions/checkout@main
        fetch-depth: 2
        token: ${{ secrets.GITHUB_TOKEN }}
      - name: Set up Node.js ${{ matrix.node-version }}
        uses: actions/setup-node@main
        with:
          node-version: ${{ matrix.node-version }}
      - name: install
        run: |
          yarn install --frozen-lockfile
          yarn run ci:install
#          yarn add -W typescript@next jest ts-jest ts-node ynpx lerna
      - uses: artiomtr/jest-coverage-report-action@main
        with:
          github-token: ${{ secrets.GITHUB_TOKEN }}
          package-manager: yarn
          #   threshold: 80 # optional parameter
          test-script: npx jest --silent --ci --coverage=false --coverageReporters="text" --coverageReporters="text-summary"
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@master
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
          verbose: true
