Skip to content

Commit

Permalink
Copied and renamed from cdms
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian Shimmings committed Dec 3, 2024
2 parents ecdf067 + f6c3182 commit 245435a
Show file tree
Hide file tree
Showing 757 changed files with 47,038 additions and 1,032 deletions.
12 changes: 12 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": 1,
"isRoot": true,
"tools": {
"husky": {
"version": "0.7.1",
"commands": [
"husky"
]
}
}
}
17 changes: 8 additions & 9 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,25 @@ csharp_new_line_before_members_in_anonymous_types = true

# name all constant fields using PascalCase
dotnet_naming_rule.constant_fields_should_be_pascal_case.severity = suggestion
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_rule.constant_fields_should_be_pascal_case.symbols = constant_fields
dotnet_naming_rule.constant_fields_should_be_pascal_case.style = pascal_case_style
dotnet_naming_symbols.constant_fields.applicable_kinds = field
dotnet_naming_symbols.constant_fields.required_modifiers = const
dotnet_naming_style.pascal_case_style.capitalization = pascal_case

# static fields should have s_ prefix
dotnet_naming_rule.static_fields_should_have_prefix.severity = suggestion
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_rule.static_fields_should_have_prefix.symbols = static_fields
dotnet_naming_rule.static_fields_should_have_prefix.style = static_prefix_style
dotnet_naming_symbols.static_fields.applicable_kinds = field
dotnet_naming_symbols.static_fields.required_modifiers = static
dotnet_naming_symbols.static_fields.applicable_accessibilities = private, internal, private_protected
dotnet_naming_style.static_prefix_style.required_prefix = s_
dotnet_naming_style.static_prefix_style.capitalization = camel_case

# internal and private fields should be _camelCase
dotnet_naming_rule.camel_case_for_private_internal_fields.severity = suggestion
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_rule.camel_case_for_private_internal_fields.symbols = private_internal_fields
dotnet_naming_rule.camel_case_for_private_internal_fields.style = camel_case_underscore_style
dotnet_naming_symbols.private_internal_fields.applicable_kinds = field
dotnet_naming_symbols.private_internal_fields.applicable_accessibilities = private, internal
dotnet_naming_style.camel_case_underscore_style.required_prefix = _
Expand Down
47 changes: 41 additions & 6 deletions .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,49 @@ jobs:
name: Run Pull Request Checks
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
- name: Test
uses: actions/setup-dotnet@v3
- uses: actions/setup-dotnet@v3
with:
dotnet-version: |
8.0
- run: dotnet test
8.0
- name: Check out code
uses: actions/checkout@v3
- name: Start MongoDB
uses: supercharge/[email protected]
with:
mongodb-version: '7.0'
mongodb-replica-set: test-rs
mongodb-port: 29017
- name: Test
run: dotnet test --logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" --collect:"XPlat Code Coverage" --results-directory ./coverage


- name: install dotnet coverage
run: dotnet tool install --global dotnet-coverage

- name: merge coverage reports
run: dotnet-coverage merge *.cobertura.xml --recursive --output merged.cobertura.xml --output-format cobertura


- name: Code Coverage Report
uses: irongut/[email protected]
with:
filename: merged.cobertura.xml
badge: true
fail_below_min: false
format: markdown
hide_branch_rate: false
hide_complexity: true
indicators: true
output: both
thresholds: '60 80'

- name: Add Coverage PR Comment
uses: marocchino/sticky-pull-request-comment@v2
if: github.event_name == 'pull_request'
with:
recreate: true
path: code-coverage-results.md

## SonarCloud
## Uncomment to unable SonarCloud scan
## Requires project to be set up in SonarCloud
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ permissions:
env:
AWS_REGION: eu-west-2
AWS_ACCOUNT_ID: "094954420758"
HUSKY: 0

jobs:
build:
Expand Down
84 changes: 84 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@

# Local config files

local.env

## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.

Expand Down Expand Up @@ -267,3 +271,83 @@ __pycache__/

library.db
.envrc

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

report.csv
31 changes: 31 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

## husky task runner examples -------------------
## Note : for local installation use 'dotnet' prefix. e.g. 'dotnet husky'

## run all tasks
#husky run

### run all tasks with group: 'group-name'
#husky run --group group-name

## run task with name: 'task-name'
#husky run --name task-name

## pass hook arguments to task
#husky run --args "$1" "$2"

## or put your custom commands -------------------
#echo 'Husky.Net is awesome!'

echo 'Welcome to pre-commit git hook with Husky.Net'

echo 'Clean Projects'
dotnet clean

echo 'Build Projects'
dotnet build

