diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2f4f28e..c5372fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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: @@ -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 diff --git a/.gitignore b/.gitignore index d226ef3..bb194fb 100644 --- a/.gitignore +++ b/.gitignore @@ -138,3 +138,5 @@ dmypy.json # Generated test images *.tif *.zarr +reports +*.svg diff --git a/README.md b/README.md index 6b7191e..dea151e 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/setup.cfg b/setup.cfg index 603b379..3c2eec2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -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