jpb06 / coverage-badges-action

Github action generating coverage badges from a coverage json summary
MIT License
3 stars 0 forks source link

Generate coverage average badges if several coverage summary reports are provided #15

Closed jpb06 closed 4 weeks ago

jpb06 commented 3 months ago

https://github.com/jpb06/coverage-badges-action/issues/5#issuecomment-2129494828

What we could do is also generating an average set of badges for all apps/libs. For example, if I have two apps with 55% and 30% coverage respectively, I'd have an average of 42.5% for the repo. These average badges could be saved at badges/average/*.

jpb06 commented 3 months ago

https://github.com/jpb06/coverage-badges-action/pull/17

jpb06 commented 3 months ago

https://github.com/jpb06/coverage-badges-action/pull/18

jpb06 commented 3 months ago

Coverage badges are written in ./badges/coverage-average (assuming ./badges is the output folder):

https://github.com/jpb06/coverage-badges-action/tree/summaries-average-manual-test/badges/coverage-average

Generated using the following file: https://github.com/jpb06/coverage-badges-action/blob/summaries-average-manual-test/.github/workflows/coverage-average.yml

name: ⚡ Coverage average badges

on:
  push:
    branches:
      - summaries-average-manual-test

jobs:
  coverage-badges-generation:
    name: 📣 Coverage badges generation
    runs-on: ubuntu-latest
    timeout-minutes: 10
    steps:
      - name: 🛑 Cancel Previous Runs
        uses: styfle/cancel-workflow-action@0.12.1

      - name: ⬇️ Checkout repo
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: 📦 Setup pnpm
        uses: pnpm/action-setup@v4
        with:
          version: latest

      - name: ⎔ Setup node
        uses: actions/setup-node@v4
        with:
          node-version-file: '.node-version'
          registry-url: 'https://registry.npmjs.org'
          cache: 'pnpm'
          cache-dependency-path: ./package.json

      - name: 📥 Install deps
        run: pnpm install --frozen-lockfile

      - name: 🔍 Tests
        run: pnpm test-ci

      - name: ⚙️ Generating coverage badges
        uses: ./
        with:
          branches: summaries-average-manual-test
          coverage-summary-path: |
            ./apps/**/coverage/coverage-summary.json
          badges-icon: vitest
jpb06 commented 3 months ago

Release as v1.0.13.

Please let me know how it rolls 🙇🏻