Skip to content

Add unit tests for compiler_yaml_main_job.go#14129

Merged
pelikhan merged 4 commits intomainfrom
copilot/create-test-file-compiler-yaml-main-job
Feb 6, 2026
Merged

Add unit tests for compiler_yaml_main_job.go#14129
pelikhan merged 4 commits intomainfrom
copilot/create-test-file-compiler-yaml-main-job

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

Main job generation (682 lines) lacked dedicated test file - only tested indirectly through integration tests, making edge case validation and regression testing difficult.

Test Coverage

Created compiler_yaml_main_job_test.go with 11 test functions covering 30+ scenarios:

Repository Import Logic

  • parseRepositoryImportSpec - Validates parsing of owner/repo@ref format, section references, invalid specs
  • generateRepositoryImportCheckouts - Tests sparse checkout generation for multiple imports
  • generateLegacyAgentImportCheckout - Handles legacy import format edge cases
  • sanitizeRefForPath - Path sanitization for refs containing slashes, colons, backslashes

Runtime Deduplication

  • addCustomStepsWithRuntimeInsertion - Tests runtime step injection after checkout detection
  • Tests runtime insertion order: checkout → runtime setup → custom steps
  • Validates detection limitations (e.g., - uses: without name: not recognized as checkout)

Main Job Orchestration

  • generateMainJobSteps - Core orchestration with various configurations (imports, custom steps, safe-outputs)
  • generateDevModeCLIBuildSteps - Dev mode CLI build step generation (Go setup, Docker build, image tagging)
  • Step ordering validation to catch compiler bugs

Example test structure:

func TestAddCustomStepsWithRuntimeInsertion(t *testing.T) {
    tests := []struct {
        name              string
        customSteps       string
        runtimeSetupSteps []GitHubActionStep
        expectStepOrder   []string
        insertionHappened bool
    }{
        {
            name: "insert runtime after checkout",
            customSteps: `steps:
  - name: Checkout code
    uses: actions/checkout@v4
  - name: Build
    run: make build`,
            runtimeSetupSteps: []GitHubActionStep{
                {"      - name: Setup Node.js", ...},
            },
            expectStepOrder: []string{"Checkout code", "Setup Node.js", "Build"},
            insertionHappened: true,
        },
        // 4 more test cases...
    }
}

Impact

  • Direct unit tests for critical compilation path
  • Easier regression testing for specific behaviors
  • Documents expected behavior for complex logic (runtime insertion, import parsing)
Original prompt

This section details on the original issue you should resolve

<issue_title>[Code Quality] Create test file for compiler_yaml_main_job.go</issue_title>
<issue_description>## Description

The compiler_yaml_main_job.go file (612 lines) currently lacks a dedicated test file. Main job generation is a critical path in the workflow compilation process and needs direct unit tests rather than only indirect integration testing.

Suggested Changes

Create pkg/workflow/compiler_yaml_main_job_test.go with comprehensive test coverage for:

  • Repository import checkout generation
  • Runtime deduplication logic
  • Custom steps insertion
  • Edge cases in main job generation

Files Affected

  • pkg/workflow/compiler_yaml_main_job_test.go (new file)
  • Test patterns should follow existing test conventions from similar compiler test files

Success Criteria

  • Test file created with at least 10 test cases
  • Coverage for repository import logic
  • Coverage for runtime setup logic
  • Coverage for custom steps handling
  • All existing integration tests continue to pass

Source

Extracted from Daily Compiler Code Quality Report discussion github/gh-aw#13934

Original recommendation:

Missing Dedicated Test File (High Priority)

  • Current: No compiler_yaml_main_job_test.go file exists
  • Concern: Main job generation is tested only indirectly through integration tests
  • Impact: Harder to validate edge cases and regression test specific behaviors
  • Estimated Effort: 2-4 hours

Priority

High - Improves regression testing for critical compilation path

AI generated by Discussion Task Miner - Code Quality Improvement Agent

  • expires on Feb 7, 2026, 9:12 AM UTC

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@github-actions github-actions bot added good first issue Good for newcomers testing labels Feb 6, 2026
- Created compiler_yaml_main_job_test.go with 11 test functions covering 30+ test cases
- Test coverage includes:
  - parseRepositoryImportSpec: 7 test cases for valid/invalid import specs
  - sanitizeRefForPath: 6 test cases for path sanitization
  - generateRepositoryImportCheckouts: 4 test cases for repository imports
  - generateLegacyAgentImportCheckout: 3 test cases for legacy imports
  - generateDevModeCLIBuildSteps: validates dev mode build steps
  - addCustomStepsAsIs: 4 test cases for custom steps without modification
  - addCustomStepsWithRuntimeInsertion: 5 test cases for runtime insertion logic
  - generateMainJobSteps: 5 test cases for main orchestration
  - Dev mode integration test
  - Step ordering validation test
  - Checkout step edge cases: 4 test cases

All tests follow existing patterns from similar compiler test files

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Successfully created comprehensive test file with:
- 11 test functions covering 30+ test cases
- All tests passing
- Code formatted and linted
- Workflows recompiled successfully

