test(scripts): unit test and measure the pure scripts/lib helpers#2194
Conversation
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2194 +/- ##
==========================================
+ Coverage 93.35% 93.40% +0.04%
==========================================
Files 54 60 +6
Lines 8639 9487 +848
Branches 3138 3502 +364
==========================================
+ Hits 8065 8861 +796
- Misses 100 106 +6
- Partials 474 520 +46 🚀 New features to boost your workflow:
|
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review — held for maintainer review
⏸️ Held for maintainer review — Large change — held for manual review Review summary
Nits — 6 non-blocking
Review context
Contributor next steps
Signal definitions
Review detailsGenerated from public PR metadata and the diff. Advisory only; deterministic signals remain authoritative. Pure coverage PR: adds five dedicated unit-test files for `scripts/lib/` helpers and wires them into `vitest.config.mjs` coverage inclusion. Every exported symbol is exercised with edge and fallback paths, the tests correctly import from the per-module paths, and the removal of `tests/miner-readiness.test.mjs` is clean — `economics-artifacts.test.mjs` is a strict superset of its assertions. The file-by-file listing in `coverage.include` rather than a glob is the right defensive choice and the explanatory comment justifies it well. Nits (5)
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Summary
Adds focused unit tests for the pure helper modules under
scripts/lib, and lists them in the vitestcoverage.includeso their lines finally show up in the coverage report. These modules hold the deterministic transforms the build relies on: text formatting and sanitization, the economics, endpoint, and enrichment artifact derivations, and README link selection. Until now they ran only throughscripts/build-artifacts.mjs, which the suite drives as a child process viaexecFileSync, so their lines never reached the in process coverage collector.No script behavior changes.
npm run buildproduces the same artifacts, and the working tree stays clean underpublic/after a fresh build.Closes #2065
What Changed
New test files, each covering every export of its module plus the reachable edge and fallback paths (empty input, missing fields, malformed rows, boundary values), modeled on the existing
tests/build-readiness.test.mjs:tests/formatting.test.mjsforscripts/lib/formatting.mjstests/economics-artifacts.test.mjsforscripts/lib/economics-artifacts.mjstests/readme-links.test.mjsforscripts/lib/readme-links.mjstests/endpoint-artifacts.test.mjsforscripts/lib/endpoint-artifacts.mjstests/enrichment-queue-artifacts.test.mjsforscripts/lib/enrichment-queue-artifacts.mjsvitest.config.mjsgains the sixscripts/lib/*.mjsmodules incoverage.include. They are listed by name rather than with ascripts/lib/**glob, so a future module dropped into the directory without its own test cannot quietly pull the backstop floors down.build-readiness.mjsalready had a suite but was never measured, so it joins the list too.Two of the covered modules (
enrichment-queue-artifacts.mjsandbuild-readiness.mjs) were lifted out ofbuild-artifacts.mjs, and the others came out ofscripts/lib.mjs, so this measures real build pipeline logic. The remaining uncovered branches in the four sub 100 modules are defensivetry/catchfallbacks and impossible state guards that the exported API cannot reach; all modules clear the backstop floors with margin.Follow up extraction targets
Captured here so the rest can land as separate PRs:
scripts/build-artifacts.mjspure helpers not yet split out, such asgapRowSeverity,mergeSubnet,buildGaps,subnetProfileCompleteness,resolveAgentServiceSchema,fixtureCoverageEntry, andprofileSuggestedNextAction.scripts/validate.mjs(validateProvider,validateCuration,validateLinks,validatePublicSafeJson,validateVerification) andscripts/validate-api.mjs(validateWorkerResponse,validateErrorEnvelope).Registry Safety
Validation
npm run validatenpm run validate:schemasnpm run validate:apinpm run validate:openapinpm run validate:typesnpm run validate:contract-driftnpm run validate:artifact-budgetsnpm run validate:docsnpm run validate:intakenpm run validate:workflowsnpm run worker:testnpm run lintandnpm run format:checknpm run test:ciandnpm run test:ci:artifactsnpm run scan:public-safetygit diff --checknpm run build, thengit statusclean underpublic/