Skip to content

Conversation

@nielsenko
Copy link
Collaborator

@nielsenko nielsenko commented Jan 21, 2026

Description

Codecov is reporting incorrect coverage (28%) after the recent mono-repo restructuring, when the actual coverage is above 90%. This PR fixes the Codecov configuration to properly handle the multi-package mono-repo structure.

  • Added ignore paths to exclude non-package directories (examples, benchmark, doc) from coverage calculations.
  • Created new internal test_utils package containing shared test utilities (parameterizedTest, makeSimpleRequest, syncHandler, etc.)
  • Moved tests to their appropriate packages:
    • Handler, message, middleware, and query tests → relic_core
    • Static file serving and WebSocket tests → relic_io
    • Lots of tests still in relic as they are implemented as integration tests (will require a bigger refactor to split)
  • Renamed workflow file from dart-tests.yaml to ci.yaml
  • Split coverage uploads into separate steps per package with proper flags (relic_core, relic_io, relic)
  • Added melos coverage script for local coverage collection

Related Issues

  • Fixes: #?

Pre-Launch Checklist

  • This update focuses on a single feature or bug fix. (For multiple fixes, please submit separate PRs.)
  • I have read and followed the Dart Style Guide and formatted the code using dart format.
  • I have referenced at least one issue this PR fixes or is related to.
  • I have updated/added relevant documentation (doc comments with ///), ensuring consistency with existing project documentation.
  • I have added new tests to verify the changes.
  • All existing and new tests pass successfully.
  • I have documented any breaking changes below.

Breaking Changes

  • Includes breaking changes.
  • No breaking changes.

Additional Notes

The test reorganization moves tests closer to the code they test, improving maintainability and making it clearer which package owns which functionality. The new test_utils package is internal (not published) and provides shared testing infrastructure across all packages.

Summary by CodeRabbit

  • Chores

    • Reorganized shared test utilities into dedicated package for improved maintainability
    • Enhanced CI/CD coverage reporting with per-package tracking
    • Updated development tool dependencies
  • Refactor

    • Restructured internal package imports and test dependencies across test suites

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 21, 2026

📝 Walkthrough

Walkthrough

This pull request extracts test utilities from packages/relic into a new shared packages/test_utils package and updates imports across the monorepo. Additionally, it modernizes CI workflow configuration with per-package Codecov uploads and adds melos-based coverage commands.

Changes

Cohort / File(s) Summary
CI & Workflow Configuration
.github/workflows/ci.yaml, codecov.yml
Replaced dynamic matrix-based runner targeting with fixed ubuntu-latest. Switched coverage execution to melos-based command. Introduced per-package Codecov uploads with explicit file paths and flags for relic_core, relic_io, and relic. Added codecov.yml with paths restrictions to target packages and ignore section excluding examples, benchmarks, and documentation.
Test Utils Package Creation
packages/test_utils/pubspec.yaml, packages/test_utils/lib/test_utils.dart, packages/test_utils/lib/src/test_utils_base.dart
New shared test utilities package with typedef SyncHandler, handlers (createSyncHandler, asyncHandler), request helpers (makeSimpleRequest), test fixtures (localhostUri, isOhNoStateError), and parameterized testing utilities (parameterizedGroup, parameterizedTest, singleTest).
Test Utility Cleanup (relic)
packages/relic/test/util/test_util.dart
Removed 144 lines of public exports including SyncHandler, handler factories, request helpers, fixtures, and parameterized test utilities. Retained only testServe function for server lifecycle testing.
Test Import Updates (relic)
packages/relic/test/adapter/connection_info_test.dart, packages/relic/test/headers/.../*_test.dart, packages/relic/test/message/apply_headers_test.dart, packages/relic/test/path/path_param_test.dart, packages/relic/test/relic_server_*.dart, packages/relic/test/router/router_methods_test.dart
Migrated test imports from local util/test_util.dart to external package:test_utils/test_utils.dart across 12 test files.
Test Import Updates (relic_core)
packages/relic_core/test/handler/cascade_test.dart, packages/relic_core/test/handler/pipeline_test.dart, packages/relic_core/test/message/.../*_test.dart, packages/relic_core/test/middleware_extra/.../*_test.dart, packages/relic_core/test/query/query_param_test.dart
Updated imports from relic.dart to relic_core.dart and replaced relative test util imports with package:test_utils/test_utils.dart across 10 test files.
Test Utilities (relic_io)
packages/relic_io/test/util/test_util.dart
New file re-exporting test utilities from relic_core and adding RelicServerTestEx extension with url getter and testServe helper function for IO-specific server testing.
Test Import Updates (relic_io)
packages/relic_io/test/static/.../*_test.dart, packages/relic_io/test/web_socket/web_socket_test.dart
Updated imports from relic.dart to relic_core.dart and/or relic_io.dart, and added package:test_utils/test_utils.dart imports across 19 test files.
Dependency Updates
packages/relic/pubspec.yaml, packages/relic_core/pubspec.yaml, packages/relic_io/pubspec.yaml
Updated lints to ^6.0.0 and mime to ^2.0.0; added test_utils as dev_dependency with path reference.
Root Configuration
pubspec.yaml
Added benchmark, examples, and test_utils to workspace packages. Introduced melos coverage script with branch coverage and scope options for relic, relic_core, and relic_io packages.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: configuring Codecov for a mono-repo structure, which is the primary objective of this PR.
Description check ✅ Passed The PR description provides detailed context about the Codecov issue, lists all major changes including test reorganization and configuration updates, and addresses most checklist items. However, it lacks a reference to a specific issue number despite checking the box for related issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Jan 21, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.18%. Comparing base (196eef7) to head (50ae39f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #318       +/-   ##
===========================================
+ Coverage   27.95%   91.18%   +63.23%     
===========================================
  Files          87       97       +10     
  Lines        3291     3723      +432     
  Branches     1735     1905      +170     
===========================================
+ Hits          920     3395     +2475     
+ Misses       2371      328     -2043     
Flag Coverage Δ
relic_core 90.91% <ø> (?)
relic_io 93.27% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Add ignore paths for examples, benchmark, and doc directories
- Split coverage upload into separate steps with flags for each package
- Associate each lcov.info file with its corresponding package flag
@nielsenko nielsenko self-assigned this Jan 23, 2026
@nielsenko
Copy link
Collaborator Author

@CodeRabbit review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/ci.yaml (1)

151-179: Coverage steps should not be gated by cancellation and need explicit timeouts.
The new && !cancelled() conditions and missing timeout-minutes conflict with the requirement that coverage steps run to completion with specified timeouts.

✅ Suggested adjustment
       - name: Run Tests With Coverage
         if: ${{ matrix.os == 'ubuntu-latest' && matrix.dart_sdk == '3.8.1' && matrix.deps == 'upgrade' }}
+        timeout-minutes: 30
         run: |
           dart pub global activate coverage
           melos run coverage --no-select

       - name: Upload Coverage (relic_core)
         uses: codecov/codecov-action@v5
-        if: ${{ matrix.os == 'ubuntu-latest' && matrix.dart_sdk == '3.8.1' && matrix.deps == 'upgrade' && !cancelled() }}
+        if: ${{ matrix.os == 'ubuntu-latest' && matrix.dart_sdk == '3.8.1' && matrix.deps == 'upgrade' }}
+        timeout-minutes: 10
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
           files: packages/relic_core/coverage/lcov.info
           flags: relic_core

       - name: Upload Coverage (relic_io)
         uses: codecov/codecov-action@v5
-        if: ${{ matrix.os == 'ubuntu-latest' && matrix.dart_sdk == '3.8.1' && matrix.deps == 'upgrade' && !cancelled() }}
+        if: ${{ matrix.os == 'ubuntu-latest' && matrix.dart_sdk == '3.8.1' && matrix.deps == 'upgrade' }}
+        timeout-minutes: 10
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
           files: packages/relic_io/coverage/lcov.info
           flags: relic_io

       - name: Upload Coverage (relic)
         uses: codecov/codecov-action@v5
-        if: ${{ matrix.os == 'ubuntu-latest' && matrix.dart_sdk == '3.8.1' && matrix.deps == 'upgrade' && !cancelled() }}
+        if: ${{ matrix.os == 'ubuntu-latest' && matrix.dart_sdk == '3.8.1' && matrix.deps == 'upgrade' }}
+        timeout-minutes: 10
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
           files: packages/relic/coverage/lcov.info
           flags: relic

As per coding guidelines, coverage steps must run to completion with explicit timeouts.

🤖 Fix all issues with AI agents
In `@packages/relic_io/test/util/test_util.dart`:
- Around line 6-7: The export in packages/relic_io/test/util/test_util.dart is
self-referential; update the export statement so it re-exports the intended
external utilities (not itself) — replace the current "../util/test_util.dart"
export with the correct package export (for example
"package:test_utils/test_util.dart" or the appropriate package that actually
contains the shared test utilities) so the file re-exports the external
utilities rather than itself.
🧹 Nitpick comments (2)
pubspec.yaml (1)

52-52: Consider using dart run instead of deprecated dart pub run.

dart pub run has been deprecated in favor of dart run. While it still works, updating to the modern syntax is recommended.

Suggested change
-        - dart pub run melos run test
+        - dart run melos run test
packages/test_utils/lib/src/test_utils_base.dart (1)

137-145: actual is evaluated at test definition time, not execution time.

In singleTest, the actual parameter is evaluated when the test is defined, not when it runs. This could lead to unexpected behavior if callers expect lazy evaluation (e.g., singleTest('test', computeValue(), expected) computes immediately).

If this is intentional for simple constant checks, consider documenting this behavior. Otherwise, consider accepting a callback:

Alternative with lazy evaluation
 `@isTest`
 void singleTest(
   final String description,
-  final dynamic actual,
+  final dynamic Function() actual,
   final dynamic expected,
 ) {
   test(description, () {
-    expect(actual, expected);
+    expect(actual(), expected);
   });
 }

Usage would change to: singleTest('test', () => computeValue(), expected)

@nielsenko nielsenko mentioned this pull request Jan 23, 2026
1 task
Copy link
Collaborator

@marcelomendoncasoares marcelomendoncasoares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@nielsenko nielsenko merged commit 2ba9392 into serverpod:main Jan 26, 2026
57 of 58 checks passed
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.

2 participants