Skip to content

Commit ece993c

Browse files
authored
ci(coverage): enforce 80% line coverage gate + fix Web.Tests missing from solution (#209)
Merges Sprint 1: coverage gate + 72 new tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent daacd82 commit ece993c

13 files changed

Lines changed: 1792 additions & 6 deletions

File tree

.github/workflows/squad-test.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,18 +690,23 @@ jobs:
690690
-reports:"coverage-reports/**/**/coverage.cobertura.xml" \
691691
-targetdir:"./coverage-output" \
692692
-reporttypes:"Html;Cobertura;JsonSummary" \
693+
-filefilters:"-**/obj/**/*.cs;-**/*.generated.cs" \
693694
-verbosity:verbose || echo "::warning::No coverage files found"
694695
695696
- name: Check coverage threshold
696697
run: |
697698
if [ -f "./coverage-output/Summary.json" ]; then
698-
coverage=$(jq -r '.lineCoverage' ./coverage-output/Summary.json 2>/dev/null || echo "0")
699+
echo "=== Summary.json raw ===" && cat ./coverage-output/Summary.json | jq . || true
700+
coverage=$(jq -r '.summary.linecoverage // .lineCoverage // 0' ./coverage-output/Summary.json 2>/dev/null || echo "0")
699701
echo "Line Coverage: $coverage%"
700702
if (( $(echo "$coverage < 80" | bc -l) )); then
701-
echo "::warning::Code coverage is below 80% threshold: $coverage%"
703+
echo "::error::Code coverage is below 80% threshold: $coverage% (required: 80%)"
704+
exit 1
705+
else
706+
echo "::notice::Coverage gate passed: $coverage% >= 80%"
702707
fi
703708
else
704-
echo "::notice::Coverage report not available"
709+
echo "::warning::Coverage report not available — skipping threshold check"
705710
fi
706711
707712
- name: Upload coverage reports

IssueTrackerApp.slnx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,6 @@
1717
<Project Path="tests/Persistence.MongoDb.Tests.Integration/Persistence.MongoDb.Tests.Integration.csproj" />
1818
<Project Path="tests/Web.Tests.Bunit/Web.Tests.Bunit.csproj" />
1919
<Project Path="tests/Web.Tests.Integration/Web.Tests.Integration.csproj" />
20+
<Project Path="tests/Web.Tests/Web.Tests.csproj" />
2021
</Folder>
2122
</Solution>

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ A modern issue tracking application built with .NET Aspire, Blazor, and MongoDB.
1212

1313
[![CodeCov Coverage](https://codecov.io/gh/mpaulosky/IssueTrackerApp/branch/main/graph/badge.svg)](https://codecov.io/gh/mpaulosky/IssueTrackerApp)
1414
[![Coverage Trend](https://img.shields.io/badge/Coverage-Trend-blue?logo=codecov)](https://codecov.io/gh/mpaulosky/IssueTrackerApp/commits/main)
15+
[![Coverage Gate](https://img.shields.io/badge/Coverage%20Gate-≥80%25-brightgreen?logo=codecov)](https://github.com/mpaulosky/IssueTrackerApp/actions/workflows/squad-test.yml)
1516

1617
[![Open Issues](https://img.shields.io/github/issues/mpaulosky/IssueTrackerApp?color=0366d6)](https://github.com/mpaulosky/IssueTrackerApp/issues?q=is%3Aopen+is%3Aissue)
1718
[![Closed Issues](https://img.shields.io/github/issues-closed/mpaulosky/IssueTrackerApp?color=6f42c1)](https://github.com/mpaulosky/IssueTrackerApp/issues?q=is%3Aclosed+is%3Aissue)

src/Web/Data/DataSeeder.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// Project Name : Web
88
// =======================================================
99

10+
using System.Diagnostics.CodeAnalysis;
11+
1012
using Domain.Abstractions;
1113
using Domain.DTOs;
1214
using Domain.Models;
@@ -31,6 +33,7 @@ public interface IDataSeeder
3133
/// <summary>
3234
/// Implementation of IDataSeeder.
3335
/// </summary>
36+
[ExcludeFromCodeCoverage]
3437
public sealed class DataSeeder : IDataSeeder
3538
{
3639
private readonly IRepository<Category> _categoryRepository;
@@ -190,6 +193,7 @@ private async Task SeedStatusesAsync(CancellationToken cancellationToken)
190193
/// <summary>
191194
/// Extension methods for registering the DataSeeder.
192195
/// </summary>
196+
[ExcludeFromCodeCoverage]
193197
public static class DataSeederExtensions
194198
{
195199
/// <summary>

src/Web/Testing/FakeRepository.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
// Project Name : Web
88
// =============================================
99

10+
using System.Diagnostics.CodeAnalysis;
1011
using System.Linq.Expressions;
1112
using System.Reflection;
1213

@@ -18,6 +19,7 @@ namespace Web.Testing;
1819
/// Thread-safe in-memory implementation of <see cref="IRepository{TEntity}"/> used in the
1920
/// Testing environment to provide fast, self-contained E2E test data without a real database.
2021
/// </summary>
22+
[ExcludeFromCodeCoverage]
2123
internal sealed class FakeRepository<TEntity> : IRepository<TEntity> where TEntity : class
2224
{
2325
private readonly List<TEntity> _store;

src/Web/Testing/FakeSeedData.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// Project Name : Web
88
// =============================================
99

10+
using System.Diagnostics.CodeAnalysis;
11+
1012
using Domain.Models;
1113

1214
using MongoDB.Bson;
@@ -17,6 +19,7 @@ namespace Web.Testing;
1719
/// Provides deterministic seed data for the Testing environment in-memory repositories.
1820
/// Hard-coded ObjectIds ensure stable IDs across test runs.
1921
/// </summary>
22+
[ExcludeFromCodeCoverage]
2023
internal static class FakeSeedData
2124
{
2225
// --- Status IDs (deterministic, stable across runs) ---

src/Web/package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)