From 7d855c821dfdacbd205bc474f88c4ea881f8f8f8 Mon Sep 17 00:00:00 2001 From: "pi.admin" Date: Sun, 24 May 2026 12:29:45 -0700 Subject: [PATCH 1/2] Dynamic coverage --- .github/actions/push-package/action.yml | 30 +++++++++++++++-- .github/workflows/build-test-cross.yml | 38 +++++++++++----------- .github/workflows/build-test-push.yml | 43 ++++++++++++++++++++----- .github/workflows/delete-packages.yml | 6 ++-- README.md | 4 +-- 5 files changed, 86 insertions(+), 35 deletions(-) diff --git a/.github/actions/push-package/action.yml b/.github/actions/push-package/action.yml index 6953d70..cb0ab02 100644 --- a/.github/actions/push-package/action.yml +++ b/.github/actions/push-package/action.yml @@ -25,6 +25,13 @@ inputs: description: 'The package registry (github or nuget)' default: github required: true +outputs: + coverage-line: + description: 'Line coverage percentage' + value: ${{ steps.extract-coverage.outputs.line }} + coverage-branch: + description: 'Branch coverage percentage' + value: ${{ steps.extract-coverage.outputs.branch }} runs: using: "composite" steps: @@ -33,11 +40,28 @@ runs: - name: Build run: dotnet build ./src/${{ inputs.project }}/${{ inputs.project }}.csproj -c ${{ inputs.config }} --verbosity minimal shell: bash - + # Test - name: Test if: ${{ inputs.skiptest == 'false' }} - run: dotnet test ./test/${{ inputs.project }}.Tests/${{ inputs.project }}.Tests.csproj -c ${{ inputs.config }} --verbosity minimal + run: dotnet test ./test/${{ inputs.project }}.Tests/${{ inputs.project }}.Tests.csproj -c ${{ inputs.config }} --verbosity minimal --collect:"XPlat Code Coverage" --results-directory ./coverage + shell: bash + + # Generate coverage report + - name: Coverage Report + if: ${{ inputs.skiptest == 'false' }} + run: reportgenerator -reports:./coverage/**/coverage.cobertura.xml -targetdir:./coverage/report -reporttypes:JsonSummary + shell: bash + + # Extract line and branch coverage percentages + - name: Extract Coverage + id: extract-coverage + if: ${{ inputs.skiptest == 'false' }} + run: | + LINE=$(cat ./coverage/report/Summary.json | python3 -c "import sys,json; d=json.load(sys.stdin); print(round(d['summary']['linecoverage']))") + BRANCH=$(cat ./coverage/report/Summary.json | python3 -c "import sys,json; d=json.load(sys.stdin); print(round(d['summary']['branchcoverage']))") + echo "line=$LINE" >> $GITHUB_OUTPUT + echo "branch=$BRANCH" >> $GITHUB_OUTPUT shell: bash # Pack @@ -59,7 +83,7 @@ runs: if: ${{ inputs.registry == 'nuget' }} run: dotnet nuget push _packages/${{ inputs.project }}.${{ inputs.version }}.nupkg --skip-duplicate --no-symbols --api-key ${{ inputs.ghapikey }} --source github shell: bash - + # Second push to Nuget (for package cadence, Github will be used and in production Nuget after package verification) - name: Nuget Push if: ${{ inputs.registry == 'nuget' }} diff --git a/.github/workflows/build-test-cross.yml b/.github/workflows/build-test-cross.yml index 58e7e5b..5953972 100644 --- a/.github/workflows/build-test-cross.yml +++ b/.github/workflows/build-test-cross.yml @@ -26,30 +26,30 @@ jobs: # Checkout - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 - # Read env + # Read env - name: Read Env run: cat .github/package_version.env >> $GITHUB_ENV continue-on-error: false # Setup .Net with global.json - name: Setup .NET - uses: actions/setup-dotnet@v3 - + uses: actions/setup-dotnet@v5 + # Restore dependencies - name: Restore run: dotnet restore - + # Build - name: Build run: dotnet build --no-restore - + # Test - name: Test run: dotnet test --no-build --verbosity normal - - macos: + + macos: runs-on: macos-latest timeout-minutes: 15 @@ -64,44 +64,44 @@ jobs: # Checkout - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 # Setup .Net with global.json - name: Setup .NET - uses: actions/setup-dotnet@v3 - + uses: actions/setup-dotnet@v5 + # Restore dependencies - name: Restore run: dotnet restore - + # Build - name: Build run: dotnet build --no-restore - + # Test - name: Test run: dotnet test --no-build --verbosity normal - - windows: + + windows: runs-on: windows-latest timeout-minutes: 15 - + # Environment Variables env: # GitHub package authentication PI_GITHUB_USERNAME_ENV: ${{ secrets.PI_GITHUB_USERNAME }} PI_GITHUB_PAT_ENV: ${{ secrets.PI_GITHUB_PAT }} PI_CI_REFERENCE: cross - + steps: # Checkout - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 # Setup .Net with global.json - name: Setup .NET - uses: actions/setup-dotnet@v3 + uses: actions/setup-dotnet@v5 # Restore dependencies - name: Restore diff --git a/.github/workflows/build-test-push.yml b/.github/workflows/build-test-push.yml index f36b370..7b61119 100644 --- a/.github/workflows/build-test-push.yml +++ b/.github/workflows/build-test-push.yml @@ -51,7 +51,7 @@ jobs: # Checkout - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v6 # Read env - name: Read Env @@ -109,13 +109,12 @@ jobs: # Setup .Net with global.json - name: Setup .NET - uses: actions/setup-dotnet@v3 - - # Setup Nuget - - name: Setup NuGet.exe - uses: NuGet/setup-nuget@v1 - with: - nuget-version: latest + uses: actions/setup-dotnet@v5 + + # Setup ReportGenerator + - name: Setup ReportGenerator + run: dotnet tool install --global dotnet-reportgenerator-globaltool + continue-on-error: false # Setup local # OneImlx.Shared is the first package so we use the local project reference to avoid cyclic Nuget dependency resolution. @@ -126,6 +125,7 @@ jobs: # Publish OneImlx.Shared - name: OneImlx.Shared + id: oneimlx-shared uses: ./.github/actions/push-package with: project: OneImlx.Shared @@ -142,6 +142,7 @@ jobs: # Publish OneImlx.Test - name: OneImlx.Test + id: oneimlx-test uses: ./.github/actions/push-package with: project: OneImlx.Test @@ -151,3 +152,29 @@ jobs: ghapikey: ${{ env.PI_GITHUB_PAT_ENV }} nugetapikey: ${{ env.PI_NUGET_PAT_ENV }} registry: ${{ env.PI_PUBLISH_REGISTRY }} + + # Update line coverage badge in Gist + - name: Line Coverage Badge + uses: Schneegans/dynamic-badges-action@v1.8.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: ${{ secrets.GIST_ID }} + filename: coverage-shared-line.json + label: coverage-line + message: ${{ steps.oneimlx-shared.outputs.coverage-line }}% + valColorRange: ${{ steps.oneimlx-shared.outputs.coverage-line }} + maxColorRange: 100 + minColorRange: 0 + + # Update branch coverage badge in Gist + - name: Branch Coverage Badge + uses: Schneegans/dynamic-badges-action@v1.8.0 + with: + auth: ${{ secrets.GIST_SECRET }} + gistID: ${{ secrets.GIST_ID }} + filename: coverage-shared-branch.json + label: coverage-branch + message: ${{ steps.oneimlx-shared.outputs.coverage-branch }}% + valColorRange: ${{ steps.oneimlx-shared.outputs.coverage-branch }} + maxColorRange: 100 + minColorRange: 0 diff --git a/.github/workflows/delete-packages.yml b/.github/workflows/delete-packages.yml index fe7d7b1..0d46941 100644 --- a/.github/workflows/delete-packages.yml +++ b/.github/workflows/delete-packages.yml @@ -65,7 +65,7 @@ jobs: # Delete specific - name: Delete ${{ env.PI_DELETE_PACKAGES }} if: ${{ env.PI_DELETE_PACKAGES != 'All' }} - uses: actions/delete-package-versions@v4 + uses: actions/delete-package-versions@v5 with: package-name: ${{ env.PI_DELETE_PACKAGES }} package-type: nuget @@ -74,7 +74,7 @@ jobs: # Delete OneImlx.Shared - name: Delete OneImlx.Shared if: ${{ env.PI_DELETE_PACKAGES == 'All' }} - uses: actions/delete-package-versions@v4 + uses: actions/delete-package-versions@v5 with: package-name: OneImlx.Shared package-type: nuget @@ -83,7 +83,7 @@ jobs: # Delete OneImlx.Test - name: Delete OneImlx.Test if: ${{ env.PI_DELETE_PACKAGES == 'All' }} - uses: actions/delete-package-versions@v4 + uses: actions/delete-package-versions@v5 with: package-name: OneImlx.Test package-type: nuget diff --git a/README.md b/README.md index 564d48e..8cca64a 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ This repository contains the shared components for our cross-platform frameworks [![Cross-Platform Build and Test](https://github.com/perpetualintelligence/shared/actions/workflows/build-test-cross.yml/badge.svg)](https://github.com/perpetualintelligence/shared/actions/workflows/build-test-cross-manual.yml) [![Push Build and Test](https://github.com/perpetualintelligence/shared/actions/workflows/build-test-push.yml/badge.svg)](https://github.com/perpetualintelligence/shared/actions/workflows/build-test-push.yml) -![coverage-line: 66%](https://img.shields.io/badge/coverage--line-66%25-yellow) -![coverage-branch: 60%](https://img.shields.io/badge/coverage--branch-76%25-orange) +![coverage-line](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/perpetualintelligence/GIST_ID/raw/coverage-shared-line.json) +![coverage-branch](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/perpetualintelligence/GIST_ID/raw/coverage-shared-branch.json) ## Feedback We welcome feedback and suggestions. Issues and tasks are tracked in the [GitHub Issues](https://github.com/perpetualintelligence/shared/issues). Details about our issue classification and resolution procedures are available in our [Issues Policy](https://terms.perpetualintelligence.com/articles/issues_policy.html). From 47e37f0d1a25b5ed11c7f7f931e6b7d11a91bf79 Mon Sep 17 00:00:00 2001 From: "pi.admin" Date: Sun, 24 May 2026 12:53:12 -0700 Subject: [PATCH 2/2] Fix GIST --- .github/workflows/build-test-push.yml | 12 ++++++------ README.md | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-test-push.yml b/.github/workflows/build-test-push.yml index 7b61119..f3cc366 100644 --- a/.github/workflows/build-test-push.yml +++ b/.github/workflows/build-test-push.yml @@ -157,9 +157,9 @@ jobs: - name: Line Coverage Badge uses: Schneegans/dynamic-badges-action@v1.8.0 with: - auth: ${{ secrets.GIST_SECRET }} - gistID: ${{ secrets.GIST_ID }} - filename: coverage-shared-line.json + auth: ${{ secrets.PI_GITHUB_GIST_PAT }} + gistID: ${{ secrets.PI_GITHUB_GIST_ID }} + filename: coverage_${{ github.event.repository.name }}_line.json label: coverage-line message: ${{ steps.oneimlx-shared.outputs.coverage-line }}% valColorRange: ${{ steps.oneimlx-shared.outputs.coverage-line }} @@ -170,9 +170,9 @@ jobs: - name: Branch Coverage Badge uses: Schneegans/dynamic-badges-action@v1.8.0 with: - auth: ${{ secrets.GIST_SECRET }} - gistID: ${{ secrets.GIST_ID }} - filename: coverage-shared-branch.json + auth: ${{ secrets.PI_GITHUB_GIST_PAT }} + gistID: ${{ secrets.PI_GITHUB_GIST_ID }} + filename: coverage_${{ github.event.repository.name }}_branch.json label: coverage-branch message: ${{ steps.oneimlx-shared.outputs.coverage-branch }}% valColorRange: ${{ steps.oneimlx-shared.outputs.coverage-branch }} diff --git a/README.md b/README.md index 8cca64a..9c22ab4 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,8 @@ This repository contains the shared components for our cross-platform frameworks [![Cross-Platform Build and Test](https://github.com/perpetualintelligence/shared/actions/workflows/build-test-cross.yml/badge.svg)](https://github.com/perpetualintelligence/shared/actions/workflows/build-test-cross-manual.yml) [![Push Build and Test](https://github.com/perpetualintelligence/shared/actions/workflows/build-test-push.yml/badge.svg)](https://github.com/perpetualintelligence/shared/actions/workflows/build-test-push.yml) -![coverage-line](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/perpetualintelligence/GIST_ID/raw/coverage-shared-line.json) -![coverage-branch](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/perpetualintelligence/GIST_ID/raw/coverage-shared-branch.json) +![coverage-line](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/perpetualintelligencegit/141903832ee52f1e9e7913300a92d507/raw/coverage_shared_line.json) +![coverage-branch](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/perpetualintelligencegit/141903832ee52f1e9e7913300a92d507/raw/coverage_shared_branch.json) ## Feedback We welcome feedback and suggestions. Issues and tasks are tracked in the [GitHub Issues](https://github.com/perpetualintelligence/shared/issues). Details about our issue classification and resolution procedures are available in our [Issues Policy](https://terms.perpetualintelligence.com/articles/issues_policy.html).