Skip to content

Commit 569e8af

Browse files
authored
Merge pull request #41 from DEFRA/feature/sonarqube
Sonar qube support
2 parents 1649722 + 4a33372 commit 569e8af

File tree

6 files changed

+89
-100
lines changed

6 files changed

+89
-100
lines changed

.github/dependabot.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
version: 2
2+
3+
updates:
4+
- package-ecosystem: nuget
5+
directory: /
6+
schedule:
7+
interval: weekly
8+
day: monday
9+
time: "09:00"
10+
timezone: Europe/London
11+
open-pull-requests-limit: 10
12+
13+
# Only update direct dependencies (not transitive)
14+
allow:
15+
- dependency-type: direct
16+
17+
# Group related packages to reduce PR noise
18+
groups:
19+
# AWS SDK packages - update together for compatibility
20+
aws-sdk:
21+
patterns:
22+
- "AWSSDK*"
23+
- "Amazon.*"
24+
25+
# Microsoft packages (excluding ASP.NET Core which should match runtime)
26+
microsoft:
27+
patterns:
28+
- "Microsoft.Extensions.*"
29+
exclude-patterns:
30+
- "Microsoft.AspNetCore.*"
31+
- "Microsoft.NET.Test.Sdk"
32+
33+
# OpenTelemetry packages - update together
34+
opentelemetry:
35+
patterns:
36+
- "OpenTelemetry*"
37+
38+
# Serilog logging packages
39+
serilog:
40+
patterns:
41+
- "Serilog*"
42+
- "Elastic.CommonSchema.Serilog"
43+
44+
# Test framework packages
45+
testing:
46+
patterns:
47+
- "xunit*"
48+
- "Moq"
49+
- "FluentAssertions"
50+
- "Bogus"
51+
- "coverlet.*"
52+
- "Microsoft.NET.Test.Sdk"
53+
- "MartinCostello.Logging.XUnit"
54+
- "GitHubActionsTestLogger"
55+
56+
# Testcontainers packages
57+
testcontainers:
58+
patterns:
59+
- "Testcontainers*"
60+
61+
# Ignore packages that should stay pinned to runtime version
62+
ignore:
63+
# ASP.NET Core packages should match the .NET 8 runtime
64+
- dependency-name: "Microsoft.AspNetCore.*"
65+
update-types:
66+
- "version-update:semver-major"
67+
68+
commit-message:
69+
prefix: "deps"
70+
include: "scope"
71+
72+
labels:
73+
- "dependencies"
74+
- "nuget"

.github/example.dependabot.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/check-pull-request.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,9 @@ jobs:
8888
- name: Run integration tests
8989
run: dotnet test ./working-dir/KeeperData.Bridge.sln --filter "Dependence=docker&testtype!=performance"
9090

91-
## SonarCloud
92-
## Uncomment to unable SonarCloud scan
93-
## Requires project to be set up in SonarCloud
94-
## and the SonarCloud token to be set in the repository secrets
95-
# sonarcloud-scan:
96-
# name: CDP SonarCloud Scan
97-
# uses: ./.github/workflows/sonarcloud.yml
98-
# needs: pr-validator
99-
# secrets: inherit
91+
sonarcloud-scan:
92+
name: CDP SonarCloud Scan
93+
uses: ./.github/workflows/sonarcloud.yml
94+
needs: pr-validator
95+
secrets:
96+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}

.github/workflows/sonarcloud.yml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ name: Run SonarCloud coverage scan
22

33
on:
44
workflow_call:
5+
secrets:
6+
SONAR_TOKEN:
7+
description: "SonarCloud token used for authentication"
8+
required: true
59

610
permissions:
711
id-token: write
@@ -64,7 +68,7 @@ jobs:
6468
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
6569
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
6670
run: |
67-
./.sonar/scanner/dotnet-sonarscanner begin /k:"DEFRA_cdp-dotnet-backend-template" /o:"defra" /d:sonar.token="${{ secrets.SONAR_TOKEN }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
68-
dotnet build --no-incremental
69-
./.sonar/coverage/dotnet-coverage collect "dotnet test" -f xml -o "coverage.xml"
70-
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ secrets.SONAR_TOKEN }}"
71+
./.sonar/scanner/dotnet-sonarscanner begin /k:"DEFRA_ls-keeper-data-bridge-backend" /o:"defra" /d:sonar.token="$SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths=coverage.xml
72+
dotnet build KeeperData.Bridge.sln --no-incremental
73+
./.sonar/coverage/dotnet-coverage collect "dotnet test KeeperData.Bridge.sln --filter \"Dependence!=docker&testtype!=performance\"" -f xml -o "coverage.xml"
74+
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="$SONAR_TOKEN"

