From 6102952fc401153ad37090f1f7fe0cc6732f8c1b Mon Sep 17 00:00:00 2001 From: James Friel Date: Mon, 28 Sep 2026 10:28:48 +0100 Subject: [PATCH] add badges --- .github/workflows/tests.yml | 48 +++++++++++++++++++++++++++++++++++++ README.md | 4 ++++ 2 files changed, 52 insertions(+) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..79cbe15 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,48 @@ +name: Tests + +on: + push: + branches: [main] + pull_request: + branches: [main] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: actions/setup-python@v5 + with: + python-version: '3.13' + + - name: Install dependencies + run: pip install -r requirements-dev.txt + + - name: Run tests with coverage + run: python -m pytest tests --cov=processing_engine --cov-report=term-missing --cov-report=json --cov-branch + + - name: Extract coverage percentage + id: coverage + run: | + COVERAGE=$(python -c "import json; d=json.load(open('coverage.json')); print(round(d['totals']['percent_covered']))") + echo "percentage=${COVERAGE}" >> $GITHUB_OUTPUT + if [ "$COVERAGE" -ge 90 ]; then COLOR="brightgreen" + elif [ "$COVERAGE" -ge 80 ]; then COLOR="green" + elif [ "$COVERAGE" -ge 70 ]; then COLOR="yellow" + elif [ "$COVERAGE" -ge 50 ]; then COLOR="orange" + else COLOR="red" + fi + echo "color=${COLOR}" >> $GITHUB_OUTPUT + + - name: Update coverage badge + if: github.ref == 'refs/heads/main' + uses: Schneegans/dynamic-badges-action@v1.7.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: ${{ secrets.GIST_ID }} + filename: scampi_coverage.json + label: coverage + message: ${{ steps.coverage.outputs.percentage }}% + color: ${{ steps.coverage.outputs.color }} diff --git a/README.md b/README.md index 88b45ed..19a8e33 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,7 @@ +![Tests](https://github.com/HicResearch/SCAMPI/actions/workflows/tests.yml/badge.svg) +![Coverage](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/JFriel/ef302fe4cee3248c4974297ba157016c/raw/scampi_coverage.json) +![Docker Hub](https://img.shields.io/docker/v/taggenblu/scampi) + # SCAMPI SCAMPI is a DICOM processing engine that extracts DICOM files from a source (local filesystem or PACS server), reads their metadata, and writes the metadata to a SQL Server database alongside copying the files to an output directory.