Skip to content

test: improve test coverage#37

Closed
guibeira wants to merge 3 commits intomainfrom
improve-test-coverage
Closed

test: improve test coverage#37
guibeira wants to merge 3 commits intomainfrom
improve-test-coverage

Conversation

@guibeira
Copy link
Contributor

@guibeira guibeira commented Mar 2, 2026

Summary by CodeRabbit

  • Tests

    • Added comprehensive test suites for worker metrics and OTEL gauge integration in Node.js and Python.
  • Chores

    • Enabled test coverage with 70% thresholds and added coverage reporting/configuration for Node.js and Python.
    • Updated CI steps to run tests with coverage and added coverage artifacts to .gitignore.

@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5bc78e5 and 1a649df.

⛔ Files ignored due to path filters (2)
  • packages/node/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • packages/python/iii/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • .github/workflows/ci-node.yml
  • .github/workflows/ci-python.yml
  • .gitignore
  • packages/node/iii/package.json
  • packages/node/iii/tests/otel-worker-gauges.test.ts
  • packages/node/iii/tests/worker-metrics.test.ts
  • packages/node/iii/vitest.config.ts
  • packages/python/iii/pyproject.toml
  • packages/python/iii/tests/test_worker_metrics.py
🚧 Files skipped from review as they are similar to previous changes (6)
  • packages/python/iii/pyproject.toml
  • packages/node/iii/vitest.config.ts
  • .github/workflows/ci-node.yml
  • packages/node/iii/package.json
  • packages/node/iii/tests/otel-worker-gauges.test.ts
  • packages/node/iii/tests/worker-metrics.test.ts

📝 Walkthrough

Walkthrough

Adds coverage collection and thresholds for Node and Python, updates CI steps to run coverage, ignores coverage artifacts in .gitignore, introduces Vitest and pytest coverage configs, adds coverage-related dev deps and scripts, and adds comprehensive unit tests for worker metrics and OTEL gauges.

Changes

Cohort / File(s) Summary
CI Workflow Updates
.github/workflows/ci-node.yml, .github/workflows/ci-python.yml
Renamed test steps to "Run tests with coverage"; Node workflow now runs the test:coverage script.
Gitignore
.gitignore
Added coverage artifacts to ignore: .coverage, coverage/, htmlcov/.
Node package & test config
packages/node/iii/package.json, packages/node/iii/vitest.config.ts
Added test:coverage script and @vitest/coverage-v8 devDependency; added Vitest coverage config (v8 provider, include/exclude, reporters, thresholds 70%).
Python project config
packages/python/iii/pyproject.toml
Added pytest-cov>=6.0 to dev deps and Pytest ini_options to enable coverage collection, reporting, and fail-under=70.
Node tests (new)
packages/node/iii/tests/otel-worker-gauges.test.ts, packages/node/iii/tests/worker-metrics.test.ts
Added unit tests for WorkerMetricsCollector and OTEL worker gauges covering metric collection, histogram handling, observable gauge registration, and cleanup behavior with extensive mocks.
Python tests (new)
packages/python/iii/tests/test_worker_metrics.py
Added tests for worker metrics and OTEL gauge registration, including proc parsing, platform-specific memory reads, CPU calculations, caching, and observable callback behavior.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Suggested reviewers

  • andersonleal

Poem

🐰 I hop through lines of code and cheer,
Coverage flags both far and near,
Gauges hum and metrics sing,
Thresholds set — let tests take wing,
Hooray for passes, bugs disappear! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: improve test coverage' accurately captures the main objective of this pull request, which adds comprehensive test coverage infrastructure and tests across Node.js and Python packages.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-test-coverage

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.

@guibeira guibeira force-pushed the improve-test-coverage branch from 22c37b9 to 5bc78e5 Compare March 2, 2026 11:12
@guibeira guibeira marked this pull request as ready for review March 2, 2026 11:12
Copy link

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/node/iii/tests/worker-metrics.test.ts`:
- Around line 30-32: The test is directly asserting private fields on
WorkerMetricsCollector which fails TS strict checks; change the casts to go
through unknown and centralize the pattern with a shared helper type/cast. For
example, introduce a reusable UnsafeCast<T> helper (used in the test file) and
replace casts like (collector as { lastCpuUsage: NodeJS.CpuUsage }) with
(collector as unknown as { lastCpuUsage: NodeJS.CpuUsage }) or via the helper
(UnsafeCast<typeof collector> as { lastCpuUsage: NodeJS.CpuUsage }) so
assignments to lastCpuUsage, lastCpuTime and eventLoopHistogram on the collector
compile under strict mode.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c0604e5 and 5bc78e5.

⛔ Files ignored due to path filters (2)
  • packages/node/pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
  • packages/python/iii/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • .github/workflows/ci-node.yml
  • .github/workflows/ci-python.yml
  • .gitignore
  • packages/node/iii/package.json
  • packages/node/iii/tests/otel-worker-gauges.test.ts
  • packages/node/iii/tests/worker-metrics.test.ts
  • packages/node/iii/vitest.config.ts
  • packages/python/iii/pyproject.toml
  • packages/python/iii/tests/test_worker_metrics.py

@guibeira
Copy link
Contributor Author

guibeira commented Mar 4, 2026

moved to mono repo:
iii-hq/iii#1228

@guibeira guibeira closed this Mar 4, 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