Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/daily-team-status.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 58 additions & 17 deletions pkg/workflow/aw_info_versions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,53 @@ import (

func TestCLIVersionInAwInfo(t *testing.T) {
tests := []struct {
name string
cliVersion string
engineID string
description string
name string
cliVersion string
engineID string
description string
shouldInclude bool
}{
{
name: "CLI version is stored in aw_info.json",
cliVersion: "1.2.3",
engineID: "copilot",
description: "Should include cli_version field with correct value",
name: "Released CLI version is stored in aw_info.json",
cliVersion: "1.2.3",
engineID: "copilot",
description: "Should include cli_version field with correct value for released builds",
shouldInclude: true,
},
{
name: "CLI version with semver prerelease",
cliVersion: "1.2.3-beta.1",
engineID: "claude",
description: "Should handle prerelease versions",
name: "CLI version with semver prerelease",
cliVersion: "1.2.3-beta.1",
engineID: "claude",
description: "Should handle prerelease versions",
shouldInclude: true,
},
{
name: "Development CLI version is excluded",
cliVersion: "dev",
engineID: "copilot",
description: "Should NOT include cli_version field for development builds",
shouldInclude: false,
},
{
name: "Dirty CLI version is excluded",
cliVersion: "1.2.3-dirty",
engineID: "copilot",
description: "Should NOT include cli_version field for dirty builds",
shouldInclude: false,
},
{
name: "Test CLI version is excluded",
cliVersion: "1.0.0-test",
engineID: "claude",
description: "Should NOT include cli_version field for test builds",
shouldInclude: false,
},
{
name: "Git hash with dirty suffix is excluded",
cliVersion: "708d3ee-dirty",
engineID: "copilot",
description: "Should NOT include cli_version field for git hash with dirty suffix",
shouldInclude: false,
},
}

Expand All @@ -46,9 +77,19 @@ func TestCLIVersionInAwInfo(t *testing.T) {
output := yaml.String()

expectedLine := `cli_version: "` + tt.cliVersion + `"`
if !strings.Contains(output, expectedLine) {
t.Errorf("%s: Expected output to contain '%s', got:\n%s",
tt.description, expectedLine, output)
containsVersion := strings.Contains(output, expectedLine)

if tt.shouldInclude {
if !containsVersion {
t.Errorf("%s: Expected output to contain '%s', got:\n%s",
tt.description, expectedLine, output)
}
} else {
// For dev builds, cli_version should not appear at all
if strings.Contains(output, "cli_version:") {
t.Errorf("%s: Expected output to NOT contain 'cli_version:' field, got:\n%s",
tt.description, output)
}
}
})
}
Expand Down Expand Up @@ -122,7 +163,7 @@ func TestAwfVersionInAwInfo(t *testing.T) {

func TestBothVersionsInAwInfo(t *testing.T) {
// Test that both CLI version and AWF version are present simultaneously
compiler := NewCompiler(false, "", "2.0.0-test")
compiler := NewCompiler(false, "", "2.0.0-beta.5")
registry := GetGlobalEngineRegistry()
engine, err := registry.GetEngine("copilot")
if err != nil {
Expand All @@ -144,7 +185,7 @@ func TestBothVersionsInAwInfo(t *testing.T) {
output := yaml.String()

// Check for cli_version
expectedCLILine := `cli_version: "2.0.0-test"`
expectedCLILine := `cli_version: "2.0.0-beta.5"`
if !strings.Contains(output, expectedCLILine) {
t.Errorf("Expected output to contain cli_version '%s', got:\n%s", expectedCLILine, output)
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/workflow/compiler_yaml.go
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,22 @@ func (c *Compiler) generatePostSteps(yaml *strings.Builder, data *WorkflowData)
}
}

// isReleasedVersion checks if a version string represents a released build.
// It excludes development builds (containing "dev", "dirty", or "test").
func isReleasedVersion(version string) bool {
if version == "" {
return false
}
// Filter out development/test versions
excludePatterns := []string{"dev", "dirty", "test"}
for _, pattern := range excludePatterns {
if strings.Contains(version, pattern) {
return false
}
}
return true
}

func (c *Compiler) generateCreateAwInfo(yaml *strings.Builder, data *WorkflowData, engine CodingAgentEngine) {
yaml.WriteString(" - name: Generate agentic run info\n")
yaml.WriteString(" id: generate_aw_info\n") // Add ID for outputs
Expand Down Expand Up @@ -398,6 +414,12 @@ func (c *Compiler) generateCreateAwInfo(yaml *strings.Builder, data *WorkflowDat
agentVersion := getInstallationVersion(data, engine)
fmt.Fprintf(yaml, " agent_version: \"%s\",\n", agentVersion)

// CLI version - only include for released builds
// Excludes development builds containing "dev", "dirty", or "test"
if isReleasedVersion(c.version) {
fmt.Fprintf(yaml, " cli_version: \"%s\",\n", c.version)
}

// Workflow information
fmt.Fprintf(yaml, " workflow_name: \"%s\",\n", data.Name)
fmt.Fprintf(yaml, " experimental: %t,\n", engine.IsExperimental())
Expand Down