Skip to content

test: add coverage and review tooling#1

Closed
Pro777 wants to merge 2 commits into
mainfrom
rowan/coderabbit-codecov
Closed

test: add coverage and review tooling#1
Pro777 wants to merge 2 commits into
mainfrom
rowan/coderabbit-codecov

Conversation

@Pro777
Copy link
Copy Markdown

@Pro777 Pro777 commented May 18, 2026

Summary

  • add real Go model tests and focused Flutter tests
  • wire CI, Codecov, and CodeRabbit for the fork
  • replace placeholder tests with coverage-bearing checks

Verification

  • go test -covermode=atomic -coverprofile=coverage.out ./internal/model/...
  • go vet ./internal/model/...
  • staticcheck ./internal/model/...
  • flutter analyze lib/model/expression_data.dart lib/util/mac_address_validator.dart test/model/expression_data_test.dart test/util/mac_address_validator_test.dart
  • flutter test test/model/expression_data_test.dart test/util/mac_address_validator_test.dart

Summary by CodeRabbit

  • Tests

    • Added comprehensive unit and widget tests covering serialization, validation, MAC handling, motion/dance data, and WebSocket client behavior; removed an obsolete widget smoke test and one empty server test.
  • Chores

    • Added CI workflow with language-specific checks and coverage upload.
    • Updated automated code-review configuration and coverage reporting rules.
    • Expanded ignore rules for local/IDE and build artifacts.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 18, 2026

Warning

Ignoring CodeRabbit configuration file changes. For security, only the configuration from the base branch is applied for open source repositories.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c8e2dbb9-1f43-43d5-aa4c-442446d28d91

📥 Commits

Reviewing files that changed from the base of the PR and between bf8412c and 3fa479c.

📒 Files selected for processing (3)
  • .coderabbit.yaml
  • .github/workflows/ci.yml
  • server/internal/model/web_socket_model_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • .github/workflows/ci.yml
  • .coderabbit.yaml
  • server/internal/model/web_socket_model_test.go

📝 Walkthrough

Walkthrough

Adds CI (GitHub Actions) for server and app tests, Codecov reporting, CodeRabbit auto-review configuration, expands .gitignore, and introduces multiple new unit tests in server (Go) and app (Dart) including model serialization, websocket client lifecycle, and MAC/address utilities.

Changes

Testing and Coverage Infrastructure

Layer / File(s) Summary
CI workflow and coverage configuration
.coderabbit.yaml, .github/workflows/ci.yml, codecov.yml
Enables GitHub Actions CI for server (Go) and app (Dart) testing with parallel jobs, coverage collection and Codecov OIDC uploads. Adds CodeRabbit automated review settings with path-scoped instructions and chat auto-reply; configures Codecov project/patch status and ignore flags.
Build and coverage artifact exclusions
.gitignore
Expands ignore rules for IDE caches (.idea/), macOS artifacts (.DS_Store), Go coverage (server/coverage.out), and Flutter/Dart build/coverage outputs under app/ (e.g., .dart_tool/, build/, coverage/).
Server model serialization and validation tests
server/internal/model/expression_data_test.go, server/internal/model/user_test.go, server/internal/model/value_constant_test.go
Adds Go tests that assert JSON round-trip equality for ExpressionData/MotionData/DanceData, validate RemoteRegisterResp field mapping, and verify DefaultDanceData decodes with expected neutral eye weights and non-zero motion fields.
Server WebSocket client lifecycle tests
server/internal/model/web_socket_model_test.go
Adds tests for NewAppClient and NewStackChanClient verifying initial identifiers, SendChan capacity (100), state mutations (LastTime/SetMac), and clean writer coroutine shutdown with channel closure detection.
Flutter app model and utility test suites
app/test/model/expression_data_test.dart, app/test/util/mac_address_validator_test.dart
Adds Dart tests validating ExpressionData JSON round-trip and copy detachment semantics, MotionData/RgbData serialization nuances, and MacAddressValidator format acceptance/rejection, normalization, and case/separator-insensitive equality. Removes obsolete app/test/widget_test.dart counter smoke test.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 CI hums, tests hop in line,
Server models and Flutter shine,
Coverage counted, reviews awake,
Little rabbit cheers for every make!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main objective: adding test coverage and integrating review/CI tooling (CodeRabbit, Codecov, GitHub Actions CI).
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch rowan/coderabbit-codecov

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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.

Copy link
Copy Markdown

@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

🧹 Nitpick comments (2)
.github/workflows/ci.yml (1)

33-35: ⚡ Quick win

Pin staticcheck to a fixed version instead of @latest.

