diff --git a/.github/workflows/unit_tests.yaml b/.github/workflows/unit_tests.yaml index a96e355..eed7bbe 100644 --- a/.github/workflows/unit_tests.yaml +++ b/.github/workflows/unit_tests.yaml @@ -2,11 +2,13 @@ name: Unit Tests on: workflow_dispatch: push: - branches-ignore: - - '**' + branches: [ main, dev, stage ] pull_request: branches: [ main, dev, stage ] +permissions: + contents: write + jobs: UnitTest: runs-on: ubuntu-latest @@ -70,6 +72,36 @@ jobs: - name: Check coverage run: coverage report --fail-under=85 + - name: Generate coverage badge + run: | + pip install coverage-badge + mkdir -p badge-out + coverage-badge -f -o badge-out/coverage.svg + + - name: Publish coverage badge to badges branch + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + set -e + cp badge-out/coverage.svg /tmp/coverage.svg + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git fetch origin badges || true + if git show-ref --verify --quiet refs/remotes/origin/badges; then + git checkout badges + else + git checkout --orphan badges + git rm -rf . >/dev/null 2>&1 || true + fi + cp /tmp/coverage.svg coverage.svg + git add coverage.svg + if ! git diff --cached --quiet; then + git commit -m "chore: update coverage badge" + git push "https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" HEAD:badges + else + echo "No badge changes to commit." + fi + # Optional: keep the log as a build artifact for easy download - name: Upload test log artifact uses: actions/upload-artifact@v4 diff --git a/README.md b/README.md index 4a39ea8..09053b0 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # TDEI-python-osw-validation +[![Unit Tests](https://github.com/TaskarCenterAtUW/TDEI-python-osw-validation/actions/workflows/unit_tests.yaml/badge.svg)](https://github.com/TaskarCenterAtUW/TDEI-python-osw-validation/actions/workflows/unit_tests.yaml) +![Coverage](https://raw.githubusercontent.com/TaskarCenterAtUW/TDEI-python-osw-validation/badges/coverage.svg) +[![python-osw-validation](https://img.shields.io/badge/dynamic/regex?url=https%3A%2F%2Fraw.githubusercontent.com%2FTaskarCenterAtUW%2FTDEI-python-osw-validation%2Fmain%2Frequirements.txt&search=%28%3Fm%29%5Epython-osw-validation%3D%3D%28%5B%5E%5Cr%5Cn%5D%2B%29&replace=%241&label=python-osw-validation&color=blue)](https://pypi.org/project/python-osw-validation/) +[![python-ms-core](https://img.shields.io/badge/dynamic/regex?url=https%3A%2F%2Fraw.githubusercontent.com%2FTaskarCenterAtUW%2FTDEI-python-osw-validation%2Fmain%2Frequirements.txt&search=%28%3Fm%29%5Epython-ms-core%3D%3D%28%5B%5E%5Cr%5Cn%5D%2B%29&replace=%241&label=python-ms-core&color=blue)](https://pypi.org/project/python-ms-core/) + ## Introduction Service to Validate the OSW files that is uploaded. At the moment, the service does the following: - Listens to the topic which is mentioned in `.env` file for any new message (that is triggered when a file is uploaded), example `UPLOAD_TOPIC=osw-upload` diff --git a/requirements.txt b/requirements.txt index d708be6..77d79f1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,4 @@ python-ms-core==0.0.25 uvicorn==0.20.0 html_testRunner==1.2.1 geopandas==0.14.4 -python-osw-validation==0.3.5 +python-osw-validation==0.4.2