From 87812321e539dc7e55d7ea7da4b592e596a48892 Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:12:27 +0000 Subject: [PATCH 01/16] Try to add badges to a different repo's gh-pages --- .github/workflows/tests.yml | 41 ++++++++++++++++++++++++++++++++++--- .gitignore | 2 ++ setup.cfg | 4 +++- 3 files changed, 43 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2f4f28e..1ce78ee 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,9 +24,44 @@ jobs: uses: actions/setup-python@v5 with: python-version: "3.10" - + - name: Install run: pip install .[test] - - name: Run tests - run: pytest + - name: Run tests and create reports and badges + run: | + coverage run -m pytest --junitxml=reports/junit/junit.xml --html=reports/junit/report.html + 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: Upload badges and reports to github actions + run: | + mkdir -p badges + mv *badge.svg badges + ## todo: + ## upload badges and reports to github pages + ## link to badges in readme + ## test badge links + + - name: Setup Temporary Directory + run: | + mkdir gh-pages + cp -R badges gh-pages/ + cp -R reports gh-pages/ + + - name: Clone Target Repository + run: | + git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/alanocallaghan/badges.git badges + cp -R gh-pages/* target_repo/ + + # Push changes to the target repository + - name: Deploy to gh-pages + run: | + cd target_repo + 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/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 From 216b9d075e0fe0afa879e3b0ef8580598c912872 Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:16:16 +0000 Subject: [PATCH 02/16] mv not cp --- .github/workflows/tests.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1ce78ee..2365503 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -37,6 +37,7 @@ jobs: genbadge tests -i reports/junit/junit.xml - name: Upload badges and reports to github actions + if: github.ref_name == 'main' run: | mkdir -p badges mv *badge.svg badges @@ -46,18 +47,21 @@ jobs: ## test badge links - name: Setup Temporary Directory + if: github.ref_name == 'main' run: | mkdir gh-pages - cp -R badges gh-pages/ - cp -R reports gh-pages/ + mv badges gh-pages/ + mv reports gh-pages/ - name: Clone Target Repository + if: github.ref_name == 'main' run: | git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/alanocallaghan/badges.git badges cp -R gh-pages/* target_repo/ # Push changes to the target repository - name: Deploy to gh-pages + if: github.ref_name == 'main' run: | cd target_repo git config user.name "github-actions[bot]" From 826cb8c733d1b98071654f686f388a1de589c11a Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:25:06 +0000 Subject: [PATCH 03/16] badges --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 2365503..a4c301c 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -57,7 +57,7 @@ jobs: if: github.ref_name == 'main' run: | git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/alanocallaghan/badges.git badges - cp -R gh-pages/* target_repo/ + cp -R gh-pages/* badges/ # Push changes to the target repository - name: Deploy to gh-pages From b2cd472be6668eb4d68f192cf72f3f5f296767c2 Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:28:13 +0000 Subject: [PATCH 04/16] badges --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a4c301c..10f81bb 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -63,7 +63,7 @@ jobs: - name: Deploy to gh-pages if: github.ref_name == 'main' run: | - cd target_repo + cd badges git config user.name "github-actions[bot]" git config user.email "github-actions[bot]@users.noreply.github.com" git add . From d2eb38dff3485582e13bc5de1dbf4b2319628eee Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:34:46 +0000 Subject: [PATCH 05/16] Add readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 6b7191e..6208650 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ +[![Coverage](https://alanocallaghan.github.io/badges/badges/coverage-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/coverage/index.html?dummy=1234) +[![Tests](https://alanocallaghan.github.io/badges/badges/test-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/junit/report.html?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. From 0300ec18bc1e811031ec9b1518d39acc3bf73324 Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:39:34 +0000 Subject: [PATCH 06/16] Clean code and use subdir --- .github/workflows/tests.yml | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 10f81bb..71e61bd 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -36,32 +36,30 @@ jobs: genbadge coverage -i reports/coverage/coverage.xml genbadge tests -i reports/junit/junit.xml + upload: + runs-on: ubuntu-latest + if: github.ref_name == 'main' + needs: test + steps: + - name: Upload badges and reports to github actions - if: github.ref_name == 'main' run: | mkdir -p badges mv *badge.svg badges - ## todo: - ## upload badges and reports to github pages - ## link to badges in readme - ## test badge links - name: Setup Temporary Directory - if: github.ref_name == 'main' run: | - mkdir gh-pages - mv badges gh-pages/ - mv reports gh-pages/ + mkdir assets + mv badges assets/ + mv reports assets/ - name: Clone Target Repository - if: github.ref_name == 'main' run: | - git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/alanocallaghan/badges.git badges - cp -R gh-pages/* badges/ + git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/alanocallaghan/badges.git badges + mkdir -p badges/${{ github.event.repository.name }} + mv assets/* badges/${{github.event.repository.name}}/ - # Push changes to the target repository - name: Deploy to gh-pages - if: github.ref_name == 'main' run: | cd badges git config user.name "github-actions[bot]" From d93dbaf800f9a65c7e61df97ec2dc1acc3c80b71 Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:40:45 +0000 Subject: [PATCH 07/16] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6208650..858eafa 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ [![Coverage](https://alanocallaghan.github.io/badges/badges/coverage-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/coverage/index.html?dummy=1234) -[![Tests](https://alanocallaghan.github.io/badges/badges/test-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/junit/report.html?dummy=1234) +[![Tests](https://alanocallaghan.github.io/badges/badges/tests-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/junit/report.html?dummy=1234) # QuBaLab From 2b8476cbc37e80db7e22f6b743474359a3b8098c Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:46:35 +0000 Subject: [PATCH 08/16] Dumb way --- .github/workflows/tests.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 71e61bd..f445939 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -28,38 +28,41 @@ jobs: - name: Install run: pip install .[test] - - name: Run tests and create reports and badges + - name: Run tests run: | coverage run -m pytest --junitxml=reports/junit/junit.xml --html=reports/junit/report.html + + - 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 - upload: - runs-on: ubuntu-latest - if: github.ref_name == 'main' - needs: test - steps: - name: Upload badges and reports to github actions + if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | mkdir -p badges mv *badge.svg badges - name: Setup Temporary Directory + if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | mkdir assets mv badges assets/ mv reports assets/ - name: Clone Target Repository + if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/alanocallaghan/badges.git badges mkdir -p badges/${{ github.event.repository.name }} mv assets/* badges/${{github.event.repository.name}}/ - name: Deploy to gh-pages + if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | cd badges git config user.name "github-actions[bot]" From 54f089d587793313326d80b210c6043ca8efd05b Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:48:21 +0000 Subject: [PATCH 09/16] Add workflow badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 858eafa..abc9234 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,6 @@ [![Coverage](https://alanocallaghan.github.io/badges/badges/coverage-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/coverage/index.html?dummy=1234) [![Tests](https://alanocallaghan.github.io/badges/badges/tests-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/junit/report.html?dummy=1234) +![Actions](https://github.com/alanocallaghan/qubalab/actions/workflows/main.yml/badge.svg?dummy=1234) # QuBaLab From c38b52821803403c09e83e61eadee5ab4d446d0f Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:52:32 +0000 Subject: [PATCH 10/16] Typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index abc9234..2bbfe34 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Coverage](https://alanocallaghan.github.io/badges/badges/coverage-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/coverage/index.html?dummy=1234) [![Tests](https://alanocallaghan.github.io/badges/badges/tests-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/junit/report.html?dummy=1234) -![Actions](https://github.com/alanocallaghan/qubalab/actions/workflows/main.yml/badge.svg?dummy=1234) +![Actions](https://github.com/alanocallaghan/qubalab/actions/workflows/tests.yml/badge.svg?dummy=1234) # QuBaLab From 37b9bdc12dc7483b17854ee8a8311d3b69872aa0 Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:53:58 +0000 Subject: [PATCH 11/16] Remove before adding --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f445939..6375ba8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -58,6 +58,8 @@ jobs: if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/alanocallaghan/badges.git badges + ## cba handling merging or dealing with stale resources + rm -r badges/${{ github.event.repository.name }} mkdir -p badges/${{ github.event.repository.name }} mv assets/* badges/${{github.event.repository.name}}/ From 7e62baa0734a2b677d1c84c6580dd7d8e57851dd Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:56:23 +0000 Subject: [PATCH 12/16] Rename workflow --- .github/workflows/tests.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6375ba8..1abb887 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 -name: test +name: pytest on: push: @@ -32,6 +32,8 @@ jobs: 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: | @@ -57,7 +59,7 @@ jobs: - name: Clone Target Repository if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | - git clone --branch=gh-pages https://${{ secrets.TARGET_REPO_ACCESS_TOKEN }}@github.com/alanocallaghan/badges.git badges + 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 -r badges/${{ github.event.repository.name }} mkdir -p badges/${{ github.event.repository.name }} From 6606ecd1f39c4af9f97fd855f534f29a806fa53d Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 15:59:42 +0000 Subject: [PATCH 13/16] qupath github links --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2bbfe34..dea151e 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -[![Coverage](https://alanocallaghan.github.io/badges/badges/coverage-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/coverage/index.html?dummy=1234) -[![Tests](https://alanocallaghan.github.io/badges/badges/tests-badge.svg?dummy=1234)](https://alanocallaghan.github.io/badges/reports/junit/report.html?dummy=1234) -![Actions](https://github.com/alanocallaghan/qubalab/actions/workflows/tests.yml/badge.svg?dummy=1234) +[![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 From 6a50b6aa9edcc488ecfa820f4d1cd5ee67ca286f Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 16:03:13 +0000 Subject: [PATCH 14/16] force in case not existing --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 1abb887..17d3c6f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -61,7 +61,7 @@ jobs: 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 -r badges/${{ github.event.repository.name }} + rm -rf badges/${{ github.event.repository.name }} mkdir -p badges/${{ github.event.repository.name }} mv assets/* badges/${{github.event.repository.name}}/ From a131d4a80b907e06550860bae7fcf45214fdd6aa Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 16:07:38 +0000 Subject: [PATCH 15/16] Better step names --- .github/workflows/tests.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 17d3c6f..948eaf5 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -43,20 +43,20 @@ jobs: genbadge tests -i reports/junit/junit.xml - - name: Upload badges and reports to github actions + - name: Make badge dir if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | mkdir -p badges mv *badge.svg badges - - name: Setup Temporary Directory + - name: Setup assets dir if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | mkdir assets mv badges assets/ mv reports assets/ - - name: Clone Target Repository + - 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 @@ -65,7 +65,7 @@ jobs: mkdir -p badges/${{ github.event.repository.name }} mv assets/* badges/${{github.event.repository.name}}/ - - name: Deploy to gh-pages + - name: Deploy badges to gh-pages if: github.ref_name == 'main' && matrix.os == 'ubuntu-latest' run: | cd badges From 94825ca7ef52aaa0cb1e32bad76f9ed80fc59b6b Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Fri, 15 Nov 2024 16:13:33 +0000 Subject: [PATCH 16/16] Accurate comment in yaml --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 948eaf5..c5372fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,4 +1,4 @@ -# 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: pytest