Files
pos-system/.github/workflows/ci-mkt-x-service.yml
Ho Ngoc Hai a8edfd1597 fix(p2): Wave 3 — fix 4 P2 backend architecture issues (TEC-261)
BACK-I-01: Add CI steps to generate openapi.yaml for all 24 .NET services
- Add .config/dotnet-tools.json with swashbuckle.aspnetcore.cli 7.2.0
- Add scripts/ci/generate-openapi.sh reusable script
- Update all 24 service CI workflows with dotnet tool restore + swagger tofile + artifact upload

BACK-I-02: Add OpenTelemetry Metrics + Prometheus /metrics to _template_dot_net
- Add OTel packages (Extensions.Hosting, Instrumentation.AspNetCore, Runtime, Prometheus)
- Register AddOpenTelemetry().WithMetrics() with ASPNetCore + Runtime instrumentation
- Map MapPrometheusScrapingEndpoint("/metrics") in middleware pipeline

BACK-W-01: Remove IHttpContextAccessor from all 18 handler files in merchant-service-net
- Create MerchantBaseController abstract base with GetCurrentUserId() helper
- Add Guid UserId to 11 Commands and 7 Queries
- Remove IHttpContextAccessor injection from all handlers, use request.UserId instead
- Update 7 controllers to inherit MerchantBaseController and extract userId from JWT claims
- Remove AddHttpContextAccessor() registration from Program.cs

BACK-W-03: Add explicit commandTimeout:5 to all Dapper queries in order-service-net
- 14 files updated: QueryAsync, ExecuteScalarAsync, QueryFirstOrDefaultAsync all get commandTimeout: 5

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-03-23 10:09:45 +07:00

87 lines
2.8 KiB
YAML

name: X Marketing Service CI
on:
push:
paths:
- 'services/mkt-x-service-net/**'
pull_request:
paths:
- 'services/mkt-x-service-net/**'
permissions:
contents: read
jobs:
build-and-test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:16-alpine
env:
POSTGRES_USER: testuser
POSTGRES_PASSWORD: testpass
POSTGRES_DB: test_db
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- uses: actions/checkout@v4
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.0.x'
- name: Restore API project
run: dotnet restore services/mkt-x-service-net/src/MktXService.API/MktXService.API.csproj
- name: Build API project
run: dotnet build services/mkt-x-service-net/src/MktXService.API/MktXService.API.csproj --configuration Release --no-restore
- name: Restore dotnet tools
run: dotnet tool restore
- name: Generate OpenAPI spec
run: bash scripts/ci/generate-openapi.sh services/mkt-x-service-net MktXService.API
- name: Upload OpenAPI spec artifact
uses: actions/upload-artifact@v4
with:
name: openapi-mktxservice-api
path: services/mkt-x-service-net/openapi.yaml
if-no-files-found: warn
- name: Restore test projects
run: |
dotnet restore services/mkt-x-service-net/tests/MktXService.UnitTests/MktXService.UnitTests.csproj
dotnet restore services/mkt-x-service-net/tests/MktXService.FunctionalTests/MktXService.FunctionalTests.csproj
- name: Run unit tests with coverage
run: >
dotnet test services/mkt-x-service-net/tests/MktXService.UnitTests/MktXService.UnitTests.csproj
--configuration Release --no-restore --verbosity normal
--collect:"XPlat Code Coverage"
--settings coverage.runsettings
--results-directory TestResults/unit
- name: Run functional tests
run: dotnet test services/mkt-x-service-net/tests/MktXService.FunctionalTests/MktXService.FunctionalTests.csproj --configuration Release --no-restore --verbosity normal
env:
ConnectionStrings__DefaultConnection: Host=localhost;Port=5432;Database=test_db;Username=testuser;Password=testpass
ASPNETCORE_ENVIRONMENT: Testing
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
with:
files: TestResults/unit/**/coverage.cobertura.xml
flags: mkt_x_service_net
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}