Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
142 commits
Select commit Hold shift + click to select a range
48e7148
docs: update roadmap - Sprint 8D completed, 8E planned, prioritize Co…
Mar 24, 2026
bfcc791
feat: add Playwright E2E test structure and pipeline integration
Mar 24, 2026
804e23e
docs: update admin-portal docs with React examples and fix E2E tests
Mar 24, 2026
4937e20
fix: resolve documentation inconsistencies and add dynamic E2E toggle
Mar 24, 2026
790fabe
refactor: restructure E2E tests to tests/MeAjudaAi.Web.*.Tests/
Mar 24, 2026
e688313
chore: exclude nul from tracking and update e2e specs
Mar 24, 2026
03d7ae9
feat: Introduce E2E tests, establish CI/CD pipeline, and add core doc…
Mar 24, 2026
a8f4394
feat: Add e2e-support library with project and ESLint configurations.
Mar 24, 2026
fb97b1a
feat: Add Nx project configuration for the e2e-support library.
Mar 24, 2026
9e2079a
test: Add E2E tests covering onboarding, profile management, configur…
Mar 24, 2026
adb928d
feat: Establish comprehensive project roadmap, architecture documenta…
Mar 24, 2026
5e65c3f
feat: Introduce an admin sidebar component, add extensive E2E tests f…
Mar 25, 2026
b2a8898
feat: implement responsive sidebar component with navigation, user in…
Mar 25, 2026
931df3c
feat: Add comprehensive documentation for project architecture, admin…
Mar 25, 2026
43a6d61
feat: Add a comprehensive plan for implementing React 19 + TypeScript…
Mar 25, 2026
4ca8e06
feat: Set up Vitest and React Testing Library for unit testing across…
Mar 25, 2026
816ba64
test: Add Vitest configuration and initial unit tests for customer-fa…
Mar 25, 2026
3687885
feat: Initialize web project testing infrastructure with Vitest and P…
Mar 25, 2026
f45e7ad
feat: Establish web project foundation with modular design, comprehen…
Mar 25, 2026
0352068
test: Introduce Vitest and add unit tests for various components, hoo…
Mar 25, 2026
a851495
feat: Introduce Vitest for customer application unit and E2E testing,…
Mar 25, 2026
584df49
test: Introduce Vitest and add unit and E2E performance tests for cus…
Mar 25, 2026
705eab1
feat: introduce Vitest for unit and E2E tests across customer web app…
Mar 25, 2026
720542e
feat: add unit tests for various customer web components and hooks.
Mar 25, 2026
9e3b367
feat: Add comprehensive unit and E2E tests across customer components…
Mar 25, 2026
44fb031
feat: Add Vitest unit and E2E performance tests for the customer web …
Mar 25, 2026
96eccdd
feat: Add comprehensive frontend testing plan and initial Vitest/Play…
Mar 25, 2026
0271da1
feat: Implement initial Vitest unit testing infrastructure and add te…
Mar 25, 2026
c44da4d
feat: Implement comprehensive frontend testing infrastructure with Vi…
Mar 25, 2026
34adca5
feat: Implement new frontend testing strategy using Vitest and React …
Mar 26, 2026
41b9585
feat: Establish comprehensive testing infrastructure with unit and E2…
Mar 26, 2026
dc4ef07
chore: modularize CI/CD pipelines
Mar 26, 2026
cf815dd
feat: add bicep infrastructure and update deploy-azure workflow for d…
Mar 26, 2026
c56acba
chore: update deploy-azure workflow to support dev/prod environments
Mar 26, 2026
f8dc74a
docs: add Portuguese instructions for Azure CI/CD and Bicep infrastru…
Mar 26, 2026
a60be37
chore: add Aspire infrastructure artifacts to .gitignore
Mar 26, 2026
009afd6
chore: refine coverage filters for backend and add coverage report fo…
Mar 26, 2026
54f2271
feat: Implement comprehensive testing infrastructure with Vitest, Pla…
Mar 26, 2026
0c1c37e
feat: Add Zod schemas for customer and provider authentication and co…
Mar 26, 2026
c68893e
fix: review corrections for E2E tests and frontend configuration
Mar 26, 2026
ffb51e3
chore: update package-lock.json with e2e-support dependency
Mar 26, 2026
d34e158
feat: add cobertura coverage reporter for CI
Mar 26, 2026
4b41b92
fix: update mkdocs nav and fix relative paths in e2e-tests
Mar 26, 2026
8b072ea
chore: add MkDocs site output to gitignore
Mar 26, 2026
bd914dd
fix: review corrections for E2E tests and validation
Mar 26, 2026
99cc54d
fix: fix customer-register-form test to properly mock sonner and asse…
Mar 26, 2026
0aa982a
docs: update roadmap status - mark completed items
Mar 27, 2026
4f8be45
fix: review corrections - multiple improvements
Mar 27, 2026
bcb231f
fix: fix coverage glob pattern in ci-frontend.yml
Mar 27, 2026
a4d77d2
fix: review corrections - multiple improvements (phase 2)
Mar 27, 2026
3c014c8
fix: add output-file param to CodeCoverageSummary and fail_if_missing
Mar 27, 2026
590848b
fix: simplify coverage file path patterns in ci-frontend.yml
Mar 27, 2026
4d17f2d
fix: use merged coverage report in CodeCoverageSummary instead of ind…
Mar 27, 2026
79add1c
fix: normalizeProviderType to return number for valid numeric strings…
Mar 27, 2026
6106c2b
feat: Establish new React/Next.js frontend architecture for Admin and…
Mar 27, 2026
9f7e5ff
build: remove Aspire.Hosting.Orchestration.linux-x64 package version …
Mar 27, 2026
ae73638
build: Generate `packages.lock.json` files for all projects and updat…
Mar 27, 2026
b7cd37c
test: Add Vitest unit tests for various components, utilities, and AP…
Mar 27, 2026
dab91ae
feat: Introduce comprehensive testing by adding unit tests for Locati…
Mar 27, 2026
eb2e864
feat: Introduce comprehensive frontend testing, including unit, integ…
Mar 27, 2026
efd4d7e
feat: implement Keycloak permission resolver with caching and add com…
Mar 28, 2026
83ab7a6
feat: implement KeycloakPermissionResolver with caching and add unit …
Mar 28, 2026
60c521a
test: add integration tests for Documents API endpoints
Mar 28, 2026
08d2221
test: add unit tests for UI components and implement coverage report …
Mar 28, 2026
1157d04
feat: implement customer registration form and expand test coverage w…
Mar 28, 2026
d09120a
feat: add script to aggregate and validate global frontend test cover…
Mar 28, 2026
17fafc1
feat: implement frontend testing suite, caching infrastructure, and C…
Mar 28, 2026
2295daf
test: add unit tests for search page functionality and error handling
Mar 28, 2026
34e06db
feat: implement frontend testing infrastructure and add unit tests fo…
Mar 28, 2026
d7dd033
feat: implement locations module structure, search endpoint, hybrid c…
Mar 28, 2026
9a7a417
test: add unit tests for customer registration form, admin sidebar, s…
Mar 28, 2026
4d0a5ad
feat: implement CI E2E pipeline and add component unit tests
Mar 28, 2026
268dfb4
feat: add CI workflow for automated backend and frontend E2E testing
Mar 28, 2026
d8bbd68
feat: add E2E CI pipeline and unit tests for UI components and regist…
Mar 28, 2026
beda776
test: implement comprehensive unit and component test suites across w…
Mar 28, 2026
44d50a8
test: add unit tests for PermissionService covering cache integration…
Mar 28, 2026
c289a49
feat: implement E2E CI pipeline, add phone validator, and expand unit…
Mar 28, 2026
a9af3db
test: resolve all failing unit tests across react apps
Mar 28, 2026
573b7a9
fix(build): resolve next.js build warnings and typescript errors in c…
Mar 28, 2026
cb8549a
test: resolve all failing unit tests across react apps and backend en…
Mar 29, 2026
06b30f7
ci: fix frontend coverage merge reporting and include customer app
Mar 29, 2026
2752267
fix(e2e): configure Playwright for CI with auth mocks and correct routes
Mar 29, 2026
a5f8a38
fix(integration-tests): correct failing backend integration tests
Mar 29, 2026
c51fde7
ci: implement frontend CI pipeline, add admin portal documentation, a…
Mar 29, 2026
c35d4bf
feat: implement Keycloak authentication for admin portal and add next…
Mar 29, 2026
9e8bdfb
feat: implement EventTypeRegistry to discover and cache integration e…
Mar 29, 2026
12e483c
test: add unit tests for useDashboardStats hook and utility functions
Mar 29, 2026
465dff4
feat: implement event type registry, configure Keycloak auth for admi…
Mar 29, 2026
b0098cb
feat: implement admin dashboard with statistics visualization and fro…
Mar 29, 2026
1978e7d
feat: add Playwright configuration and frontend CI pipeline for autom…
Mar 29, 2026
6cb2df9
feat: implement CI pipelines for E2E and frontend testing with Playwr…
Mar 29, 2026
b3ba30d
feat: implement E2E testing pipeline and dashboard KPI verification t…
Mar 30, 2026
0e4eaef
test: add integration tests for CEP provider fallback scenarios and i…
Mar 30, 2026
da49073
feat: add vitest configuration files for customer, provider, and admi…
Mar 30, 2026
8a70167
feat: implement end-to-end testing infrastructure with Playwright and…
Mar 30, 2026
2b661e0
feat: add Playwright base test fixtures with authentication mocking a…
Mar 30, 2026
83e43d6
feat: add base Playwright test utilities with auth mocking and login …
Mar 30, 2026
345a8b0
feat: implement NextAuth middleware with E2E test bypass support
Mar 30, 2026
c2f48f8
fix: correcao testes de integracao - tolerant responses and skip CEP …
Mar 30, 2026
26ff328
fix: improve E2E mocks and skip flaky tests
Mar 30, 2026
1fff1f5
fix: skip flaky E2E tests - will fix later
Mar 30, 2026
1ab2ac4
feat: implement monorepo structure with shared test utilities, API cl…
Mar 30, 2026
fec0f16
feat: implement E2E CI pipeline and add unit/integration test suites …
Mar 30, 2026
96263d0
feat: add CI workflow for backend and frontend E2E testing
Mar 30, 2026
4b5c713
feat: add CI workflow for backend and frontend E2E testing
Mar 30, 2026
bb49f61
feat: add GitHub Actions workflow for automated backend and frontend …
Mar 30, 2026
49d8dd0
feat: implement geocoding service, add normalization tests, and confi…
Mar 30, 2026
78681fb
feat: implement SelfOrAdmin authorization handler and configure NextA…
Mar 30, 2026
3986ca8
test: add integration tests for CEP provider fallback logic and initi…
Mar 30, 2026
e08f7b6
test: add integration tests for CEP lookup service and service catalo…
Mar 30, 2026
0278a04
feat: implement NextAuth configuration with Keycloak and credential p…
Mar 30, 2026
5c57dda
feat: implement provider registration handler, admin configuration, a…
Mar 31, 2026
d766c93
feat: implement E2E CI pipeline with Playwright and add integration t…
Mar 31, 2026
0d68138
feat: implement Playwright E2E testing suite and CI pipeline for web …
Mar 31, 2026
2df3aa5
fix(tests): resolve integration test failures and improve infrastruc…
Apr 1, 2026
851d06f
feat: implement search page with geocoding, provider filtering, and a…
Apr 1, 2026
fbfde44
feat: implement unit and integration test suites for Locations and Us…
Apr 1, 2026
b488e09
feat: implement Playwright E2E testing framework with initial admin p…
Apr 1, 2026
f25b7f6
test: add integration tests for AllowedCity admin endpoints
Apr 1, 2026
81a794c
test: add integration tests for AllowedCity admin API endpoints
Apr 1, 2026
72754d3
test(providers): add unit tests for admin and public endpoints
Apr 1, 2026
4e08704
test(providers): implement integration tests for admin endpoints and …
Apr 1, 2026
ec57127
test(service-catalogs): add missing integration tests for endpoints
Apr 1, 2026
32e688b
test(users): add missing integration tests for endpoints
Apr 1, 2026
ebff9fd
test: achieve high coverage using integration tests and fix build issues
Apr 1, 2026
c0bb339
fix(providers): add email and phone validation to RegisterProviderCom…
Apr 1, 2026
175d599
fix(integration-tests): fix routes, data and deserialization issues i…
Apr 1, 2026
62ff949
test: add integration tests for Service Catalogs and Providers admin …
Apr 2, 2026
6fb6e40
test: add integration tests for documents, geographic restrictions, a…
Apr 2, 2026
7ea46f4
test: add integration test suites for providers, service catalogs, us…
Apr 2, 2026
26dbcd0
feat: add backend CI workflow with build, test, and coverage reporting
Apr 2, 2026
b191994
ci: add backend CI workflow with build, test, and coverage reporting
Apr 2, 2026
06f096e
feat: add CI workflow for backend build, test, and coverage reporting
Apr 2, 2026
b26f564
feat: add CI workflow for backend build, unit, and integration testing
Apr 2, 2026
18445be
feat: add backend CI workflow with PostgreSQL and Azurite integration…
Apr 2, 2026
1772862
feat: add CI workflow for backend build and test automation
Apr 2, 2026
10adeb2
feat: add backend CI workflow for automated testing and coverage anal…
Apr 2, 2026
66a0812
ci: unify test suite and fix coverage instrumentation to reflect true…
Apr 2, 2026
a69a1b2
ci: fix coverage file overwriting and restore db wait step
Apr 3, 2026
fce5d13
ci: split unit and integration tests for better debuggability and fix…
Apr 3, 2026
834f3cd
ci: ensure coverage collection even if tests fail and fix file aggreg…
Apr 3, 2026
5cbeb41
ci: fix shell syntax error and revert to separate test steps for bett…
Apr 3, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
37 changes: 37 additions & 0 deletions .github/actions/setup-backend/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Setup Backend'
description: 'Setup .NET, restore dependencies, and install required tools'
inputs:
dotnet-version:
description: '.NET version to setup'
required: false
default: '10.0.x'
solution-path:
description: 'Path to the solution file'
required: false
default: 'MeAjudaAi.slnx'

