Skip to content

Commit

Permalink
Trying to add coverage report (#60)
Browse files Browse the repository at this point in the history
* Update README.md

* Update README.md

* trying to have a CI with coverage

* Update .github/workflows/pr_validation.yml

* adding badges folder

* Update pr_validation.yml

* Update pr_validation.yml

* Update pr_validation.yml

* Update .github/workflows/pr_validation.yml

* Update pr_validation.yml

* update coverage badge

* Update README.md

---------

Co-authored-by: jeandut <[email protected]>
  • Loading branch information
jeandut and jeandut authored Oct 23, 2024
1 parent 803f1d7 commit 04e2e35
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
32 changes: 29 additions & 3 deletions .github/workflows/pr_validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ jobs:
python: ["3.9"]
# python: ["3.9", "3.10", "3.11"] # TODO: expand to other pythons
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/checkout@v4
with:
python-version: ${{ matrix.python }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand All @@ -67,3 +67,29 @@ jobs:
name: test-coverage-report
path: htmlcov/
retention-days: 20
- name: Generate coverage status badge
if: github.event_name == 'pull_request'
run: |
set -x
total_cov=`grep -Eo '<span class="pc_cov">[0-9]+%</span>' htmlcov/index.html | grep -oe '\([0-9.]*\)'`
echo $total_cov
if [ "$total_cov" -le "50" ] ; then
COLOR=red
elif [ "$total_cov" -ge "90" ] ; then
COLOR=green
else
COLOR=orange
fi
echo $COLOR
echo "https://img.shields.io/badge/coverage-${total_cov}%25-${COLOR}"
curl "https://img.shields.io/badge/coverage-${total_cov}%25-${COLOR}" > badges/cov_badge.svg
echo "" >> badges/cov_badge.svg
- name: Commit coverage badge
if: github.event_name == 'pull_request'
uses: EndBug/add-and-commit@v9
with:
add: badges/cov_badge.svg
default_author: github_actor
pull: "--no-rebase"
message: "update coverage badge"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# FedECA
<img src="/badges/cov_badge.svg" >

:arrow_right:[The API doc is available here](https://owkin.github.io/fedeca/):arrow_left:

Expand Down Expand Up @@ -59,4 +60,4 @@ archivePrefix = {arXiv},
adsnote = {Provided by the SAO/NASA Astrophysics Data System}
}
```
```
Empty file added badges/.gitkeep
Empty file.
1 change: 1 addition & 0 deletions badges/cov_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 04e2e35

Please sign in to comment.