Skip to content

ci: Add test coverage - #36

Merged
nielsenko merged 4 commits into
serverpod:mainfrom
nielsenko:ci-tweaks
Mar 14, 2025
Merged

nielsenko merged 4 commits into
serverpod:mainfrom
nielsenko:ci-tweaks

Conversation

@nielsenko

@nielsenko nielsenko commented Mar 13, 2025 •

Copy link
Copy Markdown
Collaborator

Add test coverage reporting to track code execution during tests and identify
untested areas. Implement additional quality checks:

  • Publish dry-run to verify package meets publishing requirements
  • Pana score analysis to evaluate package quality and documentation
  • Dependency bounds checking to ensure proper version constraints

Summary by CodeRabbit

  • New Features

    • Introduced a consolidated build process that verifies dependency integrity, formatting, analysis, and performs a publishing dry run.
    • Expanded testing with enhanced support across multiple Dart SDK versions.
  • Chores

    • Updated dependency versions and incorporated new packages to optimize package management.

@coderabbitai

coderabbitai Bot commented Mar 13, 2025 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.
📝 Walkthrough

Walkthrough

The CI workflow for Dart projects has been restructured in the workflow file. Multiple jobs, including formatting and analysis steps, have been consolidated into a single build job that handles building, formatting checks, dependency upgrades, and analysis. Additional checks for the PANA score, a dry run of publishing, and test coverage have been added. The unit_tests job has been modified to depend on the build job and now includes a broader matrix for Dart SDK versions. Dependency versions in pubspec.yaml have also been updated, and new dependencies have been introduced.

Changes

File Change Summary
.github/.../dart-tests.yaml Removed jobs: dart_format, dart_analyze, dart_analyze_downgrade, dart_analyze_latest_downgrade; Added job: build (combines formatting, analysis, and build checks); Modified unit_tests to depend on build and updated dependency command to use a matrix for deps.
pubspec.yaml Updated SDK version format; Updated dependencies: path: ^1.8.2 to path: ^1.8.3, test: ^1.24.2 to test: ^1.25.0; Added new dependencies: file: ^7.0.0, frontend_server_client: ^4.0.0, pub_semver: ^2.1.4, watcher: ^1.1.0.

Sequence Diagram(s)

sequenceDiagram
    participant Dev as Developer
    participant CI as CI Workflow
    participant Build as Build Job
    participant Tests as Unit Tests

    Dev->>CI: Push code commit
    CI->>Build: Trigger build job (build, formatting, analysis, dependency upgrade)
    Build-->>CI: Return build and analysis results
    CI->>Tests: Trigger unit tests (depends on build)
    Tests-->>CI: Return test results and coverage
Loading

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@nielsenko

Copy link
Copy Markdown
Collaborator Author

@coderabbitai pause

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
.github/workflows/dart-tests.yaml (4)

24-27: Review Checkout Action Version (Build Job)
The Checkout Code step uses actions/checkout@v3. Static analysis suggests that this version may be outdated. Consider updating to a more recent version (for example, actions/checkout@v4 if available) to benefit from the latest improvements and bug fixes.

🧰 Tools
🪛 actionlint (1.7.4)

25-25: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


31-38: Review Cache Action Version (Build Job)
The cache step employs actions/cache@v3, which the static analysis indicates might be outdated. An update to the latest version (e.g. actions/cache@v4 if offered) could improve performance and compatibility. The cache key configuration appears sound.

🧰 Tools
🪛 actionlint (1.7.4)

32-32: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


75-81: Review Checkout Action Version (Unit Tests Job)
The checkout step in the unit_tests job again uses actions/checkout@v3. As noted earlier, consider updating this action to a newer version to leverage recent improvements and to mitigate potential issues identified by static analysis.

🧰 Tools
🪛 actionlint (1.7.4)

76-76: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


82-89: Review Cache Action Version (Unit Tests Job)
The caching mechanism for dependencies in the unit_tests job uses actions/cache@v3. Similar to the build job, updating to a newer version (e.g. actions/cache@v4 if available) is recommended to ensure optimal performance and compatibility.

🧰 Tools
🪛 actionlint (1.7.4)

83-83: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6abdcc4 and d2ebacf.

📒 Files selected for processing (1)
  • .github/workflows/dart-tests.yaml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/dart-tests.yaml