runs:
using: "composite"
steps:
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: ${{ inputs.dotnet-version }}

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

- name: Restore dependencies
shell: bash
run: dotnet restore ${{ inputs.solution-path }}

- name: Install Tools
shell: bash
run: |
dotnet tool install -g Swashbuckle.AspNetCore.Cli --version 10.1.7
dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.5.4
29 changes: 29 additions & 0 deletions .github/actions/setup-frontend/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Setup Frontend'
description: 'Setup Node.js and install dependencies'
inputs:
node-version:
description: 'Node.js version'
required: false
default: '20'
working-directory:
description: 'Frontend working directory'
required: false
default: './src/Web'

runs:
using: "composite"
steps:
- name: Setup Node.js environment
uses: actions/setup-node@v6
with:
node-version: ${{ inputs.node-version }}
cache: "npm"
cache-dependency-path: ${{ inputs.working-directory }}/package-lock.json

- name: Install Frontend Dependencies
shell: bash
working-directory: ${{ inputs.working-directory }}
run: npm ci

- name: Nx Set SHAs
uses: nrwl/nx-set-shas@v5
9 changes: 9 additions & 0 deletions .github/scripts/generate-runsettings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
# -o pipefail: catch errors in piped commands
set -euo pipefail

# Coverage threshold (default: 90%)
COVERAGE_THRESHOLD="${COVERAGE_THRESHOLD:-90}"

