Skip to content

[Code Quality] Increase test coverage for compiler_jobs.go #14196

@github-actions

Description

@github-actions

Description

The compiler_jobs.go file has solid error handling (16/16 proper wraps) but below-target test coverage. With a test-to-source ratio of 0.47:1 (target: 0.8:1+), complex orchestration logic may have untested edge cases.

Current State

  • File: pkg/workflow/compiler_jobs.go (460 lines)
  • Test File: compiler_jobs_test.go (215 lines, 7 test functions)
  • Current Ratio: 0.47:1 (215 test lines / 460 source lines)
  • Target Ratio: 0.8:1+ (recommended for complex orchestration)
  • Quality Score: 84/100 (good, but test coverage could improve)

Suggested Changes

Add table-driven tests focusing on:

  1. Custom Job Dependency Resolution

    • Test jobs depending on pre-activation
    • Test jobs with multiple dependencies
    • Test circular dependency prevention
  2. Job Ordering Scenarios

    • Test job execution order with various dependency chains
    • Test push_repo_memory job dependency on detection
    • Test cache_memory job positioning
  3. Edge Cases

    • Empty custom jobs array
    • Jobs referencing custom job outputs
    • Jobs with invalid dependencies
    • Jobs with missing required fields
  4. Job Manager State Validation

    • Verify job manager state after complex builds
    • Validate job.Needs relationships are correct
    • Test permission calculations for different job types

Files Affected

  • pkg/workflow/compiler_jobs_test.go (expand from 215 to ~350-400 lines)

Success Criteria

  • Test-to-source ratio increased to 0.8:1+ (350+ test lines)
  • New tests cover dependency resolution logic
  • New tests cover job ordering scenarios
  • New tests cover edge cases
  • All existing and new tests pass
  • Tests follow table-driven pattern with t.Run()
  • Run make test-unit successfully

Test Example Pattern

func TestCustomJobDependencyResolution(t *testing.T) {
    tests := []struct {
        name           string
        customJobs     map[string]any
        expectedOrder  []string
        expectedDeps   map[string][]string
    }{
        {
            name: "job depending on pre-activation",
            customJobs: map[string]any{
                "custom-job": map[string]any{
                    "needs": "pre-activation",
                    "steps": []any{...},
                },
            },
            expectedOrder: []string{"pre-activation", "custom-job"},
            expectedDeps: map[string][]string{
                "custom-job": {"pre-activation"},
            },
        },
        // More test cases...
    }
    
    for _, tt := range tests {
        t.Run(tt.name, func(t *testing.T) {
            // Test implementation
        })
    }
}

Source

Extracted from Daily Compiler Code Quality Report:

Priority

Medium - Complex orchestration logic benefits from comprehensive tests. Estimated 2-4 hours of work.

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 7, 2026, 5:13 PM UTC

Metadata

Metadata

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions