Skip to content

๐Ÿš€ attach your own jest badge to your repo page(README.md) in 10 sec, super conveniently!

License

Notifications You must be signed in to change notification settings

nolleh/jest-badge-deploy-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

38 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Overview

github action purposing on making coverage badge for jest,
super convinently.

combine 2 action jest-bades-action and
github-pages-deploy-action

if you put ci steps in 2 line, then badge automatically uploaded to your repo.
and put the url to your page. (ex. README.md)

then whenever update your code (pushed) then coverage will be updated imediately.

๐Ÿš€ Example

Coverage Branches Coverage Functions Coverage Coverage Lines Coverage Statements

it looks like only work for 100% badge, but actually cacluated..
(cause this example -simple-csv-parser- cover 100%)...
other example.

Coverage

[![Coverage Status](https://github.com/nolleh/simple-csv-parser/raw/gh-pages/badges/coverage-jest%20coverage.svg?raw=true)](https://nolleh.github.io/simple-csv-parser/badges/coverage-jest%20coverage.svg?raw=true)

No Need Headache For Permission

don't be bothered to permission for your repository (token or private repo or whatever)
because this badge file no need to uploaded to elsewhere but your repo.

๐Ÿ“ Usage

add to your github action...

  1. run test to make json-summary in your package.json or jest.config.json, add json-summary
{
  "jest": {
    "coverageReporters": ["json-summary", "text"]
  }
}
  1. add jest-badge-deploy-action
name: ci
on: [push]
jobs:
  test-and-push-badge:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: "16"
      - name: Install
        run: |
          npm install -g pnpm
          pnpm i
      - name: Test and Cov
        run: pnpm test:cov

      ### this step!
      - name: Cov Badge And Publish
        uses: nolleh/jest-badge-deploy-action@latest

in your markdown (README.md)
import your gh-pages branches svg.

โš ๏ธ NOTE: you should change the repo path (simple-csv-parser...) to yours.

[![Coverage Status](https://github.com/nolleh/simple-csv-parser/raw/gh-pages/badges/coverage-jest%20coverage.svg?raw=true)](https://nolleh.github.io/simple-csv-parser/badges/coverage-jest%20coverage.svg?raw=true)

โš™๏ธ How It Works

  • gh-pages branch is special branch in github to upload static files. (deployed)
  • by using jest:json-summary, generate badge.
  • the generated badges pushed to the special branch (gh-pages)
  • these all process worked in your ci workflow, and it has permission to your repository.
  • Booyah!

๐Ÿค” Trouble Shoot

ci can be fails with

remote: Permission to nolleh/simple-csv-parser.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/nolleh/simple-csv-parser/': The requested URL returned error: 403

make sure ci can access your repo. (to commit/push)

  1. go to repository settings > Actions > general

    repo setting menu
  2. scrolls down to workflow permission, and check 'Read and write permissions'

  • this will be applied to your .github/workflow's permission.

workflow-permissions

About

๐Ÿš€ attach your own jest badge to your repo page(README.md) in 10 sec, super conveniently!

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published