# Validate COVERAGE_THRESHOLD is within valid range (0-100)
if ! [[ "$COVERAGE_THRESHOLD" =~ ^[0-9]+$ ]] || [ "$COVERAGE_THRESHOLD" -lt 0 ] || [ "$COVERAGE_THRESHOLD" -gt 100 ]; then
echo "⚠️ WARNING: COVERAGE_THRESHOLD ($COVERAGE_THRESHOLD) is not in valid range 0-100. Using default 90." >&2
COVERAGE_THRESHOLD=90
fi

# Escape XML special characters to prevent malformed XML output
escape_xml() {
local input="$1"
Expand Down
313 changes: 313 additions & 0 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,313 @@
name: Backend CI

on:
push:
branches: [master, develop]
paths:
- 'src/Modules/**'
- 'src/Bootstrapper/**'
- 'src/Shared/**'
- 'tests/**'
- '!tests/MeAjudaAi.E2E.Tests/**'
- '.github/workflows/ci-backend.yml'
- '.github/actions/setup-backend/**'
- '.github/actions/setup-postgres-connection/**'
- '.github/scripts/generate-runsettings.sh'
- 'MeAjudaAi.slnx'
pull_request:
branches: [master, develop]
paths:
- 'src/Modules/**'
- 'src/Bootstrapper/**'
- 'src/Shared/**'
- 'tests/**'
- '!tests/MeAjudaAi.E2E.Tests/**'
- '.github/workflows/ci-backend.yml'
- '.github/actions/setup-backend/**'
- '.github/actions/setup-postgres-connection/**'
- '.github/scripts/generate-runsettings.sh'
- 'MeAjudaAi.slnx'
workflow_dispatch:

permissions:
contents: read
pull-requests: write
checks: write
statuses: write

env:
DOTNET_VERSION: "10.0.x"
STRICT_COVERAGE: true
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD || 'test123' }}
POSTGRES_USER: ${{ secrets.POSTGRES_USER || 'postgres' }}
POSTGRES_DB: ${{ secrets.POSTGRES_DB || 'meajudaai_test' }}

