Skip to content

test(quality): unit coverage for scripts/generate_skill_index.py - #788

Open
mrbobbytables wants to merge 1 commit into
projectbluefin:mainfrom
mrbobbytables:quality/test-generate-skill-index
Open

test(quality): unit coverage for scripts/generate_skill_index.py#788
mrbobbytables wants to merge 1 commit into
projectbluefin:mainfrom
mrbobbytables:quality/test-generate-skill-index

Conversation

@mrbobbytables

Copy link
Copy Markdown
Contributor

Summary

scripts/generate_skill_index.py (165 lines) is a required merge gate — .github/workflows/docs-validate.yml runs it with --check — but had zero unit tests before this PR.

Closes #767.

Note: scripts/update_coverage_snapshot.py, the other script named in #767, already gained coverage in #776 (merged), so this PR only adds tests for generate_skill_index.py.

What's covered (36 tests)

  • parse_frontmatter — YAML parsing and both error paths (missing --- marker, non-mapping front matter)
  • collect — all nine front-matter validations: each required field individually, category/status enum membership, entry_point self-match, id == name; plus doc_type extraction from metadata.type, description whitespace normalisation, multi-skill error aggregation, and id-sorted output
  • render_json / render_md — payload shape and generated document contents (including relative table links)
  • main — write mode, and every --check failure/success path, including a regression guard pinning that --check reuses the committed generated_at date rather than date.today() (switching to today's date would make the docs gate fail every day after the catalog is committed — the same class of failure as dakota-iso#137, called out in the issue)
  • A repository-invariant test asserting the committed docs/skills/index.json/index.md are currently in sync, mirroring the assertion docs-validate.yml makes

No production code changed. Since the script has no --repo-root seam, tests monkeypatch the module's ROOT/SKILLS_DIR/INDEX_JSON/INDEX_MD path constants to an isolated tmp_path.

Testing

  • python3 -m pytest tests/unit/test_generate_skill_index.py -q → 36 passed
  • python3 -m pytest tests/unit/ -q → 1563 passed (full unit suite, no regressions)
  • ruff check tests/unit/test_generate_skill_index.py → all checks passed

— hive: backend=copilot model=claude-sonnet-5

🐝 Hive Agent: contributor | SHA: 9d34091e

scripts/generate_skill_index.py (165 lines) is a required merge gate
(.github/workflows/docs-validate.yml runs it with --check) but had zero
unit tests. Add 36 tests covering:

- parse_frontmatter: YAML parsing and its two error paths
- collect: all nine front-matter validations (required fields per-field,
  category/status enums, entry_point self-match, id == name), doc_type
  extraction, description whitespace normalisation, and id-sorted output
- render_json / render_md: payload shape and generated document contents
- main: write mode, and every --check failure/success path, including a
  regression guard pinning that --check reuses the committed generated_at
  date rather than date.today() (switching to today's date would make the
  docs gate fail every day after the catalog is committed)
- a repository invariant test asserting the committed docs/skills/index.*
  files are in sync, mirroring the assertion docs-validate.yml makes

No production code changed.

Fixes projectbluefin#767

Signed-off-by: mrbobbytables <mrbobbytables@users.noreply.github.com>
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kubestellar-hive kubestellar-hive Bot added the lgtm This PR has been approved by a maintainer label Sep 7, 2026

@kubestellar-hive kubestellar-hive 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.

Approved by @castrojo for Hive auto-merge on green CI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[quality] CI gate scripts generate_skill_index.py and update_coverage_snapshot.py had zero unit coverage

2 participants