{"id":15776088,"url":"https://github.com/mishakav/pytest-coverage-comment","last_synced_at":"2025-04-08T10:33:26.037Z","repository":{"id":37812593,"uuid":"365032492","full_name":"MishaKav/pytest-coverage-comment","owner":"MishaKav","description":"Comments a pull request with the pytest code coverage badge and full report","archived":false,"fork":false,"pushed_at":"2024-10-10T20:50:19.000Z","size":646,"stargazers_count":181,"open_issues_count":8,"forks_count":59,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-29T19:31:20.731Z","etag":null,"topics":["coverage","github-actions","test","testing"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MishaKav.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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,"publiccode":null,"codemeta":null},"funding":{"patreon":"MishaKav","custom":["paypal.me/MishaKav"]}},"created_at":"2021-05-06T20:41:58.000Z","updated_at":"2024-10-19T16:08:45.000Z","dependencies_parsed_at":"2024-01-16T21:53:49.349Z","dependency_job_id":"a72db418-0636-4614-bb9b-7dab516a45db","html_url":"https://github.com/MishaKav/pytest-coverage-comment","commit_stats":{"total_commits":122,"total_committers":16,"mean_commits":7.625,"dds":0.180327868852459,"last_synced_commit":"81882822c5b22af01f91bd3eacb1cefb6ad73dc2"},"previous_names":[],"tags_count":57,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MishaKav%2Fpytest-coverage-comment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MishaKav%2Fpytest-coverage-comment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MishaKav%2Fpytest-coverage-comment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MishaKav%2Fpytest-coverage-comment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MishaKav","download_url":"https://codeload.github.com/MishaKav/pytest-coverage-comment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247824612,"owners_count":21002315,"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":["coverage","github-actions","test","testing"],"created_at":"2024-10-04T17:04:50.693Z","updated_at":"2025-04-08T10:33:25.978Z","avatar_url":"https://github.com/MishaKav.png","language":"JavaScript","readme":"# Pytest Coverage Comment\n\n![licience](https://img.shields.io/github/license/MishaKav/pytest-coverage-comment)\n![version](https://img.shields.io/github/package-json/v/MishaKav/pytest-coverage-comment)\n[![wakatime](https://wakatime.com/badge/user/f838c8aa-c197-42f0-b335-cd1d26159dfd/project/b1e64a51-e518-4b91-bb00-189ffdd444c6.svg)](https://wakatime.com/badge/user/f838c8aa-c197-42f0-b335-cd1d26159dfd/project/b1e64a51-e518-4b91-bb00-189ffdd444c6)\n\nThis action comments a pull request or commit with a HTML test coverage report.\nThe report is based on the coverage report generated by your test runner.\nNote that this action does not run any tests, but expects the tests to have been run by another action already (support pytest only).\n\n**Similar Action for Jest**\n\n---\n\nAfter I see that action become popular, I made similar action (even better) for javascript/typescript that runs `jest`\n[jest-coverage-comment](https://github.com/marketplace/actions/jest-coverage-comment)\n\n---\n\nYou can add this action to your GitHub workflow for Ubuntu runners (e.g. runs-on: ubuntu-latest) as follows:\n\n```yaml\n- name: Pytest coverage comment\n  uses: MishaKav/pytest-coverage-comment@main\n  with:\n    pytest-coverage-path: ./pytest-coverage.txt\n    junitxml-path: ./pytest.xml\n```\n\n## Inputs\n\n| Name                        | Required | Default                 | Description                                                                                                                                                                                                                                                                                                                                                                         |\n| --------------------------- | -------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `github-token`              | ✓        | `${{github.token}}`     | An alternative GitHub token, other than the default provided by GitHub Actions runner                                                                                                                                                                                                                                                                                               |\n| `issue-number`              |          | ''                      | PR Number where you'd like your comments to be posted to. Required to post a comment when running the workflow on an event that isn't `push` or `pull-request` .                                                                                                                                                                                                                    |\n| `pytest-coverage-path`      |          | `./pytest-coverage.txt` | The location of the txt output of pytest-coverage. Used to determine coverage percentage                                                                                                                                                                                                                                                                                            |\n| `pytest-xml-coverage-path`  |          | ''                      | The location of coverage-xml from pytest-coverage (--cov-report \"xml:coverage.xml)                                                                                                                                                                                                                                                                                                  |\n| `coverage-path-prefix`      |          | ''                      | Prefix for path when link to files in comment                                                                                                                                                                                                                                                                                                                                       |\n| `title`                     |          | `Coverage Report`       | Title for the coverage report. Useful for monorepo projects                                                                                                                                                                                                                                                                                                                         |\n| `badge-title`               |          | `Coverage`              | Title for the badge icon                                                                                                                                                                                                                                                                                                                                                            |\n| `hide-badge`                |          | false                   | Hide badge with percentage                                                                                                                                                                                                                                                                                                                                                          |\n| `hide-report`               |          | false                   | Hide coverage report                                                                                                                                                                                                                                                                                                                                                                |\n| `report-only-changed-files` |          | false                   | Show in report only changed files for this commit, and not all files                                                                                                                                                                                                                                                                                                                |\n| `junitxml-path`             |          | ''                      | The location of the junitxml. Used to determine test numbers (passed, failed, etc)                                                                                                                                                                                                                                                                                                  |\n| `junitxml-title`            |          | ''                      | Title for summary for junitxml                                                                                                                                                                                                                                                                                                                                                      |\n| `create-new-comment`        |          | false                   | When false, will update the same comment, otherwise will publish new comment on each run.                                                                                                                                                                                                                                                                                           |\n| `hide-comment`              |          | false                   | Hide the whole comment (use when you need only the `output`). Useful for auto-update bagdes in readme. See the [workflow](../main/.github/workflows/live-test.yml) for example                                                                                                                                                                                                      |\n| `xml-skip-covered`          |          | false                   | Hide files from xml report with 100% coverage                                                                                                                                                                                                                                                                                                                                       |\n| `default-branch`            |          | `main`                  | This branch name is useful when generate \"coverageHtml\", it points direct links to files on this branch (instead of commit).\u003cbr/\u003eUsually \"main\" or \"master\"                                                                                                                                                                                                                         |\n| `multiple-files`            |          | ''                      | You can pass array of titles and files to generate single comment with table of results.\u003cbr/\u003eSingle line should look like `Title, ./path/to/pytest-coverage.txt, ./path/to/pytest-junit.xml`\u003cbr/\u003e example:\u003cbr/\u003e `My Title 1, ./data/pytest-coverage_3.txt, ./data/pytest_1.xml`\u003cbr/\u003e**Note:** In that mode the `output` for `coverage` and `color` will be for the first file only. |\n| `remove-link-from-badge`    |          | false                   | When true, it will remove the link from badge to readme                                                                                                                                                                                                                                                                                                                             |\n| `unique-id-for-comment`     |          | ''                      | When running in a matrix, pass the matrix value, so each comment will be updated its own comment `unique-id-for-comment: ${{ matrix.python-version }}`                                                                                                                                                                                                                              |\n\n## Output Variables\n\n| Name                 | Example                        | Description                                                                           |\n| -------------------- | ------------------------------ | ------------------------------------------------------------------------------------- |\n| `coverage`           | 30%                            | Percentage of the coverage, get from `pytest-cov`                                     |\n| `color`              | red                            | Color of the percentage. You can see the whole list of [badge colors](#badges-colors) |\n| `coverageHtml`       | ...                            | Html with links to files of missing lines. See the [output-example](#output-example)  |\n| `summaryReport`      | ...                            | Markdown with summaryof: Tests/Skipped/Failures/Errors/Time                           |\n| `warnings`           | 2441                           | Number of warnings, get from pytest-cov                                               |\n| `tests`              | 109                            | Total number of tests, get from `junitxml`                                            |\n| `skipped`            | 2                              | Total number of skipped tests, get from `junitxml`                                    |\n| `failures`           | 1                              | Total number of tests with failures, get from `junitxml`                              |\n| `errors`             | 0                              | Total number of tests with errors, get from `junitxml`                                |\n| `time`               | 0.583                          | Seconds the took to run all the tests, get from `junitxml`                            |\n| `notSuccessTestInfo` | [example](#notSuccessTestInfo) | Info from testcase that has failures/errors/skipped, get from `junitxml`              |\n\n### notSuccessTestInfo\n\nthe format will be JSON.stringify in current structure\n\n```json\n{\n  \"failures\": [{ \"classname\": \"...\", \"name\": \"...\" }],\n  \"errors\": [{ \"classname\": \"...\", \"name\": \"...\" }],\n  \"skipped\": [{ \"classname\": \"...\", \"name\": \"...\" }],\n  \"count\": 3\n}\n```\n\n## Output example\n\n\u003cimg alt=\"Coverage\" src=\"https://img.shields.io/badge/Coverage-30%25-red.svg\" /\u003e\u003cbr/\u003e\u003cdetails\u003e\u003csummary\u003eCoverage Report\u003c/summary\u003e\u003ctable\u003e\u003ctr\u003e\u003cth\u003eFile\u003c/th\u003e\u003cth\u003eStmts\u003c/th\u003e\u003cth\u003eMiss\u003c/th\u003e\u003cth\u003eCover\u003c/th\u003e\u003cth\u003eMissing\u003c/th\u003e\u003c/tr\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan=\"5\"\u003e\u003cb\u003efunctions/example_completed\u003c/b\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u0026nbsp; \u0026nbsp;\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_completed/example_completed.py\"\u003eexample_completed.py\u003c/a\u003e\u003c/td\u003e\u003ctd\u003e64\u003c/td\u003e\u003ctd\u003e19\u003c/td\u003e\u003ctd\u003e70%\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_completed/example_completed.py#L33\"\u003e33\u003c/a\u003e, \u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_completed/example_completed.py#L39-L45\"\u003e39\u0026ndash;45\u003c/a\u003e, \u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_completed/example_completed.py#L48-L51\"\u003e48\u0026ndash;51\u003c/a\u003e, \u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_completed/example_completed.py#L55-L58\"\u003e55\u0026ndash;58\u003c/a\u003e, \u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_completed/example_completed.py#L65-L70\"\u003e65\u0026ndash;70\u003c/a\u003e, \u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_completed/example_completed.py#L91-L92\"\u003e91\u0026ndash;92\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan=\"5\"\u003e\u003cb\u003efunctions/example_manager\u003c/b\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u0026nbsp; \u0026nbsp;\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_manager/example_manager.py\"\u003eexample_manager.py\u003c/a\u003e\u003c/td\u003e\u003ctd\u003e44\u003c/td\u003e\u003ctd\u003e11\u003c/td\u003e\u003ctd\u003e75%\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_manager/example_manager.py#L31-L33\"\u003e31\u0026ndash;33\u003c/a\u003e, \u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_manager/example_manager.py#L49-L55\"\u003e49\u0026ndash;55\u003c/a\u003e, \u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_manager/example_manager.py#L67-L69\"\u003e67\u0026ndash;69\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u0026nbsp; \u0026nbsp;\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_manager/example_static.py\"\u003eexample_static.py\u003c/a\u003e\u003c/td\u003e\u003ctd\u003e40\u003c/td\u003e\u003ctd\u003e2\u003c/td\u003e\u003ctd\u003e95%\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/example_manager/example_static.py#L60-L61\"\u003e60\u0026ndash;61\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan=\"5\"\u003e\u003cb\u003efunctions/my_exampels\u003c/b\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u0026nbsp; \u0026nbsp;\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/my_exampels/example.py\"\u003eexample.py\u003c/a\u003e\u003c/td\u003e\u003ctd\u003e20\u003c/td\u003e\u003ctd\u003e20\u003c/td\u003e\u003ctd\u003e0%\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/my_exampels/example.py#L1-L31\"\u003e1\u0026ndash;31\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan=\"5\"\u003e\u003cb\u003efunctions/resources\u003c/b\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u0026nbsp; \u0026nbsp;\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/resources/resources.py\"\u003eresources.py\u003c/a\u003e\u003c/td\u003e\u003ctd\u003e26\u003c/td\u003e\u003ctd\u003e26\u003c/td\u003e\u003ctd\u003e0%\u003c/td\u003e\u003ctd\u003e\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/blob/680f562642190a6a28f6c54785c767e2586b44b8/functions/resources/resources.py#L1-L37\"\u003e1\u0026ndash;37\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd\u003e\u003cb\u003eTOTAL\u003c/b\u003e\u003c/td\u003e\u003ctd\u003e\u003cb\u003e1055\u003c/b\u003e\u003c/td\u003e\u003ctd\u003e\u003cb\u003e739\u003c/b\u003e\u003c/td\u003e\u003ctd\u003e\u003cb\u003e30%\u003c/b\u003e\u003c/td\u003e\u003ctd\u003e\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/details\u003e\n\n| Tests | Skipped | Failures | Errors   | Time               |\n| ----- | ------- | -------- | -------- | ------------------ |\n| 109   | 2 :zzz: | 1 :x:    | 0 :fire: | 0.583s :stopwatch: |\n\n## Example usage\n\nThe following is an example GitHub Action workflow that uses the Pytest Coverage Comment to extract the coverage report to comment at pull request:\n\n```yaml\n# This workflow will install dependencies, create coverage tests and run Pytest Coverage Comment\n# For more information see: https://github.com/MishaKav/pytest-coverage-comment/\nname: pytest-coverage-comment\non:\n  pull_request:\n    branches:\n      - '*'\n\n# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs\n# `contents` is for permission to the contents of the repository.\n# `pull-requests` is for permission to pull request\npermissions:\n  contents: write\n  checks: write\n  pull-requests: write\n\njobs:\n  build:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n\n      - name: Set up Python 3.8\n        uses: actions/setup-python@v2\n        with:\n          python-version: 3.8\n\n      - name: Install dependencies\n        run: |\n          python -m pip install --upgrade pip\n          pip install flake8 pytest pytest-cov\n          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi\n\n      - name: Build coverage file\n        run: |\n          pytest --junitxml=pytest.xml --cov-report=term-missing:skip-covered --cov=app tests/ | tee pytest-coverage.txt\n\n      - name: Pytest coverage comment\n        uses: MishaKav/pytest-coverage-comment@main\n        with:\n          pytest-coverage-path: ./pytest-coverage.txt\n          junitxml-path: ./pytest.xml\n```\n\nExample GitHub Action workflow that uses coverage percentage as output (see the [live workflow](../main/.github/workflows/live-test.yml))\n\n```yaml\n- name: Pytest coverage comment\n  id: coverageComment\n  uses: MishaKav/pytest-coverage-comment@main\n  with:\n    pytest-coverage-path: ./pytest-coverage.txt\n    junitxml-path: ./pytest.xml\n\n- name: Check the output coverage\n  run: |\n    echo \"Coverage Percentage - ${{ steps.coverageComment.outputs.coverage }}\"\n    echo \"Coverage Color - ${{ steps.coverageComment.outputs.color }}\"\n    echo \"Coverage Html - ${{ steps.coverageComment.outputs.coverageHtml }}\"\n    echo \"Summary Report - ${{ steps.coverageComment.outputs.summaryReport }}\"\n\n    echo \"Coverage Warnings - ${{ steps.coverageComment.outputs.warnings }}\"\n\n    echo \"Coverage Errors - ${{ steps.coverageComment.outputs.errors }}\"\n    echo \"Coverage Failures - ${{ steps.coverageComment.outputs.failures }}\"\n    echo \"Coverage Skipped - ${{ steps.coverageComment.outputs.skipped }}\"\n    echo \"Coverage Tests - ${{ steps.coverageComment.outputs.tests }}\"\n    echo \"Coverage Time - ${{ steps.coverageComment.outputs.time }}\"\n    echo \"Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}\"\n```\n\nExample GitHub Action workflow that get coverage report from coverage-xml instead of coverage.txt\n`pytest --cov-report \"xml:coverage.xml\" --cov=src tests/`\n\n```yaml\n- name: Pytest coverage comment\n  uses: MishaKav/pytest-coverage-comment@main\n  with:\n    pytest-xml-coverage-path: ./coverage.xml\n```\n\nExample GitHub Action workflow that passes all params to Pytest Coverage Comment\n\n```yaml\n- name: Pytest coverage comment\n  uses: MishaKav/pytest-coverage-comment@main\n  with:\n    pytest-coverage-path: ./path-to-file/pytest-coverage.txt\n    pytest-xml-coverage-path: ./path-to-file/coverage.xml\n    title: My Coverage Report Title\n    badge-title: My Badge Coverage Title\n    hide-badge: false\n    hide-report: false\n    create-new-comment: false\n    hide-comment: false\n    report-only-changed-files: false\n    remove-link-from-badge: false\n    unique-id-for-comment: python3.8\n    junitxml-path: ./path-to-file/pytest.xml\n    junitxml-title: My JUnit Xml Summary Title\n```\n\n![image](https://user-images.githubusercontent.com/289035/126039976-3f1bf8dd-5a6b-4103-8548-fc3eecc377d7.png)\n\nExample GitHub Action workflow that runs pytest inside **docker**\nIt will generate `pytest-coverage.txt` and `pytest.xml` in `/tmp` directory inside docker and share `/tmp` directory with GitHub workspace.\n\n```yaml\n- name: Run unit tests (pytest)\n  run: |\n    docker run -v /tmp:/tmp $IMAGE_TAG python3 -m pytest --cov-report=term-missing:skip-covered --junitxml=/tmp/pytest.xml --cov=src tests/ | tee /tmp/pytest-coverage.txt\n\n- name: Pytest coverage comment\n  uses: MishaKav/pytest-coverage-comment@main\n  with:\n    pytest-coverage-path: /tmp/pytest-coverage.txt\n    junitxml-path: /tmp/pytest.xml\n```\n\nExample GitHub Action workflow that uses multiple files mode (see the [live workflow](../main/.github/workflows/multiple-files.yml))\n\n```yaml\n- name: Pytest coverage comment\n  uses: MishaKav/pytest-coverage-comment@main\n  with:\n    multiple-files: |\n      My Title 1, ./data/pytest-coverage_3.txt, ./data/pytest_junit_1.xml\n      My Title 2, ./data/pytest-coverage_4.txt, ./data/pytest_junit_2.xml\n```\n\nExample GitHub Action workflow that will update your `README.md` with coverage report, only on merge to `main` branch (see the [update-coverage-on-readme workflow](../main/.github/workflows/update-coverage-on-readme.yml))\nAll you need is to add in your `README.md` the following lines wherever you want.\nIf your coverage html report will not change, it wouldn't push any changes to readme file.\n\n```html\n\u003c!-- Pytest Coverage Comment:Begin --\u003e\n\u003c!-- Pytest Coverage Comment:End --\u003e\n```\n\n```yaml\nname: Update Coverage on Readme\non:\n  push:\n\n# https://docs.github.com/en/actions/using-jobs/assigning-permissions-to-jobs\n# `contents` is for permission to the contents of the repository.\n# `pull-requests` is for permission to pull request\npermissions:\n  contents: write\n  checks: write\n  pull-requests: write\n\njobs:\n  update-coverage-on-readme:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v3\n        with:\n          persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token\n          fetch-depth: 0 # otherwise, you will failed to push refs to dest repo\n\n      - name: Pytest coverage comment\n        if: ${{ github.ref == 'refs/heads/main' }}\n        id: coverageComment\n        uses: MishaKav/pytest-coverage-comment@main\n        with:\n          hide-comment: true\n          pytest-coverage-path: ./data/pytest-coverage_4.txt\n\n      - name: Update Readme with Coverage Html\n        if: ${{ github.ref == 'refs/heads/main' }}\n        run: |\n          sed -i '/\u003c!-- Pytest Coverage Comment:Begin --\u003e/,/\u003c!-- Pytest Coverage Comment:End --\u003e/c\\\u003c!-- Pytest Coverage Comment:Begin --\u003e\\n\\${{ steps.coverageComment.outputs.coverageHtml }}\\n\u003c!-- Pytest Coverage Comment:End --\u003e' ./README.md\n\n      - name: Commit \u0026 Push changes to Readme\n        if: ${{ github.ref == 'refs/heads/main' }}\n        uses: actions-js/push@master\n        with:\n          message: Update coverage on Readme\n          github_token: ${{ secrets.GITHUB_TOKEN }}\n```\n\n## Result example\n\nCollapsed comment\n![Result Collapse Example](https://user-images.githubusercontent.com/289035/120536428-c7664a80-c3ec-11eb-9cce-3ac53343fac4.png)\n\nExpanded comment\n![Result Expand Example](https://user-images.githubusercontent.com/289035/120536607-f8df1600-c3ec-11eb-9f49-c6d7571e43ac.png)\n\nMultiple Files Mode (can be useful on mono-repo projects)\n![Result Multiple Files Mode Example](https://user-images.githubusercontent.com/289035/122121939-ddd0c500-ce34-11eb-8546-89a8a769e065.png)\n\n## Badge Colors\n\n| Badge                                                                           | Range    |\n| ------------------------------------------------------------------------------- | -------- |\n| ![Coverage 0-40](https://img.shields.io/badge/Coverage-20%25-red.svg)           | 0 - 40   |\n| ![Coverage 40-60](https://img.shields.io/badge/Coverage-50%25-orange.svg)       | 40 - 60  |\n| ![Coverage 60-80](https://img.shields.io/badge/Coverage-70%25-yellow.svg)       | 60 - 80  |\n| ![Coverage 80-90](https://img.shields.io/badge/Coverage-85%25-green.svg)        | 80 - 90  |\n| ![Coverage 90-100](https://img.shields.io/badge/Coverage-95%25-brightgreen.svg) | 90 - 100 |\n\n## Auto updating badge on README\n\nIf you want auto-update the coverage badge on your Readme, you can see the [workflow](../main/.github/workflows/live-test.yml)\n![Auto Updating Bagde](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/MishaKav/5e90d640f8c212ab7bbac38f72323f80/raw/pytest-coverage-comment__main.json)\n\n## 🤝 Contributing [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)\n\nWe welcome all contributions. You can submit any ideas as [pull requests](https://github.com/MishaKav/pytest-coverage-comment/pulls) or as [GitHub issues](https://github.com/MishaKav/pytest-coverage-comment/issues) and have a good time! :)\n\n## Our Contibutors\n\n\u003ca href=\"https://github.com/MishaKav/pytest-coverage-comment/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=MishaKav/pytest-coverage-comment\" alt=\"Contibutors\" /\u003e\n\u003c/a\u003e\n","funding_links":["https://patreon.com/MishaKav","paypal.me/MishaKav"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmishakav%2Fpytest-coverage-comment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmishakav%2Fpytest-coverage-comment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmishakav%2Fpytest-coverage-comment/lists"}