jobs:
build-and-test:
name: Build and Test (Backend)
runs-on: ubuntu-latest
timeout-minutes: 60

services:
postgres:
image: postgis/postgis:16-3.4
env:
POSTGRES_PASSWORD: ${{ env.POSTGRES_PASSWORD }}
POSTGRES_USER: ${{ env.POSTGRES_USER }}
POSTGRES_DB: ${{ env.POSTGRES_DB }}
POSTGRES_HOST_AUTH_METHOD: md5
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432

azurite:
image: mcr.microsoft.com/azure-storage/azurite:latest
ports:
- 10000:10000
- 10001:10001
- 10002:10002

steps:
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Setup Backend
uses: ./.github/actions/setup-backend
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client

- name: Build solution
run: dotnet build MeAjudaAi.slnx --configuration Release --no-restore

- name: Extract Aspire version from Directory.Packages.props
id: aspire-version
run: |
ASPIRE_VERSION=$(grep -oP 'Aspire\.Hosting\.PostgreSQL.*?Version="\K[^"]+' Directory.Packages.props || echo "13.1.3")
echo "version=$ASPIRE_VERSION" >> "$GITHUB_OUTPUT"

- name: Prepare Aspire Integration Tests
run: |
echo "Preparing .NET Aspire for integration tests..."
ASPIRE_VERSION="${{ steps.aspire-version.outputs.version }}"
TEMP_DIR=$(mktemp -d)
cd "$TEMP_DIR"
dotnet new console -n TempDcpDownloader
cd TempDcpDownloader
dotnet add package Aspire.Hosting.Orchestration.linux-x64 --version "$ASPIRE_VERSION"
dotnet restore
cd "$GITHUB_WORKSPACE"
rm -rf "$TEMP_DIR"
DCP_PACKAGE_PATH=$(find "$HOME/.nuget/packages" -maxdepth 1 -type d \
-iname "aspire.hosting.orchestration.linux-x64" 2>/dev/null | head -n 1)
if [ -z "$DCP_PACKAGE_PATH" ]; then
echo "Error: Aspire orchestration package not found"
exit 1
fi
DCP_BINARY=$(find "$DCP_PACKAGE_PATH" -type f -name "dcp" 2>/dev/null | head -n 1)
if [ -z "$DCP_BINARY" ]; then
echo "Error: DCP binary not found"
exit 1
fi
echo "DOTNET_ROOT=$HOME/.dotnet" >> $GITHUB_ENV

