name: Inventory Service CI on: push: paths: - 'services/inventory-service-net/**' pull_request: paths: - 'services/inventory-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/inventory-service-net/src/InventoryService.API/InventoryService.API.csproj - name: Build API project run: dotnet build services/inventory-service-net/src/InventoryService.API/InventoryService.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/inventory-service-net InventoryService.API - name: Upload OpenAPI spec artifact uses: actions/upload-artifact@v4 with: name: openapi-inventoryservice-api path: services/inventory-service-net/openapi.yaml if-no-files-found: warn - name: Restore test projects run: | dotnet restore services/inventory-service-net/tests/InventoryService.UnitTests/InventoryService.UnitTests.csproj dotnet restore services/inventory-service-net/tests/InventoryService.FunctionalTests/InventoryService.FunctionalTests.csproj - name: Run unit tests with coverage run: > dotnet test services/inventory-service-net/tests/InventoryService.UnitTests/InventoryService.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/inventory-service-net/tests/InventoryService.FunctionalTests/InventoryService.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: inventory_service_net fail_ci_if_error: false env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}