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
166 changes: 166 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
# EditorConfig is awesome: https://EditorConfig.org

# top-most EditorConfig file
root = true

# All files
[*]
charset = utf-8
indent_style = space
trim_trailing_whitespace = true

# Code files
[*.{cs,csx,vb,vbx}]
indent_size = 4

# XML project files
[*.{csproj,vbproj,vcxproj,vcxproj.filters,proj,projitems,shproj}]
indent_size = 2

# XML build files
[*.builds]
indent_size = 2

# XML files
[*.{xml,stylecop,resx,ruleset}]
indent_size = 2

# JSON files
[*.{json,json5}]
indent_size = 2

# YAML files
[*.{yml,yaml}]
indent_size = 2

# Markdown files
[*.md]
trim_trailing_whitespace = false

# Web files
[*.{htm,html,js,ts,css,scss,less}]
indent_size = 2

# Batch files
[*.{cmd,bat}]
end_of_line = crlf

# Shell scripts
[*.sh]
end_of_line = lf

# C# files
[*.cs]

# New line preferences
csharp_new_line_before_open_brace = all
csharp_new_line_before_else = true
csharp_new_line_before_catch = true
csharp_new_line_before_finally = true
csharp_new_line_before_members_in_object_initializers = true
csharp_new_line_before_members_in_anonymous_types = true
csharp_new_line_between_query_expression_clauses = true

# Indentation preferences
csharp_indent_case_contents = true
csharp_indent_switch_labels = true
csharp_indent_labels = flush_left

# Space preferences
csharp_space_after_cast = false
csharp_space_after_keywords_in_control_flow_statements = true
csharp_space_between_method_call_parameter_list_parentheses = false
csharp_space_between_method_declaration_parameter_list_parentheses = false
csharp_space_between_parentheses = false
csharp_space_before_colon_in_inheritance_clause = true
csharp_space_after_colon_in_inheritance_clause = true
csharp_space_around_binary_operators = before_and_after
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
csharp_space_between_method_call_name_and_opening_parenthesis = false
csharp_space_between_method_call_empty_parameter_list_parentheses = false

# Wrapping preferences
csharp_preserve_single_line_statements = true
csharp_preserve_single_line_blocks = true

# Organize usings
dotnet_separate_import_directive_groups = false
dotnet_sort_system_directives_first = true

# Code-block preferences
csharp_prefer_braces = true:warning

# Expression-level preferences
csharp_prefer_simple_using_statement = true:suggestion
csharp_style_namespace_declarations = file_scoped:warning
csharp_style_prefer_method_group_conversion = true:suggestion
csharp_style_prefer_top_level_statements = true:warning
csharp_style_expression_bodied_methods = false:none
csharp_style_expression_bodied_constructors = false:none
csharp_style_expression_bodied_operators = false:none
csharp_style_expression_bodied_properties = true:suggestion
csharp_style_expression_bodied_indexers = true:suggestion
csharp_style_expression_bodied_accessors = true:suggestion

# Pattern matching preferences
csharp_style_pattern_matching_over_is_with_cast_check = true:suggestion
csharp_style_pattern_matching_over_as_with_null_check = true:suggestion
csharp_style_inlined_variable_declaration = true:suggestion

# Null-checking preferences
csharp_style_throw_expression = true:suggestion
csharp_style_conditional_delegate_call = true:suggestion

# Modifier preferences
csharp_prefer_static_local_functions = true:suggestion
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion

# Code style rules
dotnet_style_qualification_for_field = false:suggestion
dotnet_style_qualification_for_property = false:suggestion
dotnet_style_qualification_for_method = false:suggestion
dotnet_style_qualification_for_event = false:suggestion
dotnet_style_predefined_type_for_locals_parameters_members = true:suggestion
dotnet_style_predefined_type_for_member_access = true:suggestion
dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion
dotnet_style_readonly_field = true:suggestion