25-25: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


32-32: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


76-76: the runner of "actions/checkout@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


83-83: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (9)
.github/workflows/dart-tests.yaml (9)

3-10: CI Trigger Configuration Updated
The configuration now explicitly restricts triggers to the main branch, adds a scheduled run every Sunday at 00:00 UTC, and includes a manual trigger. This consolidated trigger setup is clear and should help manage when the CI runs.


16-23: Consolidated Build Job with Matrix Strategy
The new build job combines tasks for formatting, dependency upgrades/downgrades, analysis, PANA score checking, a dry publish run, and coverage generation. The matrix has been simplified to use only ubuntu-latest and supports two Dart SDK configurations. Verify that the mixed usage of "3.3.0" and stable in the dart_sdk matrix works as intended in your environment.


42-46: Dependency Upgrade and Analysis Step
This step upgrades dependencies and then runs static analysis with --fatal-infos. Combining the two commands with && ensures the analysis is performed only if the upgrade succeeds. This approach is concise and effective for catching issues immediately.


47-51: Dependency Downgrade and Analysis Step
The downgrade step verifies that the project remains analyzable when dependencies are rolled back. The use of && ensures proper sequential execution. This is a useful addition for validating compatibility with previous dependency versions.


52-57: PANA Score Check Step
The step activates and runs PANA with specific flags. Please ensure that the environment has jq installed (or is otherwise configured) since its output is used to pass the Flutter SDK path. Also, verify that flutter --no-version-check --version --machine executes reliably in your CI environment.


58-60: Publish Dry Run Step
The dry run for publishing (dart pub publish --dry-run) is a safe addition to ensure that any potential issues with the package publishing process are identified before an actual publish.


61-65: Test Coverage Generation Step
Activating the coverage package and running test coverage with branch and function metrics is a valuable addition to monitor code quality over time. The command chaining is clear and effective.


66-74: Unit Tests Job Dependency and Matrix Update
The unit_tests job now depends on the build job, ensuring tests run only after a successful build. The matrix includes multiple OS options and a single Dart SDK version. This dependency structure should improve overall CI reliability by preventing tests from running when the build fails.


90-92: Optimized Offline Dependency Installation
Using dart pub get --offline in the unit tests job is a good optimization that speeds up dependency installation when relying on cached packages. Just ensure that the cache is reliably populated to prevent potential failures.

@coderabbitai

coderabbitai Bot commented Mar 13, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Reviews paused.

@codecov-commenter

codecov-commenter commented Mar 13, 2025 •

Copy link
Copy Markdown

Welcome to Codecov 🎉

Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests.

Thanks for integrating Codecov - We've got you covered ☂️

@nielsenko
nielsenko force-pushed the ci-tweaks branch 3 times, most recently from 5799754 to bad743a Compare March 13, 2025 14:20
@nielsenko nielsenko changed the title ci: Add coverage, PANA check, and publish dry run. Use less runners. ci: Add test coverage Mar 13, 2025
@nielsenko
nielsenko force-pushed the ci-tweaks branch 13 times, most recently from 845929c to c390d2c Compare March 14, 2025 08:28
@nielsenko

Copy link
Copy Markdown
Collaborator Author

@coderabbitai summary

@coderabbitai

coderabbitai Bot commented Mar 14, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Summary regeneration triggered.

@nielsenko

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full

@coderabbitai

coderabbitai Bot commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

@nielsenko I'll perform a full review of all the changes in your PR that adds coverage, PANA check, and publish dry run while optimizing runner usage.

✅ Actions performed

Full review triggered.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (4)
.github/workflows/dart-tests.yaml (4)

16-23: Consolidated Build Job Configuration
The new build job is well structured. The matrix is limited to ubuntu-latest and Dart SDK versions [ "3.3.0", stable ]. Verify that unquoted values such as stable are interpreted as strings consistently across YAML parsers.


31-37: Cache Action Version Update
The workflow uses actions/cache@v3 for caching Dart dependencies. Static analysis hints recommend updating this action version since the runner for v3 is outdated. If a newer stable version (such as v4) is available, consider updating the version. For example:

- uses: actions/cache@v3
+ uses: actions/cache@v4
🧰 Tools
🪛 actionlint (1.7.4)

