Skip to content

Add code coverage reporting#23

Merged
colemancda merged 19 commits into
masterfrom
feature/code-coverage
Jul 18, 2026
Merged

Add code coverage reporting#23
colemancda merged 19 commits into
masterfrom
feature/code-coverage

Conversation

@colemancda

@colemancda colemancda commented Jul 18, 2026

Copy link
Copy Markdown
Member

Adds code coverage measurement, reporting, and CI enforcement, and raises package test coverage from 44% to 92.6%.

Coverage infrastructure

  • Scripts/coverage.sh runs the test suite with coverage instrumentation, exports LCOV (coverage.lcov) and Cobertura (coverage.xml) reports scoped to this package's own sources (merged across all test binaries), and fails if total line coverage drops below the threshold.
  • New Code Coverage job in the Swift workflow enforces a 90% threshold and uploads reports to Codecov and GitHub Code Quality, plus attaches them as build artifacts.

New tests (44.5% → 92.6% line coverage)

  • Macro expansion tests for @Entity/@Attribute/@Relationship (CoreModelMacros was previously 0%)
  • Attribute/relationship coding tests for every AttributeValue type, optionals, and error paths (Decodable/Encodable now 100%)
  • Persistent storage tests covering PersistentContainerStorage, batch insert/delete, fetch limit/offset, fetchID/count, typed ModelStorage/ViewContext APIs, and a new AllTypes entity exercising every attribute type through CoreData
  • Predicate tests: Codable round-trips, descriptions, operators, key paths, string comparison helpers
  • In-memory function evaluation tests: predicate stripping, operator evaluation, and function-based sorting

Bugs found and fixed by the new tests

  • @Entity macro emitted ..name (double period) for key-path inverse relationship arguments
  • FetchRequest.toFoundation() ignored fetchOffset

Notes:

  • Codecov upload uses the CODECOV_TOKEN repo secret if configured; CI will not fail without it (fail_ci_if_error: false).
  • GitHub Code Quality must be enabled on the repo/org for the PR coverage comment to appear; the threshold gate runs regardless.

@github-code-quality

Copy link
Copy Markdown

Code Coverage Overview

Languages: Swift

Swift / code-coverage/llvm-cov

The overall coverage in the branch is 96%. Coverage data for the branch is not yet available.

Show a code coverage summary of the most covered files.
File 8a195c6 +/-
Sources/CoreMod...Decodable.swift 100%
Sources/CoreDat...valuation.swift 100%
Sources/CoreMod...os/Entity.swift 100%
Sources/CoreDat...Predicate.swift 100%
Sources/CoreMod...xpression.swift 100%
Sources/CoreMod.../Compound.swift 100%
Sources/CoreDat...Container.swift 98%
Sources/CoreDat...ibuteType.swift 98%
Sources/CoreDat...ctContext.swift 97%
Sources/CoreDat...gedObject.swift 72%

Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@colemancda
colemancda merged commit 2fc6856 into master Jul 18, 2026
32 checks passed
@colemancda
colemancda deleted the feature/code-coverage branch July 18, 2026 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant