Skip to content

test: add worker metrics tests and coverage infrastructure#1228

Merged
guibeira merged 7 commits intomainfrom
improve-test-coverage-sdk
Mar 9, 2026
Merged

test: add worker metrics tests and coverage infrastructure#1228
guibeira merged 7 commits intomainfrom
improve-test-coverage-sdk

Conversation

@guibeira
Copy link
Contributor

@guibeira guibeira commented Mar 4, 2026

  • Add worker-metrics and otel-worker-gauges unit tests for Node SDK
  • Add worker_metrics and otel_worker_gauges unit tests for Python SDK
  • Configure vitest coverage (v8 provider, 70% thresholds) for Node SDK
  • Configure pytest-cov (70% threshold) for Python SDK
  • Update CI workflow to run tests with coverage reporting
  • Add coverage output directories to .gitignore

Original pr:
iii-hq/sdk#37

Summary by CodeRabbit

  • Tests

    • Added extensive tests for worker metrics collection and OTEL gauge integration across Node.js and Python SDKs.
  • Chores

    • CI updated to run coverage-enabled tests (step renamed to "Run tests with coverage").
    • Coverage tooling and configuration added with a 70% threshold for Node.js and Python.
    • Ignore rules added to exclude coverage artifacts.

guibeira added 2 commits March 3, 2026 22:40
- Add worker-metrics and otel-worker-gauges unit tests for Node SDK
- Add worker_metrics and otel_worker_gauges unit tests for Python SDK
- Configure vitest coverage (v8 provider, 70% thresholds) for Node SDK
- Configure pytest-cov (70% threshold) for Python SDK
- Update CI workflow to run tests with coverage reporting
- Add coverage output directories to .gitignore
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5849d107-8937-4af4-b0bc-97654febe998

📥 Commits

Reviewing files that changed from the base of the PR and between 1741f4d and eebd446.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (4)
  • .github/workflows/ci.yml
  • .gitignore
  • sdk/packages/node/iii/package.json
  • sdk/packages/python/iii/pyproject.toml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .gitignore

📝 Walkthrough

Walkthrough

Adds test coverage tooling and configs, updates CI to run coverage-enabled tests, extends .gitignore for coverage outputs, and introduces Node and Python unit tests for worker metrics and OTEL gauge behavior.

Changes

Cohort / File(s) Summary
CI & Ignore
\.github/workflows/ci.yml, \.gitignore
Renamed CI test steps to run coverage-enabled commands; added .coverage, coverage/, and htmlcov/ to .gitignore.
Node SDK — Scripts & Coverage Config
sdk/packages/node/iii/package.json, sdk/packages/node/iii/vitest.config.ts
Added test:coverage script and @vitest/coverage-v8 devDependency; configured Vitest coverage provider, reporters, output dir, excludes, and 70% thresholds.
Node SDK — Tests
sdk/packages/node/iii/tests/otel-worker-gauges.test.ts, sdk/packages/node/iii/tests/worker-metrics.test.ts
Added unit tests for OTEL worker gauge registration/observation and WorkerMetricsCollector collection/stop lifecycle, including edge cases and mocked metrics.
Python SDK — Coverage Config
sdk/packages/python/iii/pyproject.toml
Added pytest-cov dev dependency and tool.pytest.ini_options for coverage flags and fail-under 70%.
Python SDK — Tests
sdk/packages/python/iii/tests/test_worker_metrics.py
Added tests for platform-specific memory reads, CPU/uptime calculations, caching, and gauge registration/lifecycle using monkeypatching and test doubles.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • sergiofilhowz
  • andersonleal

Poem

🐇 I nibble bytes where coverage blooms at night,

I hop through tests to make the metrics right.
Gauges buzz, collectors keep the pace,
From Node to Python I bound in grace —
A fluffy stamp for signals passing bright.

🚥 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: add worker metrics tests and coverage infrastructure' accurately and concisely describes the main changes: adding unit tests for worker metrics and setting up coverage infrastructure for both Node and Python SDKs.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-test-coverage-sdk

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
Contributor

@ytallo ytallo left a comment

Choose a reason for hiding this comment

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

The new test coverage is useful, but making --cov-fail-under=70 part of global pytest addopts will affect every local test invocation. Please move that coverage gate to CI or a dedicated coverage command so focused local runs do not fail for unrelated reasons.

@vercel
Copy link
Contributor

vercel bot commented Mar 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
iii-docs Ready Ready Preview, Comment Mar 9, 2026 11:20pm
motia-docs Ready Ready Preview, Comment Mar 9, 2026 11:20pm

Request Review

@guibeira guibeira merged commit b0507a1 into main Mar 9, 2026
20 checks passed
@guibeira guibeira deleted the improve-test-coverage-sdk branch March 9, 2026 23:33
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