Tests provide thorough coverage for:
- Repository import parsing and checkout generation
- Path sanitization for git refs
- Legacy agent imports
- Dev mode CLI build steps
- Custom steps handling (with and without runtime insertion)
- Main job steps orchestration
- Step ordering validation
- Checkout step detection edge cases

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add test file for compiler_yaml_main_job.go Add unit tests for compiler_yaml_main_job.go Feb 6, 2026
Copilot AI requested a review from pelikhan February 6, 2026 13:35
@pelikhan pelikhan marked this pull request as ready for review February 6, 2026 13:35
Copilot AI review requested due to automatic review settings February 6, 2026 13:35
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds direct unit test coverage for the YAML main-job generation code path in pkg/workflow, making it easier to validate edge cases (imports, runtime insertion/dedup, step ordering) and prevent regressions.

Changes:

  • Add pkg/workflow/compiler_yaml_main_job_test.go with broad unit coverage for main job step orchestration and helper functions.
  • Regenerate/update numerous workflow .lock.yml files, bumping agent/tool versions (e.g., Copilot CLI, Claude Code, Codex).

Reviewed changes

Copilot reviewed 86 out of 86 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/workflow/compiler_yaml_main_job_test.go New dedicated unit tests for main-job YAML step generation and helper logic (imports, runtime insertion, dev-mode steps, ordering).
.github/workflows/workflow-skill-extractor.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/workflow-normalizer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/workflow-health-manager.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/workflow-generator.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/weekly-issue-summary.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/video-analyzer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/unbloat-docs.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/ubuntu-image-analyzer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/typist.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/tidy.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/test-workflow.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/test-project-url-default.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/test-dispatcher.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/test-create-pr-error-handling.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/terminal-stylist.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/technical-doc-writer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/super-linter.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/sub-issue-closer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/step-name-alignment.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/static-analysis-report.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/stale-repo-identifier.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/smoke-test-tools.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/smoke-project.lock.yml Bump embedded agent/tool versions (e.g., Codex).
.github/workflows/smoke-copilot.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/smoke-codex.lock.yml Bump embedded agent/tool versions (e.g., Codex).
.github/workflows/smoke-claude.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/slide-deck-maintainer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/sergo.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/semantic-function-refactor.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/security-review.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/security-guard.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/security-fix-pr.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/security-compliance.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/scout.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/schema-consistency-checker.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/safe-output-health.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/research.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/repository-quality-improver.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/repo-tree-map.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/repo-audit-analyzer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/release.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/q.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/python-data-charts.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/prompt-clustering-analysis.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/pr-triage-agent.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/pr-nitpick-reviewer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/portfolio-analyst.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/poem-bot.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/plan.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/pdf-summary.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/org-health-report.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/notion-issue-summary.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/metrics-collector.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/mergefest.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/mcp-inspector.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/lockfile-stats.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/layout-spec-maintainer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/jsweep.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/issue-triage-agent.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/issue-monster.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/issue-arborist.lock.yml Bump embedded agent/tool versions (e.g., Codex).
.github/workflows/instructions-janitor.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/hourly-ci-cleaner.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/grumpy-reviewer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/go-pattern-detector.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/go-logger.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/go-fan.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/glossary-maintainer.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/github-remote-mcp-auth-test.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/github-mcp-tools-report.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/github-mcp-structural-analysis.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/functional-pragmatist.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/firewall.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/firewall-escape.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/example-workflow-analyzer.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/example-permissions-warning.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/example-custom-error-patterns.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/duplicate-code-detector.lock.yml Bump embedded agent/tool versions (e.g., Codex).
.github/workflows/draft-pr-cleanup.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/docs-noob-tester.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/discussion-task-miner.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/dictation-prompt.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/developer-docs-consolidator.lock.yml Bump embedded agent/tool versions (e.g., Claude Code).
.github/workflows/dev.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).
.github/workflows/dev-hawk.lock.yml Bump embedded agent/tool versions (e.g., Copilot CLI).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +206 to +207
// Note: The parser extracts only owner/repo from the spec, ignoring path components
func TestGenerateLegacyAgentImportCheckout(t *testing.T) {
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The note above this test is misleading: parseRepositoryImportSpec does not “extract only owner/repo … ignoring path components”; it rejects specs with more than 2 slash parts and returns empty strings. Please update the comment to reflect the actual behavior (or adjust the parser if the intent is to support legacy owner/repo/path@ref specs).

Copilot uses AI. Check for mistakes.
Comment on lines 147 to +148
- name: Install GitHub Copilot CLI
run: /opt/gh-aw/actions/install_copilot_cli.sh 0.0.403
run: /opt/gh-aw/actions/install_copilot_cli.sh 0.0.405
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

This PR is titled/described as adding unit tests, but it also bumps Copilot CLI versions in workflow lockfiles (and similar bumps appear across many other .lock.yml files in this PR). If these version updates are intentional, please call them out in the PR description (or split into a separate PR) to keep review scope clear.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit ee4a473 into main Feb 6, 2026
131 checks passed
@pelikhan pelikhan deleted the copilot/create-test-file-compiler-yaml-main-job branch February 6, 2026 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

good first issue Good for newcomers testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Code Quality] Create test file for compiler_yaml_main_job.go

2 participants