{"id":19972573,"url":"https://github.com/jpb06/jest-badges-action","last_synced_at":"2025-10-19T10:00:03.603Z","repository":{"id":43093994,"uuid":"357652663","full_name":"jpb06/jest-badges-action","owner":"jpb06","description":"Github action generating coverage badges using jest and pushing them to the repo","archived":false,"fork":false,"pushed_at":"2024-02-29T20:12:53.000Z","size":1600,"stargazers_count":35,"open_issues_count":0,"forks_count":19,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-08T01:01:40.793Z","etag":null,"topics":["badges","ci-cd","github-actions","jest","test-coverage"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpb06.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-04-13T18:30:53.000Z","updated_at":"2024-12-24T07:51:12.000Z","dependencies_parsed_at":"2023-12-24T15:32:25.607Z","dependency_job_id":null,"html_url":"https://github.com/jpb06/jest-badges-action","commit_stats":{"total_commits":152,"total_committers":5,"mean_commits":30.4,"dds":0.6578947368421053,"last_synced_commit":"3a3ca7c621c322286bb7019f27d5c7edf64491c9"},"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fjest-badges-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fjest-badges-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fjest-badges-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpb06%2Fjest-badges-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpb06","download_url":"https://codeload.github.com/jpb06/jest-badges-action/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251956277,"owners_count":21671181,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["badges","ci-cd","github-actions","jest","test-coverage"],"created_at":"2024-11-13T03:08:35.490Z","updated_at":"2025-10-19T10:00:03.505Z","avatar_url":"https://github.com/jpb06.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jest-badges-action\n\n[![Open in Visual Studio Code](https://img.shields.io/static/v1?logo=visualstudiocode\u0026label=\u0026message=Open%20in%20Visual%20Studio%20Code\u0026labelColor=2c2c32\u0026color=007acc\u0026logoColor=007acc)](https://open.vscode.dev/jpb06/jest-badges-action)\n![Github workflow](https://img.shields.io/github/actions/workflow/status/jpb06/jest-badges-action/tests-scan.yml?branch=master\u0026logo=github-actions\u0026label=last%20workflow)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=alert_status)](https://sonarcloud.io/summary/new_code?id=jpb06_jest-badges-action)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=jpb06_jest-badges-action)\n[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=security_rating)](https://sonarcloud.io/dashboard?id=jpb06_jest-badges-action)\n[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=reliability_rating)](https://sonarcloud.io/dashboard?id=jpb06_jest-badges-action)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=jpb06_jest-badges-action)\n![Total coverage](./badges/coverage-jest%20coverage.svg)\n[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=ncloc)](https://sonarcloud.io/summary/new_code?id=jpb06_jest-badges-action)\n[![Technical Debt](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=sqale_index)](https://sonarcloud.io/summary/new_code?id=jpb06_jest-badges-action)\n[![Code Smells](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=code_smells)](https://sonarcloud.io/dashboard?id=jpb06_jest-badges-action)\n[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=bugs)](https://sonarcloud.io/summary/new_code?id=jpb06_jest-badges-action)\n[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=jpb06_jest-badges-action)\n[![Duplicated Lines (%)](https://sonarcloud.io/api/project_badges/measure?project=jpb06_jest-badges-action\u0026metric=duplicated_lines_density)](https://sonarcloud.io/dashboard?id=jpb06_jest-badges-action)\n![Last commit](https://img.shields.io/github/last-commit/jpb06/jest-badges-action?logo=git)\n\nGenerating coverage badges and pushing them to the repository.\n\n\u003c!-- readme-package-icons start --\u003e\n\n\u003cp align=\"left\"\u003e\u003ca href=\"https://docs.github.com/en/actions\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/GithubActions-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://www.typescriptlang.org/docs/\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/TypeScript.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://nodejs.org/en/docs/\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/NodeJS-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://pnpm.io/motivation\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Pnpm-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://github.com/conventional-changelog\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/CommitLint.Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://eslint.org/docs/latest/\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Eslint-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://jestjs.io/docs/getting-started\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Jest.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://prettier.io/docs/en/index.html\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Prettier-Dark.svg\" /\u003e\u003c/a\u003e\u0026nbsp;\u003ca href=\"https://swc.rs/docs/getting-started\" target=\"_blank\"\u003e\u003cimg height=\"50\" src=\"https://raw.githubusercontent.com/jpb06/jpb06/master/icons/Swc-Dark.svg\" /\u003e\u003c/a\u003e\u003c/p\u003e\n\n\u003c!-- readme-package-icons end --\u003e\n\n# 😺 This action is replaced by [coverage-badges-action](https://github.com/jpb06/coverage-badges-action)\n\n## ⚡ Description\n\nThis github action generates testing coverage badges using jest and pushes them to the repo at `./badges`. There is five badges generated:\n\n![Branches](./badges/coverage-branches.svg)\n![Functions](./badges/coverage-functions.svg)\n![Lines](./badges/coverage-lines.svg)\n![Statements](./badges/coverage-statements.svg)\n![Jest coverage](./badges/coverage-jest%20coverage.svg)\n\nYou can use them on a readme like so:\n\n```markdown\n![Branches](./badges/coverage-branches.svg)\n![Functions](./badges/coverage-functions.svg)\n![Lines](./badges/coverage-lines.svg)\n![Statements](./badges/coverage-statements.svg)\n![Jest coverage](./badges/coverage-jest%20coverage.svg)\n```\n\n## ⚡ Requirements\n\nYou will need to add json-summary to coverage reporters in jest config:\n\n```javascript\nmodule.exports = {\n   coverageReporters: [\"json-summary\"];\n};\n```\n\nYou also need to run jest before calling this action in your ci workflow. See `usage` for an example.\n\n## ⚡ Inputs\n\n### 🔶 `no-commit`\n\nIf set to `true`, badges won't be committed by the github action.\n\n\u003e Default value: *false**\n\n### 🔶 `branches`\n\nBranches on which the badges should be generated, separated by commas. Optionally, you can set the value as `*` to specify generation should always happen.\n\n\u003e Default value: **master,main**\n\n### 🔶 `target-branch`\n\nThe branch on which generated badges should be pushed. If unset, the current branch (on which the action is ran against) will be used.\n\n### 🔶 `coverage-summary-path`\n\nJest coverage summary path (json-summary). Defining this may be useful if you need to run this action on a monorepo.\n\n\u003e Default value: **./coverage/coverage-summary.json**\n\n### 🔶 `commit-message`\n\nCommit message of the commit with generated badges.\n\n\u003e Default value: **Updating coverage badges**\n\n### 🔶 `commit-user`\n\nCustomizing the name of the user committing generated badges (optional).\n\n\u003e Default value: **\u003ccontext.actor\u003e**\n\n### 🔶 `commit-user-email`\n\nCustomizing the email of the user committing generated badges (optional).\n\n\u003e Default value: **\u003ccontext.actor\u003e@users.noreply.github.com**\n\n### 🔶 `output-folder`\n\nWhere badges should be written (optional).\n\n\u003e Default value: **./badges**\n\n## ⚡ Usage\n\nLet's first define an npm script to run jest in package.json, specifying the coverage option to generate a coverage report:\n\n```json\n{\n  \"scripts\": {\n    \"test-ci\": \"jest --ci --coverage\"\n  }\n}\n```\n\nLet's then define our workflow:\n\n```yaml\nname: My ci things\non: [push]\njobs:\n  bump:\n    runs-on: ubuntu-latest\n    steps:\n    # Necessary to push the generated badges to the repo\n    - name: Check out repository code\n      uses: actions/checkout@v3\n    # Necessary to generate the coverage report.\n    # Make sure to add 'json-summary' to the coverageReporters in jest options\n    - name: Tests\n      run: yarn test-ci\n    [...]\n    - name: Generating coverage badges\n      uses: jpb06/jest-badges-action@latest\n        with:\n          branches: master,preprod,staging\n\n```\n\nThe badges will be generated when the action runs on the master, preprod or staging branch.\n\n### 🔶 Using a custom jest coverage summary file path\n\nIn case you need to define a custom path for the coverage summary file, you can use the `coverage-summary-path` input like so:\n\n```yaml\n    [...]\n    - name: Generating coverage badges\n      uses: jpb06/jest-badges-action@latest\n        with:\n          coverage-summary-path: ./my-module/coverage/coverage-summary.json\n```\n\n### 🔶 Pushing generated badges to a custom branch\n\nYour perpetual branches should be protected to avoid some people from force pushing on them for example. Sadly there is no way to push badges to a protected branch 😿.\n\nA workaround is to push them to a custom branch. Here is an example using a `badges` branch:\n\n```yaml\nname: Generate badges on custom branch\n\non:\n  push:\n    branches:\n      - master\n\njobs:\n  generate-badges-on-custom-branch:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout repository\n        uses: actions/checkout@v3\n        with:\n          fetch-depth: 0\n      \n      - uses: pnpm/action-setup@v2.2.4\n        with:\n          version: latest\n\n      - name: Setup node\n        uses: actions/setup-node@v3\n        with:\n          node-version-file: '.node-version'\n          registry-url: 'https://registry.npmjs.org'\n          cache: 'pnpm'\n\n      - name: Installing dependencies\n        run: pnpm install --frozen-lockfile\n\n      - name: Delete remote badges branch\n        run: git push origin --delete badges\n\n      - name: Create badges branch\n        run: git checkout -b badges\n\n      - name: Tests\n        run: pnpm test-ci\n\n      - name: Generating coverage badges\n        uses: ./\n        with:\n          branches: '*'\n          target-branch: badges\n\n      - name: Push badges branch\n        run: git push origin badges\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpb06%2Fjest-badges-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpb06%2Fjest-badges-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpb06%2Fjest-badges-action/lists"}