Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ All notable changes to this project are documented here. The format follows
## [Unreleased]

### Added
- A coverage badge in the README, measured by the tests on master and linked
to the full line-by-line report on the documentation site (ADR 0015).
- A "Code Coverage" badge next to the README title, measured by the tests on
master and linked to the full line-by-line report on the documentation site
(ADR 0015).
Coverage is 100% of lines and branches, release scripts included, and CI
now requires 100%.

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
# PythonMetaTrader5
# PythonMetaTrader5 [![Code Coverage](https://img.shields.io/endpoint?url=https://akinzou.github.io/MetaTrader5-Python/coverage.json)](https://akinzou.github.io/MetaTrader5-Python/coverage/)

[![CI](https://github.com/Akinzou/MetaTrader5-Python/actions/workflows/ci.yml/badge.svg)](https://github.com/Akinzou/MetaTrader5-Python/actions/workflows/ci.yml)
[![Docs](https://img.shields.io/badge/docs-online-blue?logo=materialformkdocs&logoColor=white)](https://akinzou.github.io/MetaTrader5-Python/)
[![Coverage](https://img.shields.io/endpoint?url=https://akinzou.github.io/MetaTrader5-Python/coverage.json)](https://akinzou.github.io/MetaTrader5-Python/coverage/)
[![PyPI](https://img.shields.io/pypi/v/pythonmetatrader5)](https://pypi.org/project/PythonMetaTrader5/)
![Python](https://img.shields.io/badge/python-3.10%2B-blue?logo=python&logoColor=white)
![License](https://img.shields.io/badge/license-CC_BY--NC_4.0-lightgrey.svg)
Expand Down
7 changes: 6 additions & 1 deletion scripts/coverage_badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,14 @@ def main(argv: list[str]) -> int:
# coverage.py's own display rounding: it never shows 100 for 99.9.
badge = {
"schemaVersion": 1,
"label": "coverage",
"label": "Code Coverage",
"message": f"{totals['percent_covered_display']}%",
"color": colour(totals["percent_covered"]),
# pytest's logo: the tests behind the number run under pytest, which
# drives coverage.py through pytest-cov; coverage.py has no logo of its
# own. A coverage service's logo would suggest one this project lacks.
"namedLogo": "pytest",
"logoColor": "white",
}
target.write_text(json.dumps(badge), encoding="utf-8")
print(f"{target}: coverage {badge['message']}")
Expand Down
4 changes: 3 additions & 1 deletion tests/unit/test_coverage_badge.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ def test_the_badge_shows_the_report_total(tmp_path: Path) -> None:
assert badge.main([str(report(tmp_path, "100")), str(out)]) == 0
assert json.loads(out.read_text(encoding="utf-8")) == {
"schemaVersion": 1,
"label": "coverage",
"label": "Code Coverage",
"message": "100%",
"color": "brightgreen",
"namedLogo": "pytest",
"logoColor": "white",
}


Expand Down
Loading