echo 'Test Projects'
dotnet test --filter Category!=Integration
28 changes: 28 additions & 0 deletions .husky/task-runner.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"$schema": "https://alirezanet.github.io/Husky.Net/schema.json",
"tasks": [
{
"name": "welcome-message-example",
"command": "bash",
"args": [ "-c", "echo Husky.Net is awesome!" ],
"windows": {
"command": "cmd",
"args": ["/c", "echo Husky.Net is awesome!" ]
}
},
{
"name": "dotnet-format",
"group": "pre-commit",
"command": "dotnet",
"args": ["dotnet-format", "--include", "${staged}"],
"include": ["**/*.cs", "**/*.vb"]
},
{
"name": "warning-check",
"command": "dotnet",
"group": "pre-push",
"args": ["build", "/warnaserror"],
"include": ["**/*.cs", "**/*.vb"]
}
]
}
11 changes: 11 additions & 0 deletions Btms.Analytics.Tests/AggregationTestCollection.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Xunit;

namespace Btms.Analytics.Tests;

[CollectionDefinition("Aggregation Test collection")]
public class AggregationTestCollection : ICollectionFixture<AggregationTestFixture>
{
// This class has no code, and is never created. Its purpose is simply
// to be the place to apply [CollectionDefinition] and all the
// ICollectionFixture<> interfaces.
}
61 changes: 61 additions & 0 deletions Btms.Analytics.Tests/AggregationTestFixture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using Btms.Analytics.Tests.Helpers;
using Btms.Analytics;
using Btms.Backend.Data;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using TestDataGenerator.Scenarios;

namespace Btms.Analytics.Tests;

#pragma warning disable S3881
public class AggregationTestFixture : IDisposable
#pragma warning restore S3881
{
public IHost App;
public IImportNotificationsAggregationService ImportNotificationsAggregationService;
public IMovementsAggregationService MovementsAggregationService;

public IMongoDbContext MongoDbContext;
public AggregationTestFixture()
{
var builder = TestContextHelper.CreateBuilder<AggregationTestFixture>();

App = builder.Build();
var rootScope = App.Services.CreateScope();

MongoDbContext = rootScope.ServiceProvider.GetRequiredService<IMongoDbContext>();
ImportNotificationsAggregationService = rootScope.ServiceProvider.GetRequiredService<IImportNotificationsAggregationService>();
MovementsAggregationService = rootScope.ServiceProvider.GetRequiredService<IMovementsAggregationService>();

MongoDbContext.ResetCollections().GetAwaiter().GetResult();

// Ensure we have some data scenarios around 24/48 hour tests
App.PushToConsumers(App.CreateScenarioConfig<ChedASimpleMatchScenarioGenerator>(10, 3, arrivalDateRange: 0))
.GetAwaiter().GetResult();

App.PushToConsumers(App.CreateScenarioConfig<ChedPSimpleMatchScenarioGenerator>(10, 3, arrivalDateRange: 2))
.GetAwaiter().GetResult();

App.PushToConsumers(App.CreateScenarioConfig<CRNoMatchScenarioGenerator>(10, 3, arrivalDateRange: 0))
.GetAwaiter().GetResult();

// Create some more variable data over the rest of time
App.PushToConsumers(App.CreateScenarioConfig<ChedASimpleMatchScenarioGenerator>(10, 7, arrivalDateRange: 10))
.GetAwaiter().GetResult();

App.PushToConsumers(App.CreateScenarioConfig<ChedANoMatchScenarioGenerator>(5, 3, arrivalDateRange: 10))
.GetAwaiter().GetResult();

App.PushToConsumers(App.CreateScenarioConfig<ChedPSimpleMatchScenarioGenerator>(1, 3, arrivalDateRange: 10))
.GetAwaiter().GetResult();

App.PushToConsumers(App.CreateScenarioConfig<CRNoMatchScenarioGenerator>(1, 3, arrivalDateRange: 10))
.GetAwaiter().GetResult();

}

public void Dispose()
{
// ... clean up test data from the database ...
}
}
43 changes: 43 additions & 0 deletions Btms.Analytics.Tests/Btms.Analytics.Tests.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="EphemeralMongo7" Version="1.1.3" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.4.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="FluentAssertions" Version="6.12.1" />
<PackageReference Include="MartinCostello.Logging.XUnit" Version="0.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.8" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="SlimMessageBus" Version="2.0.4" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="xunit.extensibility.core" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Btms.Analytics\Btms.Analytics.csproj" />
<ProjectReference Include="..\Btms.Consumers\Btms.Consumers.csproj" />
<ProjectReference Include="..\TestDataGenerator\TestDataGenerator.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 245435a

Please sign in to comment.