Using @latest makes CI non-reproducible and can fail unexpectedly when upstream releases change behavior. Specify an explicit version (e.g., @v1.26.0) to ensure consistent and reliable builds across environments.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/ci.yml around lines 33 - 35, Replace the dynamic `@latest`
pin for staticcheck in the CI workflow with a fixed semantic version to ensure
reproducible CI runs; update the `go install
honnef.co/go/tools/cmd/staticcheck@latest` invocation to use a specific tag (for
example `@v1.26.0`) so the subsequent `"$(go env GOPATH)/bin/staticcheck"` call
runs a known, locked version.
server/internal/model/web_socket_model_test.go (1)

61-77: ⚡ Quick win

Prefer blocking select to eliminate busy-wait polling.

The helper uses a default case with sleep, causing it to poll every 10ms. Removing the default case would let the select block until the channel is ready or the timeout occurs, eliminating unnecessary CPU usage.

⚡ Proposed refactor to use blocking select
 func waitForClosedChannel(t *testing.T, ch chan *WsSendMsg) {
 	t.Helper()
 
 	deadline := time.After(2 * time.Second)
 	for {
 		select {
 		case _, ok := <-ch:
 			if !ok {
 				return
 			}
+			// Channel had data but wasn't closed; continue waiting
 		case <-deadline:
 			t.Fatal("timed out waiting for writer coroutine to close channel")
-		default:
-			time.Sleep(10 * time.Millisecond)
 		}
 	}
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server/internal/model/web_socket_model_test.go` around lines 61 - 77, The
waitForClosedChannel helper is busy-waiting due to the default case and
time.Sleep; change the select in waitForClosedChannel to a blocking select
(remove the default branch) so it blocks on either receiving from ch (and
returning when the channel is closed) or the deadline case which calls t.Fatal
on timeout; keep the existing deadline := time.After(2 * time.Second) and use
the same receive check (case _, ok := <-ch: if !ok { return }) and timeout
handling.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.coderabbit.yaml:
- Around line 19-28: The path_instructions block is currently a top-level key
and must be nested under the reviews section; update .coderabbit.yaml so the
path_instructions mapping (the block containing firmware/**, server/**, app/**
rules) is indented under the existing reviews: key (move/indent the
path_instructions block so it becomes a child of reviews) so CodeRabbit will
apply those rules.

---

Nitpick comments:
In @.github/workflows/ci.yml:
- Around line 33-35: Replace the dynamic `@latest` pin for staticcheck in the CI
workflow with a fixed semantic version to ensure reproducible CI runs; update
the `go install honnef.co/go/tools/cmd/staticcheck@latest` invocation to use a
specific tag (for example `@v1.26.0`) so the subsequent `"$(go env
GOPATH)/bin/staticcheck"` call runs a known, locked version.

In `@server/internal/model/web_socket_model_test.go`:
- Around line 61-77: The waitForClosedChannel helper is busy-waiting due to the
default case and time.Sleep; change the select in waitForClosedChannel to a
blocking select (remove the default branch) so it blocks on either receiving
from ch (and returning when the channel is closed) or the deadline case which
calls t.Fatal on timeout; keep the existing deadline := time.After(2 *
time.Second) and use the same receive check (case _, ok := <-ch: if !ok { return
}) and timeout handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 93d89606-4182-4ffc-a16f-b9ffbe8f7d56

📥 Commits

Reviewing files that changed from the base of the PR and between da156e1 and bf8412c.

⛔ Files ignored due to path filters (1)
  • server/go.sum is excluded by !**/*.sum
📒 Files selected for processing (12)
  • .coderabbit.yaml
  • .github/workflows/ci.yml
  • .gitignore
  • app/test/model/expression_data_test.dart
  • app/test/util/mac_address_validator_test.dart
  • app/test/widget_test.dart
  • codecov.yml
  • server/internal/model/expression_data_test.go
  • server/internal/model/user_test.go
  • server/internal/model/value_constant_test.go
  • server/internal/model/web_socket_model_test.go
  • server/internal/service/device_test.go
💤 Files with no reviewable changes (2)
  • app/test/widget_test.dart
  • server/internal/service/device_test.go

Comment thread .coderabbit.yaml Outdated
@Pro777
Copy link
Copy Markdown
Author

Pro777 commented May 19, 2026

@coderabbitai Please review.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

@Pro777: Sure! I'll kick off a full review of PR #1 right away.

✅ 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.

@Pro777
Copy link
Copy Markdown
Author

Pro777 commented May 27, 2026

Closing for now. The test additions may still be useful later, but this PR also carries Codecov/CodeRabbit tooling that no longer matches the current fork direction. We can reintroduce the useful testing pieces later in a narrower form.

@Pro777 Pro777 closed this May 27, 2026
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