- name: Wait for PostgreSQL
shell: bash
run: |
max_attempts=30
attempt=0
until pg_isready -h localhost -p 5432 -U "$POSTGRES_USER"; do
attempt=$((attempt + 1))
if [ $attempt -ge $max_attempts ]; then
echo "ERROR: PostgreSQL did not become ready after $max_attempts attempts"
exit 1
fi
echo "Waiting for PostgreSQL... (attempt $attempt/$max_attempts)"
sleep 2
done
echo "PostgreSQL is ready"

- name: Setup PostgreSQL connection
id: db
uses: ./.github/actions/setup-postgres-connection
with:
postgres-host: localhost
postgres-port: 5432
postgres-db: ${{ env.POSTGRES_DB }}
postgres-user: ${{ env.POSTGRES_USER }}
postgres-password: ${{ env.POSTGRES_PASSWORD }}

- name: Wait for PostgreSQL
shell: bash
run: |
max_attempts=60
attempt=0
until pg_isready -h localhost -p 5432 -U "$POSTGRES_USER"; do
attempt=$((attempt + 1))
if [ $attempt -ge $max_attempts ]; then
echo "ERROR: PostgreSQL did not become ready after $max_attempts attempts"
exit 1
fi
echo "Waiting for PostgreSQL... (attempt $attempt/$max_attempts)"
sleep 2
done
echo "PostgreSQL is ready"