# Expression-level preferences
dotnet_style_object_initializer = true:suggestion
dotnet_style_collection_initializer = true:suggestion
dotnet_style_explicit_tuple_names = true:suggestion
dotnet_style_null_propagation = true:suggestion
dotnet_style_coalesce_expression = true:suggestion
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion
dotnet_style_prefer_inferred_tuple_names = true:suggestion
dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion
dotnet_style_prefer_auto_properties = true:suggestion
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
dotnet_style_prefer_conditional_expression_over_return = true:suggestion

# Naming rules
dotnet_naming_rule.interfaces_should_be_prefixed_with_i.severity = warning
dotnet_naming_rule.interfaces_should_be_prefixed_with_i.symbols = interface
dotnet_naming_rule.interfaces_should_be_prefixed_with_i.style = prefix_interface_with_i

dotnet_naming_rule.types_should_be_pascal_case.severity = warning
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case

dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = warning
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case

dotnet_naming_symbols.interface.applicable_kinds = interface
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected

dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected

dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected

dotnet_naming_style.prefix_interface_with_i.required_prefix = I
dotnet_naming_style.prefix_interface_with_i.capitalization = pascal_case

dotnet_naming_style.pascal_case.capitalization = pascal_case
38 changes: 38 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
version: 2
updates:
# .NET dependencies
- package-ecosystem: "nuget"
directory: "/src"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
open-pull-requests-limit: 10
commit-message:
prefix: "🔄"
include: "scope"
labels:
- "dependencies"
- "nuget"
reviewers:
- "fructuoso"
assignees:
- "fructuoso"

# GitHub Actions dependencies
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
day: "monday"
time: "09:00"
commit-message:
prefix: "🔧"
include: "scope"
labels:
- "dependencies"
- "github-actions"
reviewers:
- "fructuoso"
assignees:
- "fructuoso"
186 changes: 186 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
name: 🔍 CI - Quality & Coverage

on:
pull_request:
branches: [ main, develop ]
paths:
- 'src/**'
- '.github/workflows/ci.yml'
- '.editorconfig'
- 'global.json'
push:
branches: [ main, develop ]
paths:
- 'src/**'
- '.github/workflows/ci.yml'
- '.editorconfig'
- 'global.json'

env:
DOTNET_VERSION: '8.0.x'
WORKING_DIRECTORY: './src'
CONFIGURATION: 'Release'
COVERAGE_THRESHOLD: '80'

jobs:
ci:
name: 🚀 CI - Build, Test, Quality & Coverage
runs-on: ubuntu-latest

steps:
- name: 🛒 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: 🔧 Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: 📦 Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/src/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-

- name: 🔄 Restore dependencies
working-directory: ${{ env.WORKING_DIRECTORY }}
run: dotnet restore --verbosity minimal

- name: 🎨 Check code formatting
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
echo "🎨 Checking code formatting..."
dotnet format --verify-no-changes --verbosity minimal

- name: 🏗️ Build solution
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
echo "🏗️ Building solution..."
dotnet build --configuration ${{ env.CONFIGURATION }} --no-restore --verbosity minimal

- name: 🔍 Static code analysis
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
echo "🔍 Running static analysis..."
dotnet build --configuration Debug --no-restore --verbosity minimal

- name: 🔒 Security audit
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
echo "🔒 Running security audit..."
dotnet list package --vulnerable --include-transitive || echo "✅ No vulnerabilities found"
dotnet list package --deprecated || echo "✅ No deprecated packages found"

- name: 🧪 Run tests with coverage
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
echo "🧪 Running tests with coverage collection..."
dotnet test \
--configuration ${{ env.CONFIGURATION }} \
--no-build \
--verbosity minimal \
--collect:"XPlat Code Coverage" \
--results-directory:"./TestResults" \
--logger:"trx;LogFileName=test-results.trx" \
-- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.ExcludeByFile="**/Program.cs"

- name: 🛠️ Install ReportGenerator
run: dotnet tool install -g dotnet-reportgenerator-globaltool

