-
Notifications
You must be signed in to change notification settings - Fork 429
Record compiler ref in lock metadata for --action-tag compiles
#39687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,9 @@ func (c *Compiler) generateWorkflowHeader(yaml *strings.Builder, data *WorkflowD | |
| agentInfo.EngineVersions = collectEngineVersionsForMetadata(data) | ||
| agentInfo.AgentImageRunner = resolveAgentImageRunnerIdentifier(data.RawFrontmatter) | ||
| metadata := GenerateLockMetadata(LockHashInfo{FrontmatterHash: frontmatterHash, BodyHash: bodyHash}, data.StopTime, c.effectiveStrictMode(data.RawFrontmatter), agentInfo) | ||
| if metadata.CompilerVersion == "" && c.GetActionTag() != "" { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @copilot review if there is anything cli arg as well
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed in 1127713. I added CLI integration coverage for the flag-driven paths as well:
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/diagnose] If this is intentional (different metadata structure, different downstream consumers), a brief comment here noting the scope of this fix would help future readers avoid applying it in the wrong place. 💡 ContextThe affected code in metadataCompilerVersion := "dev"
if IsRelease() && strings.TrimSpace(GetVersion()) != "" {
metadataCompilerVersion = GetVersion()
}That path uses package-level functions, not the |
||
| metadata.CompilerVersion = c.GetVersion() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
💡 Details and suggested guardThe unit test avoids this case by always pre-seeding SetVersion("401bd13")
compiler.SetActionTag("v9.9.9")That means the test never exercises the path where if metadata.CompilerVersion == "" && c.GetActionTag() != "" && c.GetVersion() != "dev" {
metadata.CompilerVersion = c.GetVersion()
}If the intent is "always record whatever version the binary has, even if it is |
||
| } | ||
| metadataJSON, err := metadata.ToJSON() | ||
| if err != nil { | ||
| // Fallback to legacy format if JSON serialization fails | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1399,18 +1399,28 @@ func TestLockMetadataVersionInReleaseBuilds(t *testing.T) { | |
| name string | ||
| isRelease bool | ||
| version string | ||
| actionTag string | ||
| expectVersion bool | ||
| }{ | ||
| { | ||
| name: "dev build should not include version", | ||
| isRelease: false, | ||
| version: "dev", | ||
| actionTag: "", | ||
| expectVersion: false, | ||
| }, | ||
| { | ||
| name: "release build should include version", | ||
| isRelease: true, | ||
| version: "v0.1.2", | ||
| actionTag: "", | ||
| expectVersion: true, | ||
| }, | ||
| { | ||
| name: "action-tag compile should include current ref", | ||
| isRelease: false, | ||
| version: "401bd13", | ||
| actionTag: "v9.9.9", | ||
| expectVersion: true, | ||
| }, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [/tdd] Missing boundary test: The new guard ( 💡 Suggested test case to add{
name: "release build with action-tag should use release version (not guard)",
isRelease: true,
version: "v1.2.3",
actionTag: "v9.9.9",
expectVersion: true,
// compiler_version should be "v1.2.3" (release path), not "401bd13"
},This documents the intended priority and will catch a regression if the guard order ever changes. |
||
| } | ||
|
|
@@ -1437,6 +1447,7 @@ Test prompt. | |
|
|
||
| // Compile the workflow | ||
| compiler := NewCompiler() | ||
| compiler.SetActionTag(tt.actionTag) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
💡 Suggested fixAdd a cleanup at the top of each sub-test (or once at the parent level): origVersion := GetVersion()
origRelease := IsRelease()
t.Cleanup(func() {
SetVersion(origVersion)
SetIsRelease(origRelease)
})This is a pre-existing pattern in the test, but the new case changes which dirty state is left behind — worth hardening now while the test is being touched. |
||
| err := compiler.CompileWorkflow(workflowPath) | ||
| if err != nil { | ||
| t.Fatalf("Failed to compile workflow: %v", err) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Integration test asserts non-empty
compiler_versionbut never checks the actual value. This passes equally whethercompiler_versionis"dev", a real SHA, or any other non-empty string — meaning a regression where the wrong ref is recorded would go undetected here.💡 Details
For an integration test the binary version is whatever the test binary was built with, so you cannot always assert an exact string. But you could at least verify it is not the
"dev"placeholder if you care about real provenance, or document via a comment that"dev"is the expected value for test builds.Alternately, build the test binary with a known
-Xversion flag (as already done in some other integration tests) so the assertion can check the exact value.