Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 9f3a883

Browse files
Merge branch 'main' into feat/DTOSS-8925-transform-skeleton
2 parents 770fce3 + 1fecdbd commit 9f3a883

16 files changed

Lines changed: 538 additions & 59 deletions

File tree

.env.example

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ MeshPassword=password
1212
NbssMailboxId=X26ABC1
1313
MeshApiBaseUrl=http://localhost:8700/messageexchange
1414
ASPNETCORE_ENVIRONMENT=Development
15-
FileDiscoveryTimerExpression=*/5 * * * *
15+
FileDiscoveryTimerExpression=0 */5 * * * *
16+
MeshHandshakeTimerExpression=0 0 0 * * * # Midnight
17+
FileRetryTimerExpression=0 0 * * * *
1618
QueueUrl=http://127.0.0.1:10001
1719
FileExtractQueueName=file-extract
1820
FileTransformQueueName=file-transform
21+
StaleHours=12
1922

2023
# API Configuration
2124
API_PORT=7071

.github/actions/perform-static-analysis/action.yaml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,12 @@ runs:
4444
run: |
4545
mkdir -p .sonar/scanner
4646
dotnet tool install dotnet-sonarscanner --tool-path ./.sonar/scanner
47-
dotnet tool install dotnet-coverage --tool-path ./.sonar/scanner
47+
dotnet tool install dotnet-reportgenerator-globaltool --tool-path ./.sonar/scanner
48+
4849
- name: Build and analyze
4950
shell: bash
5051
run: |
51-
echo "${{ inputs.sonar_project_key }}"
52-
echo "${{ inputs.sonar_organisation_key }}"
53-
echo "${{ inputs.sonar_token }}"
54-
./.sonar/scanner/dotnet-sonarscanner begin /k:"${{ inputs.sonar_project_key }}" /o:"${{ inputs.sonar_organisation_key }}" /d:sonar.token="${{ inputs.sonar_token }}" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.cs.vscoveragexml.reportsPaths="coverage.xml" /d:sonar.typescript.lcov.reportsPaths="src/web/coverage/lcov.info" /d:sonar.lang.patterns.ts=**/*.ts,**/*.tsx,**/*.cts,**/*.mts /d:sonar.lang.patterns.js=**/*.js,**/*.jsx,**/*.cjs,**/*.mjs,**/*.vue /d:sonar.javascript.enabled=false
55-
dotnet build src/ServiceLayer.sln
56-
./.sonar/scanner/dotnet-coverage collect -f xml -o coverage.xml dotnet test src/ServiceLayer.sln
57-
./.sonar/scanner/dotnet-sonarscanner end /d:sonar.token="${{ inputs.sonar_token }}"
52+
export SONAR_PROJECT_KEY="${{ inputs.sonar_project_key }}"
53+
export SONAR_ORGANISATION_KEY="${{ inputs.sonar_organisation_key }}"
54+
export SONAR_TOKEN="${{ inputs.sonar_token }}"
55+
make test-coverage

.github/workflows/stage-2-test.yaml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,6 @@ jobs:
6565
- name: "Save the linting result"
6666
run: |
6767
echo "Nothing to save"
68-
test-coverage:
69-
name: "Test coverage"
70-
needs: [test-unit]
71-
runs-on: ubuntu-latest
72-
timeout-minutes: 5
73-
steps:
74-
- name: "Checkout code"
75-
uses: actions/checkout@v4
76-
- name: "Run test coverage check"
77-
run: |
78-
make test-coverage
79-
- name: "Save the coverage check result"
80-
run: |
81-
echo "Nothing to save"
8268
perform-static-analysis:
8369
name: "Perform static analysis"
8470
needs: [test-unit]

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,3 +288,7 @@ __queuestorage__
288288

289289
# Gitleaks report
290290
gitleaks-report.json
291+
292+
coverage/
293+
.sonar/
294+
.sonarqube/

scripts/tests/coverage.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
: "${SONAR_TOKEN:?SONAR_TOKEN is required}"
5+
: "${SONAR_PROJECT_KEY:?SONAR_PROJECT_KEY is required}"
6+
: "${SONAR_ORGANISATION_KEY:?SONAR_ORGANISATION_KEY is required}"
7+
8+
SONAR_SCANNER="./.sonar/scanner/dotnet-sonarscanner"
9+
REPORT_GENERATOR="./.sonar/scanner/reportgenerator"
10+
11+
12+
13+
$SONAR_SCANNER begin /k:"$SONAR_PROJECT_KEY" /o:"$SONAR_ORGANISATION_KEY" /d:sonar.token="$SONAR_TOKEN" /d:sonar.host.url="https://sonarcloud.io" /d:sonar.coverageReportPaths="coverage/converted/SonarQube.xml"
14+
15+
dotnet build src/ServiceLayer.sln
16+
17+
make test-unit ARGS="--no-build"
18+
19+
$REPORT_GENERATOR \
20+
-reports:coverage/**/coverage.cobertura.xml \
21+
-targetdir:coverage/converted \
22+
-reporttypes:SonarQube
23+
24+
$SONAR_SCANNER end /d:sonar.token="$SONAR_TOKEN"

