Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: coverage badge #38

Open
pawamoy opened this issue May 19, 2021 · 1 comment
Open

Feature: coverage badge #38

pawamoy opened this issue May 19, 2021 · 1 comment
Labels
feature New feature or request fund Issue priority can be boosted

Comments

@pawamoy
Copy link
Owner

pawamoy commented May 19, 2021

  • add a docs macro that outputs a JSON badge:

    @env.macro
    def get_coverage():
        data = json.load(Path("htmlcov/coverage.json").read_text())
        value = int(data["totals"]["percent_covered"])
        for threshold, hex in (
            (95, "#4c1"),  # brightgreen
            (90, "#97CA00"),  # green
            (75, "#a4a61d"),  # yellowgreen
            (60, "#dfb317"),  # yellow
            (40, "#fe7d37"),  # orange
            (0, "#e05d44"),  # red
        ):
            if value >= threshold:
                color = hex
                break
        return {"value": value, "color": color}
  • add a templated file coverage_badge.json to the docs:

    {% with get_coverage() as coverage %}
    {"schemaVersion": 1, "label": "coverage", "message": "{{ coverage.value }}", "color": "{{ coverage.color }}"}
    {% endwith %}
    
  • add a badge to the readme pointing to that published JSON file:

    [![coverage](https://img.shields.io/endpoint?url=https://namespace.github.io/project/coverage_badge.json)](https://namespace.github.io/project/coverage)

Boost priority

  • Boost priority in our backlog through Polar.sh. Higher pledge, higher priority.
  • Minimum pledge by user/organization is $5, minimum amount for boost is $30.
  • View all issues with pledges.
  • We receive the funds once the issue is completed and confirmed by you.
  • Features with the insiders label are released to sponsors first, and tied to a funding goal.
Fund with Polar
@pawamoy
Copy link
Owner Author

pawamoy commented May 21, 2021

Not possible to render a JSON file through MkDocs + macros unfortunately... Maybe I'll implement this in mkdocs-coverage.

@pawamoy pawamoy added feature New feature or request fund Issue priority can be boosted labels Oct 25, 2024
@pawamoy pawamoy transferred this issue from pawamoy/copier-pdm Oct 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request fund Issue priority can be boosted
Projects
None yet
Development

No branches or pull requests

1 participant