diff --git a/.github/workflows/pr_validation.yml b/.github/workflows/pr_validation.yml index ebfc02f3..68dd3c5c 100644 --- a/.github/workflows/pr_validation.yml +++ b/.github/workflows/pr_validation.yml @@ -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 @@ -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 '[0-9]+%' 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" diff --git a/README.md b/README.md index 92a0c822..68593e0c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ # FedECA + :arrow_right:[The API doc is available here](https://owkin.github.io/fedeca/):arrow_left: @@ -59,4 +60,4 @@ archivePrefix = {arXiv}, adsnote = {Provided by the SAO/NASA Astrophysics Data System} } -``` \ No newline at end of file +``` diff --git a/badges/.gitkeep b/badges/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/badges/cov_badge.svg b/badges/cov_badge.svg new file mode 100644 index 00000000..704c1cce --- /dev/null +++ b/badges/cov_badge.svg @@ -0,0 +1 @@ +coverage: 44%coverage44%