- name: Run Unit Tests with Coverage
id: unit-tests
continue-on-error: true
env:
ASPNETCORE_ENVIRONMENT: Testing
MEAJUDAAI_DB_PASS: ${{ env.POSTGRES_PASSWORD }}
MEAJUDAAI_DB_USER: ${{ env.POSTGRES_USER }}
MEAJUDAAI_DB: ${{ env.POSTGRES_DB }}
ConnectionStrings__DefaultConnection: ${{ steps.db.outputs.connection-string }}
ConnectionStrings__Users: ${{ steps.db.outputs.connection-string }}
ConnectionStrings__Search: ${{ steps.db.outputs.connection-string }}
ConnectionStrings__meajudaai-db: ${{ steps.db.outputs.connection-string }}
AZURE_STORAGE_CONNECTION_STRING: "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;"
run: |
echo "🧪 Running Unit & Architecture Tests..."
rm -rf ./coverage
mkdir -p ./coverage

# Run unit tests per module for isolation
MODULES=(
"src/Modules/Users/Tests/MeAjudaAi.Modules.Users.Tests.csproj"
"src/Modules/Providers/Tests/MeAjudaAi.Modules.Providers.Tests.csproj"
"src/Modules/Documents/Tests/MeAjudaAi.Modules.Documents.Tests.csproj"
"src/Modules/ServiceCatalogs/Tests/MeAjudaAi.Modules.ServiceCatalogs.Tests.csproj"
"src/Modules/Locations/Tests/MeAjudaAi.Modules.Locations.Tests.csproj"
"src/Modules/SearchProviders/Tests/MeAjudaAi.Modules.SearchProviders.Tests.csproj"
"tests/MeAjudaAi.Shared.Tests/MeAjudaAi.Shared.Tests.csproj"
"tests/MeAjudaAi.ApiService.Tests/MeAjudaAi.ApiService.Tests.csproj"
"tests/MeAjudaAi.Architecture.Tests/MeAjudaAi.Architecture.Tests.csproj"
)

for module in "${MODULES[@]}"; do
if [ -f "$module" ]; then
module_name=$(basename "$module" .csproj)
dotnet test "$module" \
--configuration Release --no-build \
--collect:"XPlat Code Coverage" \
--results-directory "./coverage/unit/$module_name" \
--settings ./coverlet.runsettings
fi
done

