From b4ca19403461284cb95b30a8e7da2344a35e3462 Mon Sep 17 00:00:00 2001 From: Heinz-Alexander Fuetterer <35225576+afuetterer@users.noreply.github.com> Date: Mon, 15 Jan 2024 15:15:35 +0100 Subject: [PATCH] ci: add coverage badge and report --- .github/workflows/ci.yml | 14 +++++++++++--- .pre-commit-config.yaml | 1 + README.md | 3 ++- pyproject.toml | 7 +++---- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index dc41dc21..044cd03e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -71,6 +71,8 @@ jobs: tests: runs-on: ubuntu-22.04 + permissions: + contents: write steps: - uses: actions/checkout@v4 - name: Set up Python 3.11 @@ -84,9 +86,6 @@ jobs: python -m pip install --upgrade hatch - name: Run test suite with coverage run: hatch run cov-ci - - name: Generate badges - if: always() - run: hatch run badges - name: Upload test results if: always() uses: actions/upload-artifact@v4 @@ -101,6 +100,15 @@ jobs: name: coverage-results retention-days: 1 path: pytest-cobertura.xml + - run: rm ./reports/coverage/.gitignore + - name: Generate coverage badge + if: github.ref == 'refs/heads/master' + run: hatch run cov-badge + - name: Deploy reports to GitHub Pages + if: github.ref == 'refs/heads/master' + uses: JamesIves/github-pages-deploy-action@65b5dfd4f5bcd3a7403bbc2959c144256167464e # v4.5.0 + with: + folder: ./reports event_file: runs-on: ubuntu-22.04 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8626ec6b..fa64609e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,7 @@ repos: rev: v4.5.0 hooks: - id: end-of-file-fixer + exclude_types: [svg] - id: mixed-line-ending types: [python] - id: trailing-whitespace diff --git a/README.md b/README.md index 2672ea11..1cb83914 100644 --- a/README.md +++ b/README.md @@ -4,10 +4,11 @@ Developers: [Robert Huber](mailto:rhuber@marum.de), [Anusuriya Devaraju](mailto: Thanks to [Heinz-Alexander Fuetterer](https://github.com/afuetterer) for his contributions and his help in cleaning up the code. [![CI](https://github.com/pangaea-data-publisher/fuji/actions/workflows/ci.yml/badge.svg)](https://github.com/pangaea-data-publisher/fuji/actions/workflows/ci.yml) +[![Coverage](https://pangaea-data-publisher.github.io/fuji/coverage/coveragebadge.svg)](https://pangaea-data-publisher.github.io/fuji/coverage/) + [![Publish Docker image](https://github.com/pangaea-data-publisher/fuji/actions/workflows/publish-docker.yml/badge.svg)](https://github.com/pangaea-data-publisher/fuji/actions/workflows/publish-docker.yml) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4063720.svg)](https://doi.org/10.5281/zenodo.4063720) - ## Overview F-UJI is a web service to programmatically assess FAIRness of research data objects based on [metrics](https://doi.org/10.5281/zenodo.3775793) developed by the [FAIRsFAIR](https://www.fairsfair.eu/) project. diff --git a/pyproject.toml b/pyproject.toml index d1372296..618e203e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -79,7 +79,7 @@ report = [ "jupyter~=1.0" ] testing = [ - "genbadge[tests]~=1.1", + "genbadge[coverage]~=1.1", "pytest~=7.4", "pytest-cov~=4.1", "pytest-randomly~=3.15", @@ -122,10 +122,9 @@ features = [ ] [tool.hatch.envs.default.scripts] -badges = "genbadge tests --input-file=pytest-junit.xml" cov = "pytest --cov {args}" -cov-ci = "pytest --cov --junitxml=pytest-junit.xml --cov-report=xml:pytest-cobertura.xml {args}" -cov-html = "pytest --cov --cov-report=html {args}" +cov-badge = "genbadge coverage --input-file=pytest-cobertura.xml --output-file=./reports/coverage/coveragebadge.svg" +cov-ci = "pytest --cov --junitxml=pytest-junit.xml --cov-report=xml:pytest-cobertura.xml --cov-report=html:./reports/coverage/ {args}" lint = "pre-commit run --all-files --color=always {args}" test = "pytest {args}"