scripts/tests/test.mk

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ test: # Run all the test tasks @Testing
6565
test-load
6666

6767
_test:
68-
set -e
69-
script="./scripts/tests/${name}.sh"
70-
if [ -e "$${script}" ]; then
71-
exec $${script}
72-
else
73-
echo "make test-${name} not implemented: $${script} not found" >&2
68+
@set -e; \
69+
script="./scripts/tests/$(name).sh"; \
70+
if [ -e "$$script" ]; then \
71+
exec "$$script"; \
72+
else \
73+
echo "make test-$(name) not implemented: $$script not found" >&2; \
7474
fi
7575

7676
${VERBOSE}.SILENT: \

scripts/tests/unit.sh

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
#!/bin/bash
2-
32
set -euo pipefail
43

5-
cd "$(git rev-parse --show-toplevel)"
6-
7-
dir="$PWD"
8-
UnitDir="$dir/tests/"
9-
ResDir="$UnitDir"results-unit
10-
Format="trx"
11-
12-
# Find all *.csproj files excluding the IntegrationTests folder and execute dotnet test, with build for now
13-
find "$UnitDir" -name '*.csproj' -not -path "$UnitDir/IntegrationTests/*" | while read -r file; do
14-
echo -e "\nRunning unit tests for:\n$file"
15-
dotnet test "$file" --filter "TestCategory!=Integration" --logger $Format --verbosity quiet
16-
done
17-
18-
19-
# Move all trx result files into a separate folder, for easier reporting
20-
mkdir -p "$ResDir"
21-
find "$UnitDir" -name "*.$Format" -not -path "$ResDir/*" | while read -r resfile; do
22-
mv "$resfile" "$ResDir"
4+
BUILD_ARGS=""
5+
if [[ "${1:-}" == "--no-build" ]]; then
6+
BUILD_ARGS="--no-build"
7+
fi
8+
9+
COVERAGE_DIR="coverage"
10+
TEST_PROJECTS=$(find tests -name '*.csproj')
11+
12+
rm -rf "$COVERAGE_DIR"
13+
mkdir -p "$COVERAGE_DIR"
14+
15+
for proj in $TEST_PROJECTS; do
16+
proj_name=$(basename "$proj" .csproj)
17+
out_file="$COVERAGE_DIR/$proj_name.coverage.xml"
18+
echo "🧪 Running coverage for $proj -> $out_file"
19+
dotnet test "$proj" \
20+
$BUILD_ARGS \
21+
--collect:"XPlat Code Coverage" \
22+
--results-directory coverage
2323
done
24-
25-
# List created results
26-
echo -e "\nCreated result files:\n"
27-
find "$ResDir" -name "*.$Format"
28-
29-
# echo "Test execution completed. See scripts/tests/unit.sh for more."

src/ServiceLayer.Mesh/Configuration/AppConfiguration.cs

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,17 @@ public class AppConfiguration :
55
IFileExtractFunctionConfiguration,
66
IFileExtractQueueClientConfiguration,
77
IFileTransformQueueClientConfiguration,
8-
IFileTransformFunctionConfiguration
8+
IFileTransformFunctionConfiguration,
9+
IFileRetryFunctionConfiguration,
10+
IMeshHandshakeFunctionConfiguration
911
{
1012
public string NbssMeshMailboxId => GetRequired("NbssMailboxId");
1113

1214
public string FileExtractQueueName => GetRequired("FileExtractQueueName");
1315

1416
public string FileTransformQueueName => GetRequired("FileTransformQueueName");
1517

16-
public int StaleHours => throw new NotImplementedException();
18+
public int StaleHours => GetRequiredInt("StaleHours");
1719

1820
private static string GetRequired(string key)
1921
{
@@ -26,4 +28,16 @@ private static string GetRequired(string key)
2628

2729
return value;
2830
}
31+
32+
private static int GetRequiredInt(string key)
33+
{
34+
var value = GetRequired(key);
35+
36+
if (!int.TryParse(value, out var intValue))
37+
{
38+
throw new InvalidOperationException($"Environment variable '{key}' is not a valid integer");
39+
}
40+
41+
return intValue;
42+
}
2943
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace ServiceLayer.Mesh.Configuration;
2+
3+
public interface IFileRetryFunctionConfiguration
4+
{
5+
int StaleHours { get; }
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
namespace ServiceLayer.Mesh.Configuration
2+
{
3+
public interface IMeshHandshakeFunctionConfiguration
4+
{
5+
string NbssMeshMailboxId { get; }
6+
}
7+
}

0 commit comments

Comments
 (0)