32-32: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


38-41: Conditional Formatting Check
The "Verify Formatting" step runs only if ${{ matrix.dart_sdk != 'stable' }}. Please clarify the rationale behind excluding the stable SDK from formatting checks. If there’s a specific reason (e.g., differences in formatting behavior), consider adding a comment for future maintainers.


80-86: Cache Action Version in Unit Tests
Similar to the build job, the unit tests job uses actions/cache@v3. Consider updating this to a newer version for consistency and to resolve the previously mentioned runner issues.

- uses: actions/cache@v3
+ uses: actions/cache@v4
🧰 Tools
🪛 actionlint (1.7.4)

81-81: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6abdcc4 and c390d2c.

📒 Files selected for processing (2)
  • .github/workflows/dart-tests.yaml (1 hunks)
  • pubspec.yaml (1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.4)
.github/workflows/dart-tests.yaml

32-32: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)


81-81: the runner of "actions/cache@v3" action is too old to run on GitHub Actions. update the action's version to fix this issue

(action)

🔇 Additional comments (12)
pubspec.yaml (4)

7-8: Consistent Environment SDK Declaration
The SDK version has been updated and now uses double quotes. This improves consistency and readability.


13-13: Dependency Version Update for path
The version for the path dependency has been updated to ^1.8.3. Please ensure that this version is compatible with the rest of the codebase.


21-22: Update Dev Dependency Versions
The http and test dev dependencies have been updated (and reformatted with double quotes). This keeps dependency versions aligned with the CI requirements.


25-31: New Transitively Included Dependencies
New dependencies (file, frontend_server_client, pub_semver, and watcher) have been added with explanatory comments regarding semver hygiene. Ensure that these bounds address any known issues, and consider documenting their purpose in your project’s README if appropriate.

.github/workflows/dart-tests.yaml (8)

1-2: Workflow Naming and Trigger Configuration
The workflow is now named "Relic Ci", and the trigger conditions (push, pull_request, schedule, and manual dispatch) are clearly defined. Nice consolidation!


42-48: Dependency Bounds Check Logic
The "Check Dependency Bounds" step is conditional on the Dart SDK not being 3.3.0 (with a comment about --tighten availability from 3.5). Ensure that this condition is correct and well-documented, as it directly affects dependency resolution.


49-59: Analysis and Pana Score Steps
The steps for analyzing the project (dart pub get and dart analyze --fatal-infos) and checking the Pana score look good. The Pana score is only checked when using the stable SDK. This differentiation is sensible if Pana’s behavior varies across SDK versions.


60-62: Publish Dry Run Implementation
The "Publish Dry Run" step running dart pub publish --dry-run is a great addition for pre-deployment validation.


63-72: Unit Tests Job Matrix Configuration
The unit_tests job now depends on the build job and includes an expanded matrix covering multiple OSes and Dart SDK versions (3.3.0, stable, and beta) as well as dependency commands (downgrade and upgrade). This provides broader test coverage and is a good design decision.


87-91: Installation of Dependencies
The step “Install Dependencies (${{ matrix.deps }})” correctly executes dart pub with the respective dependency command followed by dart pub get. This ensures that both downgrade and upgrade commands are tested.


92-97: Running Tests with Coverage
The step “Run Tests With Coverage” conditionally continues on error for non-stable SDKs. This is an interesting approach to allow failures in experimental environments while ensuring stability in production. Confirm that this behavior is intentional.


98-102: Coverage Upload via Codecov
Using codecov/codecov-action@v5 to upload the coverage results is properly set up. As long as the secret CODECOV_TOKEN is maintained securely, this step should work as expected.

Add test coverage reporting to track code execution during tests and identify
untested areas. Implement additional quality checks:

- Publish dry-run to verify package meets publishing requirements
- Pana score analysis to evaluate package quality and documentation
- Dependency bounds checking to ensure proper version constraints
@nielsenko

Copy link
Copy Markdown
Collaborator Author

@coderabbitai configuration

@nielsenko

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Mar 14, 2025

Copy link
Copy Markdown
Contributor
✅ 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.

@nielsenko

Copy link
Copy Markdown
Collaborator Author

@coderabbitai full

@coderabbitai

coderabbitai Bot commented Mar 14, 2025

Copy link
Copy Markdown
Contributor

