Skip to content

Commit

Permalink
Add badges (#29)
Browse files Browse the repository at this point in the history
Add self-hosted (well, github pages hosted) badges and reports (tests and coverage) using coverage.py and genbadge.

The reports and badges are hosted in a different repo. To add this to another repo, you'd just have to use a suitable access token as a repository secret (ie, one that has access to the qupath badges repo).
  • Loading branch information
alanocallaghan authored Nov 15, 2024
1 parent 64670cf commit 9fbec3f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 5 deletions.
52 changes: 48 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# This workflow will run unit tests on pull requests or when manually activated
# This workflow will run unit tests when main is updated, on pull requests or when manually activated

name: test
name: pytest

on:
push:
Expand All @@ -24,9 +24,53 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: "3.10"

- name: Install
run: pip install .[test]

- name: Run tests
run: pytest
run: |
coverage run -m pytest --junitxml=reports/junit/junit.xml --html=reports/junit/report.html
## everything from here deals with generating and uploading reports and badges to a separate "badges" repo.
- name: Create reports and badges
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
coverage xml -o reports/coverage/coverage.xml
coverage html -d reports/coverage/
genbadge coverage -i reports/coverage/coverage.xml
genbadge tests -i reports/junit/junit.xml
- name: Make badge dir
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
mkdir -p badges
mv *badge.svg badges
- name: Setup assets dir
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
mkdir assets
mv badges assets/
mv reports assets/
- name: Clone badges repo
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/qupath/badges.git badges
## cba handling merging or dealing with stale resources
rm -rf badges/${{ github.event.repository.name }}
mkdir -p badges/${{ github.event.repository.name }}
mv assets/* badges/${{github.event.repository.name}}/
- name: Deploy badges to gh-pages
if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest'
run: |
cd badges
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "Update badges and reports"
git push
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,5 @@ dmypy.json
# Generated test images
*.tif
*.zarr
reports
*.svg
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
[![Coverage](https://qupath.github.io/badges/badges/coverage-badge.svg?dummy=1234)](https://qupath.github.io/badges/reports/coverage/index.html?dummy=1234)
[![Tests](https://qupath.github.io/badges/badges/tests-badge.svg?dummy=1234)](https://qupath.github.io/badges/reports/junit/report.html?dummy=1234)
![Actions](https://github.com/qupath/qubalab/actions/workflows/tests.yml/badge.svg?dummy=1234)
# QuBaLab


This is a Python package for exploring quantitative bioimage analysis... *especially* (but not exclusively) in combination with QuPath (https://qupath.github.io/).

The name comes from **Quantitative Bioimage Analysis Laboratory**. This is chosen to be reminiscent of QuPath (*Quantitative Pathology*), but recognizes that neither is really restricted to pathology.
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ dev =
jupyter ~= 1.0.0
test =
pytest ~= 8.2.2
openslide =
pytest-html ~= 4.1.1
coverage ~= 7.6.5
genbadge[all] ~= 1.1.1
doc =
sphinx ~= 7.4.5
sphinx-rtd-theme ~= 2.0.0

0 comments on commit 9fbec3f

Please sign in to comment.