Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/workflows/codecoverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Code Coverage

on:
push:
# branches to consider in the event; optional, defaults to all
branches:
- main
workflow_dispatch:

jobs:
codecoverage:
name: "Code Coverage"
env:
ASPNETCORE_ENVIRONMENT: "Production"

runs-on: ubuntu-latest

steps:
- uses: actions/[email protected]

- 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
Comment on lines +12 to +46

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.
14 changes: 0 additions & 14 deletions .github/workflows/nightlybuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,20 +37,6 @@ jobs:

- name: Run Integration Tests
run: dotnet test "CallbackHandler.IntegrationTests\CallbackHandler.IntegrationTests.csproj"

- 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

- uses: dacbd/create-issue-action@main
if: ${{ failure() }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="Moq" Version="4.20.72" />
<PackageReference Include="Shared.EventStore" Version="2026.2.2" />
<PackageReference Include="Shared.EventStore" Version="2026.3.1" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
<TargetFramework>net10.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MediatR" Version="14.0.0" />
<PackageReference Include="SecurityService.Client" Version="2026.2.1" />
<PackageReference Include="Shared" Version="2026.2.2" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2026.2.2" />
<PackageReference Include="Shared.EventStore" Version="2026.2.2" />
<PackageReference Include="TransactionProcessor.Client" Version="2026.2.1" />
<PackageReference Include="MediatR" Version="14.1.0" />
<PackageReference Include="SecurityService.Client" Version="2026.2.3" />
<PackageReference Include="Shared" Version="2026.3.1" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2026.3.1" />
<PackageReference Include="Shared.EventStore" Version="2026.3.1" />
<PackageReference Include="TransactionProcessor.Client" Version="2026.3.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CallbackHandler.CallbackMessageAggregate\CallbackHandler.CallbackMessageAggregate.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<DebugType>None</DebugType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Shared" Version="2026.2.2" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2026.2.2" />
<PackageReference Include="Shared" Version="2026.3.1" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2026.3.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="Shared.EventStore" Version="2026.2.2" />
<PackageReference Include="Shared.EventStore" Version="2026.3.1" />
<PackageReference Include="Shouldly" Version="4.3.0" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.extensibility.core" Version="2.9.3" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.76.0" />
<PackageReference Include="Shared" Version="2026.2.2" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2026.2.2" />
<PackageReference Include="Shared.EventStore" Version="2026.2.2" />
<PackageReference Include="Shared" Version="2026.3.1" />
<PackageReference Include="Shared.DomainDrivenDesign" Version="2026.3.1" />
<PackageReference Include="Shared.EventStore" Version="2026.3.1" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
<PackageReference Include="Reqnroll.Tools.MsBuild.Generation" Version="3.3.3" />
<PackageReference Include="Reqnroll" Version="3.3.3" />
<PackageReference Include="Reqnroll.NUnit" Version="3.3.3" />
<PackageReference Include="NUnit" Version="4.5.0" />
<PackageReference Include="NUnit" Version="4.5.1" />
<PackageReference Include="NUnit3TestAdapter" Version="6.1.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.3.0" />
<PackageReference Include="SecurityService.Client" Version="2026.2.1" />
<PackageReference Include="SecurityService.IntegrationTesting.Helpers" Version="2026.2.1" />
<PackageReference Include="Shared" Version="2026.2.2" />
<PackageReference Include="Shared.IntegrationTesting" Version="2026.2.2" />
<PackageReference Include="TransactionProcessor.Client" Version="2026.2.1" />
<PackageReference Include="TransactionProcessor.IntegrationTesting.Helpers" Version="2026.2.1" />
<PackageReference Include="SecurityService.Client" Version="2026.2.3" />
<PackageReference Include="SecurityService.IntegrationTesting.Helpers" Version="2026.2.3" />
<PackageReference Include="Shared" Version="2026.3.1" />
<PackageReference Include="Shared.IntegrationTesting" Version="2026.3.1" />
<PackageReference Include="TransactionProcessor.Client" Version="2026.3.1" />
<PackageReference Include="TransactionProcessor.IntegrationTesting.Helpers" Version="2026.3.1" />
</ItemGroup>

<ItemGroup>
Expand Down
7 changes: 2 additions & 5 deletions CallbackHandler/Bootstrapper/MediatorRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@ public class MediatorRegistry : ServiceRegistry
{
public MediatorRegistry()
{
this.AddTransient<IMediator, Mediator>();

// request & notification handlers
this.AddSingleton<IRequestHandler<CallbackCommands.RecordCallbackCommand, Result>, CallbackHandlerRequestHandler>();
this.AddSingleton<IRequestHandler<CallbackQueries.GetCallbackQuery, Result<CallbackHandlers.Models.CallbackMessage>>, CallbackHandlerRequestHandler>();

this.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(CallbackHandlerRequestHandler).Assembly));
this.AddSingleton<ICallbackDomainService, CallbackDomainService>();
}
}
6 changes: 3 additions & 3 deletions CallbackHandler/CallbackHandler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
<PackageReference Include="Lamar.Microsoft.DependencyInjection" Version="15.0.1" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="10.0.3" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="9.0.0" />
<PackageReference Include="MediatR" Version="14.0.0" />
<PackageReference Include="MediatR" Version="14.1.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.23.0" />
<PackageReference Include="Shared" Version="2026.2.2" />
<PackageReference Include="Shared.Results.Web" Version="2026.2.2" />
<PackageReference Include="Shared" Version="2026.3.1" />
<PackageReference Include="Shared.Results.Web" Version="2026.3.1" />
<PackageReference Include="SimpleResults.AspNetCore" Version="4.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.4" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="10.1.4" />
Expand Down
3 changes: 1 addition & 2 deletions CallbackHandler/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerF

ConfigurationReader.Initialise(Startup.Configuration);
app.UseMiddleware<TenantMiddleware>();
app.AddRequestLogging();
app.AddResponseLogging();
app.AddRequestResponseLogging();
app.AddExceptionHandler();

app.UseRouting();
Expand Down
Loading