Skip to content

Add meaningful tests for workflow scripts #39

@jdelfino

Description

@jdelfino

Context

Depends on #37 (shared libs) and #38 (script extraction).

Current tests (3 .py + 2 .sh files) are keyword-grep checks against inline YAML — they validate almost nothing. With scripts extracted into standalone JS modules, we can write real unit tests.

Task

Language: Node.js (using built-in node:test runner, Node 18+)

1. YAML structure validation (tests/validate-workflows.js)

  • Parse each .yml with js-yaml
  • Validate: name, triggers, permissions, job structure, job dependencies
  • Replaces all existing structural tests

2. Unit tests for lib modules (tests/lib/*.test.js)

Test pure logic with real inputs — no GitHub API mocking:

Test file What's tested
config.test.js YAML section parsing with various inputs
file-patterns.test.js Test/code/dependency file detection edge cases
commit-validator.test.js Conventional commit format validation
scope-matcher.test.js File path extraction from markdown + scope matching
api-patterns.test.js Language-specific API surface regex patterns
patch-parser.test.js Unified diff line number tracking
severity.test.js Review comment severity keyword detection
approval.test.js Non-stale approval logic
fixes-parser.test.js Fixes #N extraction from PR bodies
pr-body.test.js Idempotent section replacement

3. Delete old tests

  • tests/test_guardrail_test_ratio.py
  • tests/test_human_review_workflow.py
  • tests/test_pr_review_workflow.py
  • tests/test-guardrail-commits.sh
  • tests/test-guardrail-scope.sh

Files

  • tests/validate-workflows.js (new)
  • tests/lib/*.test.js (10 new files)
  • tests/*.py, tests/*.sh (5 deleted)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions