From 0d8126550b4a4219a0b7f08c916fa8bbb0c65c0d Mon Sep 17 00:00:00 2001 From: Rudolf Kovalov Date: Sun, 1 Mar 2026 02:52:52 +0200 Subject: [PATCH 1/4] feat(test): add coverage badge --- .github/workflows/ci.yml | 19 ++++++++++++++++++- README.md | 1 + 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8722c8d..07aefda 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,7 +29,24 @@ jobs: run: pnpm format:lint - name: Test - run: pnpm test + run: pnpm test:coverage + + - name: Parse coverage + id: coverage + run: | + PCT=$(node -e "const c=require('./coverage/coverage-summary.json');console.log(Math.round(c.total.lines.pct))") + echo "pct=$PCT" >> $GITHUB_OUTPUT + echo "color=$([ $PCT -ge 80 ] && echo green || [ $PCT -ge 60 ] && echo yellow || echo red)" >> $GITHUB_OUTPUT + + - name: Update coverage badge + uses: schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: ${{ secrets.TEST_COVERAGE_GIST_ID }} + filename: coverage.json + label: coverage + message: ${{ steps.coverage.outputs.pct }}% + color: ${{ steps.coverage.outputs.color }} - name: Build run: pnpm build \ No newline at end of file diff --git a/README.md b/README.md index 745ca4e..4af38e8 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,7 @@ [![npm](https://img.shields.io/npm/v/@rstackio/services)](https://www.npmjs.com/package/@rstackio/services) [![CI](https://github.com/rstackio/services/actions/workflows/publish.yml/badge.svg)](https://github.com/rstackio/services/actions/workflows/publish.yml) +[![coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/rkovalov/c73854c806277dbac2ab2b6936c39518/raw/coverage.json)](https://github.com/rstackio/services/actions/workflows/ci.yml) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/rstackio/services/blob/main/LICENSE) [![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue)](https://www.typescriptlang.org/) From 757a7c8e4a7da23acc82863bd69d89c2393e84e5 Mon Sep 17 00:00:00 2001 From: Rudolf Kovalov Date: Sun, 1 Mar 2026 02:59:30 +0200 Subject: [PATCH 2/4] feat(test): add coverage badge --- .github/workflows/ci.yml | 19 +------------------ .github/workflows/publish.yml | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 07aefda..8722c8d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,24 +29,7 @@ jobs: run: pnpm format:lint - name: Test - run: pnpm test:coverage - - - name: Parse coverage - id: coverage - run: | - PCT=$(node -e "const c=require('./coverage/coverage-summary.json');console.log(Math.round(c.total.lines.pct))") - echo "pct=$PCT" >> $GITHUB_OUTPUT - echo "color=$([ $PCT -ge 80 ] && echo green || [ $PCT -ge 60 ] && echo yellow || echo red)" >> $GITHUB_OUTPUT - - - name: Update coverage badge - uses: schneegans/dynamic-badges-action@v1.7.0 - with: - auth: ${{ secrets.GIST_SECRET }} - gistID: ${{ secrets.TEST_COVERAGE_GIST_ID }} - filename: coverage.json - label: coverage - message: ${{ steps.coverage.outputs.pct }}% - color: ${{ steps.coverage.outputs.color }} + run: pnpm test - name: Build run: pnpm build \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index c5db1ae..dd1aa08 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,6 +8,7 @@ jobs: publish: name: Publish runs-on: ubuntu-latest + environment: Publish permissions: contents: write # required for pushing git tags id-token: write # required for npm provenance @@ -33,7 +34,24 @@ jobs: run: pnpm format:lint - name: Test - run: pnpm test + run: pnpm test:coverage + + - name: Parse coverage + id: coverage + run: | + PCT=$(node -e "const c=require('./coverage/coverage-summary.json');console.log(Math.round(c.total.lines.pct))") + echo "pct=$PCT" >> $GITHUB_OUTPUT + echo "color=$([ $PCT -ge 80 ] && echo green || [ $PCT -ge 60 ] && echo yellow || echo red)" >> $GITHUB_OUTPUT + + - name: Update coverage badge + uses: schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: ${{ secrets.TEST_COVERAGE_GIST_ID }} + filename: coverage.json + label: coverage + message: ${{ steps.coverage.outputs.pct }}% + color: ${{ steps.coverage.outputs.color }} - name: Build run: pnpm build From 38c75f3a0d932788ae46891127b94866e1656aeb Mon Sep 17 00:00:00 2001 From: Rudolf Kovalov Date: Sun, 1 Mar 2026 03:02:27 +0200 Subject: [PATCH 3/4] feat(test): add coverage badge --- .github/workflows/publish.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index dd1aa08..f6a9d1c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -43,16 +43,6 @@ jobs: echo "pct=$PCT" >> $GITHUB_OUTPUT echo "color=$([ $PCT -ge 80 ] && echo green || [ $PCT -ge 60 ] && echo yellow || echo red)" >> $GITHUB_OUTPUT - - name: Update coverage badge - uses: schneegans/dynamic-badges-action@v1.7.0 - with: - auth: ${{ secrets.GIST_SECRET }} - gistID: ${{ secrets.TEST_COVERAGE_GIST_ID }} - filename: coverage.json - label: coverage - message: ${{ steps.coverage.outputs.pct }}% - color: ${{ steps.coverage.outputs.color }} - - name: Build run: pnpm build @@ -71,6 +61,17 @@ jobs: env: NODE_AUTH_TOKEN: ${{ secrets.RSTACKIO_NPM_TOKEN }} + - name: Update coverage badge + if: steps.publish.outputs.published == 'true' + uses: schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: ${{ secrets.TEST_COVERAGE_GIST_ID }} + filename: coverage.json + label: coverage + message: ${{ steps.coverage.outputs.pct }}% + color: ${{ steps.coverage.outputs.color }} + - name: Push git tag if: steps.publish.outputs.published == 'true' run: | From 0b192e5fb04f437ca4156158bfa2e1971178059a Mon Sep 17 00:00:00 2001 From: Rudolf Kovalov Date: Sun, 1 Mar 2026 03:07:09 +0200 Subject: [PATCH 4/4] chore(ci): fixed error handling --- .github/workflows/publish.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index f6a9d1c..0b4e9f7 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -63,6 +63,7 @@ jobs: - name: Update coverage badge if: steps.publish.outputs.published == 'true' + continue-on-error: true uses: schneegans/dynamic-badges-action@v1.7.0 with: auth: ${{ secrets.GIST_SECRET }}