Skip to content

Update dependencies and add code coverage workflow#233

Merged
StuartFerguson merged 3 commits intomainfrom
task/#232_update_shared_nugets
Mar 9, 2026
Merged

Update dependencies and add code coverage workflow#233
StuartFerguson merged 3 commits intomainfrom
task/#232_update_shared_nugets

Conversation

@StuartFerguson
Copy link
Copy Markdown
Member

Updated NuGet package versions across all projects, including Shared, DomainDrivenDesign, EventStore, MediatR, SecurityService.Client, TransactionProcessor.Client, and NUnit. Added a GitHub Actions workflow (codecoverage.yml) to build, run tests with coverage, merge LCOV reports, and upload results to Codacy. No application logic changes were made.

closes #232
closes #231

Updated NuGet package versions across all projects, including Shared, DomainDrivenDesign, EventStore, MediatR, SecurityService.Client, TransactionProcessor.Client, and NUnit.
Added a GitHub Actions workflow (codecoverage.yml) to build, run tests with coverage, merge LCOV reports, and upload results to Codacy.
No application logic changes were made.
Comment on lines +12 to +46
name: "Code Coverage"
env:
ASPNETCORE_ENVIRONMENT: "Production"

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2.3.4

- name: Restore Nuget Packages
run: dotnet restore CallbackHandler.sln --source ${{ secrets.PUBLICFEEDURL }} --source ${{ secrets.PRIVATEFEED_URL }}

- name: Build Code
run: dotnet build CallbackHandler.sln --configuration Release

- name: Run Unit Tests
run: |
echo "ASPNETCORE_ENVIRONMENT are > ${ASPNETCORE_ENVIRONMENT}"
dotnet test "CallbackHandler.BusinessLogic.Tests\CallbackHandler.BusinessLogic.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov1.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov"
dotnet test "CallbackHandler.CallbackMessageAggregate.Tests\CallbackHandler.CallbackMessageAggregate.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov2.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov"
dotnet test "CallbackHandler.Tests\CallbackHandler.Tests.csproj" /p:CollectCoverage=true /p:Exclude="[xunit*]*" /p:ExcludeByAttribute="Obsolete" /p:ExcludeByAttribute="GeneratedCodeAttribute" /p:ExcludeByAttribute="CompilerGeneratedAttribute" /p:ExcludeByAttribute="ExcludeFromCodeCoverageAttribute" /p:CoverletOutput="../lcov3.info" /maxcpucount:1 /p:CoverletOutputFormat="lcov"

- name: Install LCOV merger
run: npm install -g lcov-result-merger

- name: Merge LCOV reports
run: |
mkdir -p coverage
lcov-result-merger "*.info" > lcov.info

- name: Upload merged coverage to Codacy
uses: codacy/codacy-coverage-reporter-action@v1
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ./lcov.info

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {contents: read}

Copilot Autofix

AI 2 months ago

To fix the issue, explicitly restrict GITHUB_TOKEN permissions for this workflow to the minimum needed. The job only checks out code, restores/builds/tests, and uploads coverage to Codacy; it does not need to write to the repository or interact with issues/PRs. Therefore, setting contents: read (and nothing else) at the workflow level is sufficient and preserves existing behavior.

The best minimal fix is to add a permissions: block at the top (root) of .github/workflows/codecoverage.yml, directly under the name: line and before the on: section:

  • This applies to all jobs in the workflow (currently just codecoverage).
  • It limits the GITHUB_TOKEN to read-only repository contents, which is enough for actions/checkout and does not impact the usage of secrets or external services like Codacy.

Concretely:

  • Edit .github/workflows/codecoverage.yml.

  • Insert:

    permissions:
      contents: read

    after line 1 (name: Code Coverage) and before the on: block (line 3 onwards).

  • No imports or additional methods are required; this is purely a YAML configuration change.

Suggested changeset 1
.github/workflows/codecoverage.yml

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/.github/workflows/codecoverage.yml b/.github/workflows/codecoverage.yml
--- a/.github/workflows/codecoverage.yml
+++ b/.github/workflows/codecoverage.yml
@@ -1,4 +1,6 @@
 name: Code Coverage
+permissions:
+  contents: read
 
 on:
   push:
EOF
@@ -1,4 +1,6 @@
name: Code Coverage
permissions:
contents: read

on:
push:
Copilot is powered by AI and may make mistakes. Always verify output.
Replaced manual registration of IMediator and specific IRequestHandlers with AddMediatR, auto-registering all handlers from the relevant assembly. This streamlines service setup and reduces maintenance overhead.
@StuartFerguson StuartFerguson merged commit 6111448 into main Mar 9, 2026
9 checks passed
@github-actions github-actions Bot deleted the task/#232_update_shared_nugets branch May 9, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update Shared Nugets Move Code Coverage to its own workflow

2 participants