Tip

For best results, initiate chat on the files or code changes.

@nielsenko I notice that you've already requested a full review in a previous comment, and I've already triggered that process. Would you like me to initiate another full review of your PR that adds test coverage? If so, please confirm and I'll start the process again.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
.github/workflows/dart-tests.yaml (2)

38-42: Conditional Formatting Check
The "Verify Formatting" step conditionally skips formatting for the stable channel, addressing the noted differences in Dart stable (3.7.2). Consider correcting the typo "formating" to "formatting" in the comment for clarity.


70-73: Unit Tests Job Matrix Configuration
The unit tests matrix expands testing coverage across multiple OS environments and Dart SDK versions ("3.3.0", stable, and beta) with dependency scenarios (downgrade and upgrade). For clarity and consistency, consider quoting stable and beta.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c390d2c and 1b98b47.

📒 Files selected for processing (2)
  • .github/workflows/dart-tests.yaml (1 hunks)
  • pubspec.yaml (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • pubspec.yaml
🔇 Additional comments (14)
.github/workflows/dart-tests.yaml (14)

1-1: Project Name Setup
The workflow name "Relic Ci" is clear. Ensure that it aligns with any naming conventions you may have within the repository.


3-11: Workflow Trigger Configuration
The triggers are well defined: push and pull_request on the main branch, scheduled execution (every Sunday at 00:00 UTC), and manual dispatch. This setup provides good flexibility in triggering the CI.


16-23: Build Job Matrix Definition
The build job matrix is configured with os: [ubuntu-latest] and dart_sdk: ["3.3.0", stable]. Please verify that the unquoted stable value is correctly interpreted as a string in this context.


24-25: Code Checkout Update
Using actions/checkout@v4 is a current best practice and should help ensure reliable code retrieval.


31-37: Caching Dart Dependencies
The caching step uses actions/cache@v4 with clearly defined key and restore-keys. This should efficiently speed up subsequent builds by reusing previously cached dependencies.


44-50: Dependency Bounds Check
The step to check dependency bounds uses dart pub downgrade --tighten and dart pub upgrade --major-versions, but only runs when the Dart SDK isn’t "3.3.0" (as tightening is available from 3.5). Ensure that this condition aligns with your dependency management strategy.


51-55: Analysis Step
The combined execution of dart pub get and dart analyze --fatal-infos is straightforward and effective for catching issues early.


56-61: Pana Score Check
Running the PANA score check only on the stable channel is a smart decision to keep the analysis focused where it matters most.


62-63: Publish Dry Run Verification
Executing a publish dry run is a prudent step before actual publishing, ensuring that the package meets the necessary criteria without risk.


65-67: Unit Tests Job Dependency
The unit_tests job correctly depends on the successful completion of the build job (via needs: build), ensuring a proper sequence in the CI pipeline.


82-88: Unit Tests Caching Step
Caching of Dart dependencies is implemented similarly as in the build job, which helps reduce redundant downloads and speeds up the test execution.


89-93: Installing Dependencies Based on Matrix
The command using dart pub ${{ matrix.deps }} && dart pub get efficiently tests different dependency handling scenarios. This approach provides versatile testing of dependency resolution.


94-99: Test Coverage Execution
The "Run Tests With Coverage" step activates the coverage package and runs tests with branch coverage. The continue-on-error flag for non-stable Dart SDK versions is a pragmatic choice to prevent failures in experimental setups. Verify that this aligns with your overall test reliability goals.


100-104: Codecov Upload Integration
Uploading the coverage report with the Codecov action is correctly configured. Utilizing a secret token is a best practice for secure integrations.

@nielsenko

Copy link
Copy Markdown
Collaborator Author

@coderabbitai resolve

@nielsenko
nielsenko requested a review from SandPod March 14, 2025 08:51
@coderabbitai

coderabbitai Bot commented Mar 14, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Comments resolved.

Comment thread pubspec.yaml
Comment on lines +26 to +31
# Due to bad semver hygiene we need to bound the versions higher than
# our direct dependencies indicate.
file: ^7.0.0
frontend_server_client: ^4.0.0
pub_semver: ^2.1.4
watcher: ^1.1.0

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

As we are now actually testing on the lower-bounds as well, we need to accommodate for other packages bad semver hygiene.

To be honest it is very easy mistake to make in Dart, as just adding a new methods on a class is a breaking change (since someone might implement the class).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Notice that these are only dev-dependencies needed to make the test pass, but that they may impact the minimal lower bound.

Happened for path actually, which was bumped to ^1.8.3 as a result.

os: [windows-latest, ubuntu-latest, macos-latest]
dart_sdk: ['3.3.0']
dart_sdk: ["3.3.0", stable, beta]
deps: [downgrade, upgrade]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We now also test with downgraded dependencies.

Obviously there are many valid combinations in between, but testing the lower bound often reveals issues.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: Theoretically, If dart releases a bad version into beta this will prevent us from merging PRs. Do we see this as highly unlikely or should we exclude the beta from a required pass?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Perhaps we should have the same thinking with Stable. If Dart releases a new version we are not compatible with that should not block our PR flow. It could be a job we run in main.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Okay. Only lowest sdk (ie. 3.3.0) will break the build.

Comment on lines +44 to +49
- name: Check Dependency Bounds
if: ${{ matrix.dart_sdk != '3.3.0' }} # --tighten available from 3.5
run: >-
dart pub downgrade --tighten &&
dart pub upgrade --major-versions &&
git diff-files --quiet

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This helps us catch if dependencies are released in new major versions, and to see if our lower constraints are artificially low.

Comment thread .github/workflows/dart-tests.yaml Outdated

unit_tests:
name: Run Unit Tests
needs: build

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Since I spawning an awful lot of runners in this job, I make sure only to do it if the fast and simply build job completes. For the sake of the planet and all..

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, Don't we want as much information as possible in one run in the CI pipe? Seems like these could be broken for different reasons (for example som fatal info), but the feedback is still valuable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The first job is fast.

Also, to be honest my plan is to make sure caches are primed even more in this job, so that the latter job can benefit. Doing that mandates the needs to ensure the caches are actually primed.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The first job is fast.

True, but pushing a new commit only to discover that there is a failure in the unit tests that was not caught is slow.

I think we should optimize developer time here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll drop needs:

@nielsenko
nielsenko requested a review from Isakdl March 14, 2025 09:23
Comment thread pubspec.yaml
collection: ^1.17.1
http_parser: ^4.0.2
path: ^1.8.2
path: ^1.8.3

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Bumped due to Check Dependency Bounds

Comment thread .github/workflows/dart-tests.yaml Resolved

@SandPod SandPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Neat cleanup! 👍

I have a couple of questions!

Comment on lines +44 to +49
- name: Check Dependency Bounds
if: ${{ matrix.dart_sdk != '3.3.0' }} # --tighten available from 3.5
run: >-
dart pub downgrade --tighten &&
dart pub upgrade --major-versions &&
git diff-files --quiet

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: Don't we need to run an analyze after both the downgrade and the upgrade to catch if there are any issues with the dependencies?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I decided not to, but I can definitely add it back.

Analysis is only looking at our code, not the dependencies, and as such it should not be impacted by upgrade/downgrade as far as I can tell.

As long as we can resolve the constraints in both cases.

However, running the actual tests will often reveal that the constraints are not correct.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think a breaking change in the API of a dependency will not be visible when running the constraints checks. We might still be able to resolve the dependency, but we are using it in an invalid way.

And since unit tests run in isolation, we would only detect it if we have 100% code coverage for all paths in our code which is an assumption I don't think we should have.

So the analyzer would be needed to catch these.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll add it back, but I'm not sure why you think the analyzer will catch this situation?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The analyzer reports invalid dart code right?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Implicit yes, but so does the compiler running before the test. The analyzer is for stuff that compiles, but is still problematic.

Comment thread .github/workflows/dart-tests.yaml Outdated

unit_tests:
name: Run Unit Tests
needs: build

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hmm, Don't we want as much information as possible in one run in the CI pipe? Seems like these could be broken for different reasons (for example som fatal info), but the feedback is still valuable?

Comment thread .github/workflows/dart-tests.yaml Resolved
os: [windows-latest, ubuntu-latest, macos-latest]
dart_sdk: ['3.3.0']
dart_sdk: ["3.3.0", stable, beta]
deps: [downgrade, upgrade]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: Theoretically, If dart releases a bad version into beta this will prevent us from merging PRs. Do we see this as highly unlikely or should we exclude the beta from a required pass?

Comment on lines +100 to +104
- name: Upload Coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: coverage/lcov.info

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: Does codecov publish the report as part of the PR in some way?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yes, it will be available from the PR, once we have a baseline.

You can also drill into the step and find an url already

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

BTW. Not sure why I cannot reply to the question just above:

Question: Theoretically, If dart releases a bad version into beta this will prevent us from merging PRs. Do we see this as highly unlikely or should we exclude the beta from a required pass?

We don't block on a failure on beta, only on stable.

continue-on-error: ${{ matrix.dart_sdk != 'stable' }}

jobs:
dart_format:
name: Verify Dart Formatting
build:

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Discussion: I'm not sure I think it is a good idea to combine all of these different validations into the same job. You are then required to go into the logs to understand what failed specifically. Especially formatting is very nice to run in isolation as that is as simple as just running the formatter locally, I will basically never have to view the specific error.

On top of that for the analyzer, the reason we run all the OSes is that we previously have had bugs that only propagated on windows, where we fucked up the imports path in the generated code. Since none of us at the office is running Windows, the only way we will discover problems is from users after a release. Hence I think it is important that we run the analyzer for at least one of the scenarios on all OSes.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Disregard the comment on generated code, I thought this was the serverpod repo, not relic.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

A job will require a runner, which you will have to wait for, and it has a certain startup time.

I prefer to keep things as steps unless there is a clear benefit to running stuff in parallel.

I would like to know more about how the analyzer would come to different conclusions on windows. The reason to run only on linux is that I didn't deem that possible.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I really think we should optimize developer roundtrip time here. Pushing a change only to resolve one step and having to wait for the CI pipe again is a pretty slow developer experience. we want to give as much information in one go as possible.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I'll drop the needs:. Still interested in the windows vs linux analyzer result (for my education)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Windows - that was an issue in combination with the code generator. We accidentally generated platform specific import paths which was not good... 🙃

matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
dart_sdk: ['3.3.0']
dart_sdk: ["3.3.0", stable, beta]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Comment: I think it makes sense to test against beta every now and then, but I'm not sure we should do that in general PRs as the Dart team could have introduced breaking changes which will then block unrelated changes from being merged.

I do think it makes sense to run against beta on a scheduled runner so we get notified if the upcoming release is incompatible, but that should probably also be combined with a slack notification if the job fails!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Notice the continue-on-error: ${{ matrix.dart_sdk != 'stable' }}. I think it is nice to get a heads-up on upcoming issues like this

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What happens if we fail with a continue-on-error? How are you notified that it failed? Or is the job marked as successfull anyways and you need to read the logs to understand if it failed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The job still fails (red cross), it just doesn't break the pipeline. It will be very visible when you are about to merge.

Comment on lines +97 to +98
dart pub global activate coverage &&
dart pub global run coverage:test_with_coverage --branch-coverage

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Question: Couldn't this be run with the integration testst too?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

For the integration tests you run the test-suite as above, but also make sure the server is started in a similar way, so you can catch coverage from both client and server.

I cannot recall how to do it of the top of my head, but as I recall coverage:test_with_coverage can be split into multiple steps, and for the server-side you would need some of those.

@nielsenko
nielsenko force-pushed the ci-tweaks branch 3 times, most recently from 4c5c0ec to acf19ed Compare March 14, 2025 12:55

@SandPod SandPod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM! 👍

I still think it might be better to have more pipes running in parallel to mininize number of roundtrips through the CI. But we could break that out if it becomes an issue.

jobs:
dart_format:
name: Verify Dart Formatting
build:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Windows - that was an issue in combination with the code generator. We accidentally generated platform specific import paths which was not good... 🙃

Comment on lines +44 to +49
- name: Check Dependency Bounds
if: ${{ matrix.dart_sdk != '3.3.0' }} # --tighten available from 3.5
run: >-
dart pub downgrade --tighten &&
dart pub upgrade --major-versions &&
git diff-files --quiet

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The analyzer reports invalid dart code right?

@nielsenko
nielsenko merged commit 39deca6 into serverpod:main Mar 14, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Aug 28, 2025
5 of 9 tasks
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.

4 participants