Skip to content

Commit b7774d5

Browse files
committed
chore: remove genbadge dep
1 parent ebd6833 commit b7774d5

File tree

7 files changed

+132
-41
lines changed

7 files changed

+132
-41
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,16 @@ jobs:
8383
run: |
8484
source .venv/bin/activate
8585
make pytest
86+
#-----------------------------------------------
87+
# Create coverage badge
88+
#-----------------------------------------------
89+
- name: Create coverage badge
90+
run: |
91+
make coverage-badge
92+
- name: Add & Commit
93+
uses: EndBug/[email protected]
94+
with:
95+
author_name: ${{ github.actor }}
96+
author_email: ${{ github.actor }}@users.noreply.github.com
97+
message: "ci: Update coverage badge [ci skip]"
98+
add: "coverage.svg"

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ LINT_PATHS=${PACKAGE_NAME}/
77
pytest:
88
bash ./scripts/run_tests.sh
99

10+
coverage-badge:
11+
# Generate coverage badge
12+
poetry run python ./scripts/generate_coverage_badge.py
13+
1014
check-codestyle:
1115
# Reformat using black
1216
poetry run black --check -l 127 ${LINT_PATHS}

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# `eagerx_template` package
2+
3+
[![license](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
4+
[![codestyle](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
5+
[![Continuous Integration](https://github.com/eager-dev/eagerx_template/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/eager-dev/eagerx_template/actions/workflows/ci.yml)
6+
[![Test Coverage](coverage.svg)](https://github.com/eager-dev/eagerx_template/actions/workflows/ci.yml)
7+
8+
9+
What is the `eagerx_template` package
10+
-------------------------------------
11+
12+
This repository provides a template for creating EAGERx packages.
13+
EAGERx (Engine Agnostic Graph Environments for Robotics) enables users to easily define new tasks, switch from one sensor to another, and switch from simulation to reality with a single line of code by being invariant to the physics engine.
14+
15+
[The core repository is available here.](https://github.com/eager-dev/eagerx)
16+
[Full documentation and tutorials (including package creation and contributing) are available here.](https://eagerx.readthedocs.io/en/master/)
17+
18+
Installation
19+
------------
20+
21+
You can install the package using pip:
22+
23+
```bash
24+
pip3 install eagerx_template
25+
```
26+
27+
Cite EAGERx
28+
-----------
29+
30+
If you are using EAGERx for your scientific publications, please cite:
31+
32+
``` {.sourceCode .bibtex}
33+
@article{eagerx,
34+
author = {van der Heijden, Bas and Luijkx, Jelle, and Ferranti, Laura and Kober, Jens and Babuska, Robert},
35+
title = {EAGERx: Engine Agnostic Graph Environments for Robotics},
36+
year = {2022},
37+
publisher = {GitHub},
38+
journal = {GitHub repository},
39+
howpublished = {\url{https://github.com/eager-dev/eagerx}}
40+
}
41+
```
42+
43+
Acknowledgements
44+
----------------
45+
46+
EAGERx is funded by the [OpenDR](https://opendr.eu/) Horizon 2020
47+
project.

README.rst

Lines changed: 0 additions & 40 deletions
This file was deleted.

coverage.svg

Lines changed: 26 additions & 0 deletions
Loading

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ pytest = "^7.0"
1818
pytest-cov = "^3.0.0"
1919
flake8 = ">=3"
2020
flake8-bugbear = "^22.3.23"
21-
genbadge = "^1.1.0"
2221

2322
[build-system]
2423
requires = ["poetry-core>=1.0.0"]

scripts/generate_coverage_badge.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import re
2+
from pathlib import Path
3+
4+
5+
ROOT = Path(__file__).parent.parent
6+
7+
8+
if __name__ == "__main__":
9+
# Get the coverage percentage from the coverage file
10+
with open(f"{ROOT}/coverage.xml", "r") as f:
11+
coverage = f.read().split("line-rate=")[1].split('"')[1]
12+
coverage = float(coverage) * 100
13+
14+
# Update coverage.svg with the new coverage percentage
15+
with open(f"{ROOT}/coverage.svg", "r") as f:
16+
svg = f.read()
17+
18+
# Replace coverage percentage in aria-label with two decimals
19+
svg = re.sub(r'aria-label=".*%"', f'aria-label="{coverage:.2f}%"', svg)
20+
21+
# Replace coverage in title
22+
svg = re.sub(r'<title>.*</title>', f'<title>{coverage:.2f}%</title>', svg)
23+
24+
# Replace coverage in text
25+
svg = re.sub(r">.*%</text>", f">{coverage:.2f}%</text>", svg)
26+
27+
# Calculate red and blue rgb values based on coverage (till 50% red)
28+
red = int(255 * (1 - max(coverage - 50, 0) / 50))
29+
green = int(255 * max(coverage - 50, 0) / 50)
30+
31+
# Get rgb string
32+
rgb_string = "rgb({},{},{})".format(red, green, 0)
33+
34+
# Replace rgb in fill
35+
svg = re.sub(r'fill="rgb\(.*\)"', f'fill="{rgb_string}"', svg)
36+
37+
# Save the new svg
38+
with open(f"{ROOT}/coverage.svg", "w") as f:
39+
f.write(svg)
40+
41+
42+

0 commit comments

Comments
 (0)