Skip to content

feat(testing): TD_018 C# Event Infrastructure Integration Tests #95

feat(testing): TD_018 C# Event Infrastructure Integration Tests

feat(testing): TD_018 C# Event Infrastructure Integration Tests #95

Workflow file for this run

name: Streamlined CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main, develop ]
types: [ opened, synchronize, reopened ]
workflow_dispatch:
permissions:
contents: read
pull-requests: read
checks: write
jobs:
# Job 1: Quick verification (trust local hooks did their job)
verify:
name: πŸ” Verify Local Fixes
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: πŸ” Verify build cleanliness
run: |
echo "πŸ” Verifying no build artifacts committed..."
if find . -type d -name "bin" -o -name "obj" | grep -q .; then
echo "❌ Build artifacts found in repo"
exit 1
else
echo "βœ… Repository is clean (no build artifacts)"
fi
- name: πŸ” Verify code formatting
run: |
echo "πŸ” Verifying local hooks did their job..."
# Check if code would be changed by formatting
dotnet format src/Darklands.Core.csproj --verify-no-changes --verbosity diagnostic
dotnet format tests/Darklands.Core.Tests.csproj --verify-no-changes --verbosity diagnostic
echo "βœ… Code formatting is correct (local hooks worked!)"
# Clean up any build artifacts created during format verification
echo "🧹 Cleaning up format verification artifacts..."
find . -type d -name "bin" -o -name "obj" | grep -v .godot | xargs rm -rf || true
# Job 2: Fast build and test
test:
name: πŸ§ͺ Build & Test
runs-on: ubuntu-latest
needs: [verify]
timeout-minutes: 10
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '8.0.x'
- name: πŸ—οΈ Restore dependencies
run: dotnet restore
- name: πŸ—οΈ Build projects
run: |
dotnet build src/Darklands.Core.csproj --configuration Release
dotnet build tests/Darklands.Core.Tests.csproj --configuration Release
# Godot project (optional - may need Godot runtime)
dotnet build Darklands.csproj --configuration Release || {
echo "ℹ️ Godot project build skipped (requires Godot runtime)"
}
- name: πŸ§ͺ Run tests
run: |
dotnet test tests/Darklands.Core.Tests.csproj \
--configuration Release \
--logger "console;verbosity=normal" \
--collect:"XPlat Code Coverage" \
--results-directory ./TestResults \
--filter "FullyQualifiedName!~MediatR_Should_Discover_All_Handlers_In_Core_Assembly"
- name: πŸ“Š Upload coverage
uses: codecov/codecov-action@v4
if: always()
with:
directory: ./TestResults
flags: unittests
fail_ci_if_error: false
# Job 3: Security and quality checks
security:
name: πŸ”’ Security & Quality
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: πŸ”’ Security scan
run: |
echo "πŸ”’ Scanning for security issues..."
# Check for hardcoded secrets (basic check) - more specific patterns
if grep -r "password\s*=\s*[\"'].*[\"']" --include="*.cs" . || \
grep -r "secret\s*=\s*[\"'].*[\"']" --include="*.cs" . || \
grep -r "apikey\s*=\s*[\"'].*[\"']" --include="*.cs" . || \
grep -r "connectionstring\s*=\s*[\"'].*[\"']" --include="*.cs" .; then
echo "⚠️ Potential hardcoded credentials found"
exit 1
else
echo "βœ… No hardcoded credentials detected"
fi
- name: πŸ“ Validate commit messages (PR only)
if: github.event_name == 'pull_request'
run: |
echo "πŸ“ Validating commit messages..."
# Simple conventional commit check
git log --format=%s origin/main..HEAD | while read commit; do
if echo "$commit" | grep -qE "^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\([a-zA-Z0-9_-]+\))?: .+|.*\[Phase [1-4]/4\]"; then
echo "βœ… $commit"
else
echo "⚠️ Non-conventional: $commit"
fi
done
# Job 4: Success summary (only runs if all pass)
success:
name: βœ… CI Success
runs-on: ubuntu-latest
needs: [verify, test, security]
if: success()
steps:
- name: πŸŽ‰ All checks passed
run: |
echo "πŸŽ‰ All CI checks passed!"
echo ""
echo "βœ… Local hooks verification: PASSED"
echo "βœ… Build and tests: PASSED"
echo "βœ… Security scan: PASSED"
echo ""
echo "πŸš€ Ready to merge!"