chore: fix coverage badge not generated #210
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: Unit Test | |
on: | |
push: | |
branches: | |
- master | |
- feature/badge-new | |
pull_request: | |
branches: | |
- master | |
jobs: | |
coverage: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
package: [utils, base, react, bridge] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Set up Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
- name: Install pnpm | |
run: npm install -g pnpm | |
- name: Install dependencies | |
run: pnpm install --no-frozen-lockfile | |
- name: Run tests with coverage | |
run: | | |
cd packages/${{ matrix.package }} | |
pnpm run test:coverage | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v3 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} | |
files: packages/${{ matrix.package }}/coverage/lcov.info | |
flags: unittests | |
name: codecov-umbrella | |
- name: Generate coverage badge | |
uses: jaywcjlove/coverage-badges-cli@main | |
with: | |
source: packages/${{ matrix.package }}/coverage/coverage-summary.json | |
output: packages/${{ matrix.package }}/coverage/badge.svg | |
- name: Upload coverage report to artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: coverage-${{ matrix.package }} | |
path: packages/${{ matrix.package }}/coverage | |
deploy: | |
runs-on: ubuntu-latest | |
needs: coverage | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Download coverage artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: coverage | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: coverage |