- name: Run Integration Tests
id: integration-tests
continue-on-error: true
env:
ASPNETCORE_ENVIRONMENT: Testing
INTEGRATION_TESTS: true
MEAJUDAAI_DB_PASS: ${{ env.POSTGRES_PASSWORD }}
MEAJUDAAI_DB_USER: ${{ env.POSTGRES_USER }}
MEAJUDAAI_DB: ${{ env.POSTGRES_DB }}
ConnectionStrings__DefaultConnection: ${{ steps.db.outputs.connection-string }}
ConnectionStrings__Users: ${{ steps.db.outputs.connection-string }}
ConnectionStrings__Search: ${{ steps.db.outputs.connection-string }}
ConnectionStrings__meajudaai-db: ${{ steps.db.outputs.connection-string }}
AZURE_STORAGE_CONNECTION_STRING: "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://localhost:10000/devstoreaccount1;"
run: |
echo "🚀 Running Integration Tests (expected duration ~40m)..."
dotnet test tests/MeAjudaAi.Integration.Tests/MeAjudaAi.Integration.Tests.csproj \
--configuration Release --no-build \
--collect:"XPlat Code Coverage" \
--results-directory ./coverage/integration \
--settings ./coverlet.runsettings \
--verbosity normal

- name: Collect and aggregate coverage files
run: |
mkdir -p ./coverage/aggregate
counter=0
# Standard bash loop to find and rename coverage files uniquely
find ./coverage -type f -name "coverage.cobertura.xml" | while read -r file; do
counter=$((counter + 1))
cp "$file" "./coverage/aggregate/coverage_${counter}.cobertura.xml"
echo "✅ Collected: $file as coverage_${counter}.cobertura.xml"
done

if [ -n "$(ls -A ./coverage/aggregate/ 2>/dev/null)" ]; then
echo "✅ All coverage files ready for aggregation."
else
echo "❌ CRITICAL ERROR: No coverage files were generated."
exit 1
fi

- name: Configure DOTNET_ROOT for ReportGenerator
run: |
DOTNET_PATH="$(which dotnet)"
echo "DOTNET_ROOT=$(dirname "$(readlink -f "$DOTNET_PATH")")" >> $GITHUB_ENV

- name: Generate aggregated coverage report
uses: danielpalme/ReportGenerator-GitHub-Action@5
with:
reports: "coverage/aggregate/**/*.cobertura.xml"
targetdir: "coverage/final_report"
reporttypes: "Cobertura;JsonSummary"
assemblyfilters: "+MeAjudaAi.*;-MeAjudaAi.AppHost;-MeAjudaAi.ServiceDefaults"
classfilters: "-*.Tests;-*.Tests.*;-*Test*;-testhost;-*.Migrations.*;-*Program*;-*.Seeding.*;-*.Monitoring.*"

- name: Upload coverage reports
uses: actions/upload-artifact@v4
if: always()
with:
name: coverage-reports
path: coverage/**

- name: Code Coverage Summary
uses: irongut/CodeCoverageSummary@v1.3.0
with:
filename: "coverage/final_report/Cobertura.xml"
badge: true
format: markdown
output: both
thresholds: "90 80" # line branch
fail_below_min: true

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

security-scan:
name: Security Scan
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Setup .NET
uses: actions/setup-dotnet@v5
with:
dotnet-version: "10.0.x"
- name: Run Security Audit
continue-on-error: true
run: |
dotnet list package --vulnerable --include-transitive > security-audit-report.txt
cat security-audit-report.txt
- name: Verify No Critical Direct Vulnerabilities
run: |
# Parse output to find if there are critical vulnerabilities in direct dependencies
# We check the top-level references specifically. A basic scan verifies if "Critical" shows up without being in a Transitive block, or simply checks top-level explicitly.
dotnet list package --vulnerable > direct-security-audit.txt
if grep -qi "Critical" direct-security-audit.txt; then
echo "Critical direct vulnerabilities found!"
cat direct-security-audit.txt
exit 1
fi
echo "No critical vulnerabilities found in direct dependencies."
Loading
Loading