- name: 📊 Generate coverage report
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
echo "📊 Generating coverage report..."

# Find coverage files
echo "🔍 Coverage files found:"
COVERAGE_FILES=$(find TestResults -name "coverage.cobertura.xml" -type f 2>/dev/null || true)

if [ -z "$COVERAGE_FILES" ]; then
echo "⚠️ No coverage files found. Creating placeholder report..."
mkdir -p CoverageReport
echo "# ⚠️ Coverage Report Not Available" > CoverageReport/SummaryGithub.md
echo "" >> CoverageReport/SummaryGithub.md
echo "No coverage data was collected during test execution." >> CoverageReport/SummaryGithub.md
exit 0
fi

# List all coverage files with details
echo "📋 Coverage files to be merged:"
find TestResults -name "coverage.cobertura.xml" -type f -exec echo " - {}" \;

# Count projects
FILE_COUNT=$(find TestResults -name "coverage.cobertura.xml" -type f | wc -l)
echo "📊 Total test projects with coverage: $FILE_COUNT"

# Generate report
reportgenerator \
-reports:"TestResults/**/coverage.cobertura.xml" \
-targetdir:"CoverageReport" \
-reporttypes:"Html;MarkdownSummaryGithub;JsonSummary;Badges" \
-title:"DesignPatternSamples - Code Coverage" \
-tag:"monorepo;dotnet8;ci"

- name: 📈 Check coverage threshold
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
if [ -f "CoverageReport/Summary.json" ]; then
COVERAGE=$(jq -r '.summary.linecoverage' CoverageReport/Summary.json)
echo "📊 Current coverage: ${COVERAGE}%"

# Use bc for floating point comparison
if (( $(echo "$COVERAGE < ${{ env.COVERAGE_THRESHOLD }}" | bc -l) )); then
echo "❌ Coverage $COVERAGE% is below threshold ${{ env.COVERAGE_THRESHOLD }}%"
exit 1
else
echo "✅ Coverage $COVERAGE% meets threshold ${{ env.COVERAGE_THRESHOLD }}%"
fi
else
echo "⚠️ Summary.json not found, coverage check skipped"
fi

- name: 💬 Comment coverage on PR
if: github.event_name == 'pull_request' && !cancelled() && hashFiles('./src/CoverageReport/SummaryGithub.md') != ''
uses: marocchino/sticky-pull-request-comment@v2
with:
recreate: true
path: ${{ env.WORKING_DIRECTORY }}/CoverageReport/SummaryGithub.md

- name: 📤 Upload coverage report
if: always()
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ${{ env.WORKING_DIRECTORY }}/CoverageReport/

- name: 📤 Upload test results
if: always()
uses: actions/upload-artifact@v4
with:
name: test-results
path: ${{ env.WORKING_DIRECTORY }}/TestResults/

- name: 📋 CI Summary
if: always()
run: |
echo "## 🎯 CI Results Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY

if [ "${{ job.status }}" == "success" ]; then
echo "✅ **All checks passed!**" >> $GITHUB_STEP_SUMMARY
echo "- 🎨 Code formatting: ✅" >> $GITHUB_STEP_SUMMARY
echo "- 🏗️ Build: ✅" >> $GITHUB_STEP_SUMMARY
echo "- 🔍 Static analysis: ✅" >> $GITHUB_STEP_SUMMARY
echo "- 🔒 Security audit: ✅" >> $GITHUB_STEP_SUMMARY
echo "- 🧪 Tests: ✅" >> $GITHUB_STEP_SUMMARY
echo "- 📊 Coverage: ✅" >> $GITHUB_STEP_SUMMARY
else
echo "❌ **Some checks failed - please review the logs above**" >> $GITHUB_STEP_SUMMARY
fi

echo "" >> $GITHUB_STEP_SUMMARY
echo "📊 Coverage reports and test results are available in the artifacts." >> $GITHUB_STEP_SUMMARY
Loading
Loading