tests/KeeperData.Core.Tests.Unit/ETL/Utils/IngestionProgressTrackerTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ public void GetCurrentStatus_AfterUpdateProgress_ShouldReturnNonZeroProgress()
7777
// Assert
7878
status.RowNumber.Should().Be(500);
7979
status.PercentageCompleted.Should().BeGreaterThan(0);
80-
status.RowsPerMinute.Should().NotBeNull();
8180
}
8281

8382
[Fact]

tests/KeeperData.Infrastructure.Tests.Unit/Crypto/AesCryptoTransformTests.cs

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -373,65 +373,7 @@ await _cryptoTransform.EncryptStreamAsync(
373373
progressReports.Should().Contain(r => r.percentage == 0 && r.status.Contains("processed") && !r.status.Contains("%"));
374374
}
375375

376-
[Fact(Skip = "This is too fuzzy for remote ci-cd pipelines")]
377-
public async Task LargeFileStreaming_Over500MB_ShouldProcessWithMinimalMemoryUsage()
378-
{
379-
// Arrange
380-
const long fileSizeBytes = 500L * 1024 * 1024 + 1024; // 500MB + 1KB
381-
var inputFile = CreateLargeTempFile(fileSizeBytes);
382-
var encryptedFile = GetTempFilePath();
383-
var decryptedFile = GetTempFilePath();
384-
385-
var encryptProgressReports = new List<(int percentage, string status)>();
386-
var decryptProgressReports = new List<(int percentage, string status)>();
387-
388-
// Monitor memory usage
389-
var initialMemory = GC.GetTotalMemory(true);
390-
391-
// Act - Encrypt
392-
await _cryptoTransform.EncryptFileAsync(
393-
inputFile,
394-
encryptedFile,
395-
TestPassword,
396-
TestSaltBytes,
397-
(percentage, status) => encryptProgressReports.Add((percentage, status)));
398-
399-
var memoryAfterEncrypt = GC.GetTotalMemory(false);
400-
401-
// Act - Decrypt
402-
await _cryptoTransform.DecryptFileAsync(
403-
encryptedFile,
404-
decryptedFile,
405-
TestPassword,
406-
TestSaltBytes,
407-
(percentage, status) => decryptProgressReports.Add((percentage, status)));
408-
409-
var memoryAfterDecrypt = GC.GetTotalMemory(false);
410-
411-
// Assert file sizes
412-
var originalFileInfo = new FileInfo(inputFile);
413-
var decryptedFileInfo = new FileInfo(decryptedFile);
414-
415-
originalFileInfo.Length.Should().Be(fileSizeBytes);
416-
decryptedFileInfo.Length.Should().Be(fileSizeBytes);
417-
418-
// Assert memory usage - should not buffer entire file in memory
419-
// Memory increase should be much less than file size (allowing some overhead for test framework)
420-
var maxMemoryIncrease = Math.Max(memoryAfterEncrypt - initialMemory, memoryAfterDecrypt - initialMemory);
421-
maxMemoryIncrease.Should().BeLessThan(10 * 1024 * 1024); // Less than 10MB increase
422-
423-
// Assert progress reporting
424-
encryptProgressReports.Should().NotBeEmpty();
425-
encryptProgressReports.Should().Contain(r => r.percentage == 100);
426-
encryptProgressReports.Where(r => r.status.Contains("%")).Should().NotBeEmpty();
427-
428-
decryptProgressReports.Should().NotBeEmpty();
429-
decryptProgressReports.Should().Contain(r => r.percentage == 100);
430-
decryptProgressReports.Where(r => r.status.Contains("%")).Should().NotBeEmpty();
431-
432-
// Verify data integrity by comparing checksums of first and last chunks
433-
await VerifyFileIntegrity(inputFile, decryptedFile);
434-
}
376+
435377

436378
[Fact]
437379
public async Task StreamDecryption_LargeFile_ShouldMaintainConstantMemoryUsage()

0 commit comments

Comments
 (0)