Skip to content

Commit 4173449

Browse files
authored
feat: update action-tag to use action pins mode (gh-aw-actions) with v0 (#20991)
1 parent 62f815e commit 4173449

10 files changed

Lines changed: 185 additions & 57 deletions

.github/aw/actions-lock.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@
140140
"version": "v4.32.6",
141141
"sha": "fb0994ef1c058010acf1efccff928b0a83b1ed54"
142142
},
143+
"github/gh-aw-actions/setup@v0": {
144+
"repo": "github/gh-aw-actions/setup",
145+
"version": "v0",
146+
"sha": "c303e453d96fe6789ee8cb3d63033c710eac347a"
147+
},
143148
"github/stale-repos@v9.0.2": {
144149
"repo": "github/stale-repos",
145150
"version": "v9.0.2",

.github/workflows/daily-fact.lock.yml

Lines changed: 75 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/daily-fact.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ engine:
1616
model: gpt-5.1-codex-mini
1717
strict: true
1818
timeout-minutes: 15
19+
inlined-imports: true
1920
features:
20-
action-tag: "a70c5eada06553e3510ac27f2c3bda9d3705bccb"
21+
action-tag: "v0"
2122

2223
network:
2324
allowed:

pkg/workflow/action_reference.go

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -125,18 +125,21 @@ func ResolveSetupActionReference(actionMode ActionMode, version string, actionTa
125125

126126
// resolveActionReference converts a local action path to the appropriate reference
127127
// based on the current action mode (dev vs release vs action).
128-
// If action-tag is specified in features, it overrides the mode check and enables release mode behavior.
128+
// If action-tag is specified in features, it overrides the mode check and enables action mode behavior
129+
// (using the github/gh-aw-actions external repository).
129130
// For dev mode: returns the local path as-is (e.g., "./actions/create-issue")
130131
// For release mode: converts to SHA-pinned remote reference (e.g., "github/gh-aw/actions/create-issue@SHA # tag")
131132
// For action mode: converts to SHA-pinned reference in external repo if possible (e.g., "github/gh-aw-actions/create-issue@SHA # version")
132133
func (c *Compiler) resolveActionReference(localActionPath string, data *WorkflowData) string {
133-
// Check if action-tag is specified in features - if so, override mode and use release behavior
134+
// Check if action-tag is specified in features - if so, override mode and use action mode behavior
134135
hasActionTag := false
136+
var frontmatterActionTag string
135137
if data != nil && data.Features != nil {
136138
if actionTagVal, exists := data.Features["action-tag"]; exists {
137139
if actionTagStr, ok := actionTagVal.(string); ok && actionTagStr != "" {
138140
hasActionTag = true
139-
actionRefLog.Printf("action-tag feature detected: %s - using release mode behavior", actionTagStr)
141+
frontmatterActionTag = actionTagStr
142+
actionRefLog.Printf("action-tag feature detected: %s - using action mode behavior", actionTagStr)
140143
}
141144
}
142145
}
@@ -154,15 +157,17 @@ func (c *Compiler) resolveActionReference(localActionPath string, data *Workflow
154157
if !hasActionTag {
155158
return ResolveSetupActionReference(c.actionMode, c.version, "", resolver)
156159
}
160+
// hasActionTag is true and no compiler actionTag: use action mode with the frontmatter tag
161+
return ResolveSetupActionReference(ActionModeAction, c.version, frontmatterActionTag, resolver)
157162
}
158163

159-
// Action mode - use external gh-aw-actions repository with version tag (no SHA pinning)
160-
if c.actionMode == ActionModeAction && !hasActionTag {
164+
// Action mode - use external gh-aw-actions repository
165+
if c.actionMode == ActionModeAction || hasActionTag {
161166
return c.convertToExternalActionsRef(localActionPath, data)
162167
}
163168

164-
// Use release mode if either actionMode is release OR action-tag is specified
165-
if c.actionMode == ActionModeRelease || hasActionTag {
169+
// Use release mode
170+
if c.actionMode == ActionModeRelease {
166171
// Convert to tag-based remote reference for release
167172
remoteRef := c.convertToRemoteActionRef(localActionPath, data)
168173
if remoteRef == "" {
@@ -185,22 +190,14 @@ func (c *Compiler) resolveActionReference(localActionPath string, data *Workflow
185190
}
186191
if pinnedRef != "" {
187192
// Successfully resolved to SHA
188-
if hasActionTag {
189-
actionRefLog.Printf("action-tag override: resolved %s to SHA-pinned reference: %s", remoteRef, pinnedRef)
190-
} else {
191-
actionRefLog.Printf("Release mode: resolved %s to SHA-pinned reference: %s", remoteRef, pinnedRef)
192-
}
193+
actionRefLog.Printf("Release mode: resolved %s to SHA-pinned reference: %s", remoteRef, pinnedRef)
193194
return pinnedRef
194195
}
195196
}
196197

197198
// If we couldn't resolve to SHA, return the tag-based reference
198199
// This happens in non-strict mode when no pin is available
199-
if hasActionTag {
200-
actionRefLog.Printf("action-tag override: using tag-based remote action reference: %s", remoteRef)
201-
} else {
202-
actionRefLog.Printf("Release mode: using tag-based remote action reference: %s", remoteRef)
203-
}
200+
actionRefLog.Printf("Release mode: using tag-based remote action reference: %s", remoteRef)
204201
return remoteRef
205202
}
206203

pkg/workflow/action_reference_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,26 +152,26 @@ func TestResolveActionReference(t *testing.T) {
152152
localPath: "./actions/setup",
153153
version: "v1.0.0",
154154
actionTag: "latest",
155-
expectedRef: "github/gh-aw/actions/setup@latest",
156-
description: "Release mode with action-tag should use action-tag instead of version",
155+
expectedRef: "github/gh-aw-actions/setup@latest",
156+
description: "Frontmatter action-tag should use action mode (gh-aw-actions) regardless of compiler mode",
157157
},
158158
{
159159
name: "release mode with action-tag using SHA",
160160
actionMode: ActionModeRelease,
161161
localPath: "./actions/setup",
162162
version: "v1.0.0",
163163
actionTag: "abc123def456789",
164-
expectedRef: "github/gh-aw/actions/setup@abc123def456789",
165-
description: "Release mode with action-tag SHA should use the SHA",
164+
expectedRef: "github/gh-aw-actions/setup@abc123def456789",
165+
description: "Frontmatter action-tag SHA should use action mode (gh-aw-actions)",
166166
},
167167
{
168-
name: "dev mode with action-tag uses remote reference",
168+
name: "dev mode with action-tag uses external actions repo",
169169
actionMode: ActionModeDev,
170170
localPath: "./actions/setup",
171171
version: "v1.0.0",
172172
actionTag: "latest",
173-
expectedRef: "github/gh-aw/actions/setup@latest",
174-
description: "Dev mode with action-tag should override and use remote reference",
173+
expectedRef: "github/gh-aw-actions/setup@latest",
174+
description: "Dev mode with frontmatter action-tag should use action mode (gh-aw-actions)",
175175
},
176176
}
177177

pkg/workflow/data/action_pins.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@
140140
"version": "v4.32.6",
141141
"sha": "fb0994ef1c058010acf1efccff928b0a83b1ed54"
142142
},
143+
"github/gh-aw-actions/setup@v0": {
144+
"repo": "github/gh-aw-actions/setup",
145+
"version": "v0",
146+
"sha": "c303e453d96fe6789ee8cb3d63033c710eac347a"
147+
},
143148
"github/stale-repos@v9.0.2": {
144149
"repo": "github/stale-repos",
145150
"version": "v9.0.2",

pkg/workflow/features_validation.go

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
//
55
// This file validates feature flag values to ensure they meet requirements
66
// before being used in workflow compilation. It ensures that:
7-
// - action-tag uses full 40-character SHA when specified
7+
// - action-tag uses a full 40-character SHA or a version tag when specified
88
// - Other feature-specific constraints are met
99
//
1010
// # Validation Functions
1111
//
1212
// - validateFeatures() - Validates all feature flags in WorkflowData
13-
// - validateActionTag() - Validates action-tag is a full SHA
13+
// - validateActionTag() - Validates action-tag is a full SHA or version tag
1414
// - isValidFullSHA() - Checks if a string is a valid 40-character SHA
15+
// - isValidVersionTag() - Checks if a string is a valid version tag (in semver.go)
1516
//
1617
// # When to Add Validation Here
1718
//
@@ -54,7 +55,7 @@ func validateFeatures(data *WorkflowData) error {
5455
return nil
5556
}
5657

57-
// validateActionTag validates that action-tag is a full 40-character SHA when specified
58+
// validateActionTag validates that action-tag is a full 40-character SHA or a version tag when specified
5859
func validateActionTag(value any) error {
5960
// Allow empty or nil values
6061
if value == nil {
@@ -68,7 +69,7 @@ func validateActionTag(value any) error {
6869
"features.action-tag",
6970
fmt.Sprintf("%T", value),
7071
fmt.Sprintf("action-tag must be a string, got %T", value),
71-
"Provide a string value for action-tag. Example:\nfeatures:\n action-tag: \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"",
72+
"Provide a string value for action-tag. Example:\nfeatures:\n action-tag: \"v0\"",
7273
)
7374
}
7475

@@ -77,17 +78,22 @@ func validateActionTag(value any) error {
7778
return nil
7879
}
7980

80-
// Validate it's a full SHA (40 hex characters)
81-
if !isValidFullSHA(strVal) {
82-
return NewValidationError(
83-
"features.action-tag",
84-
strVal,
85-
fmt.Sprintf("action-tag must be a full 40-character commit SHA (length: %d). Short SHAs are not allowed", len(strVal)),
86-
"Use 'git rev-parse <ref>' to get the full SHA. Example:\n\n$ git rev-parse HEAD\na1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\n\nThen use in workflow:\nfeatures:\n action-tag: \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"",
87-
)
81+
// Accept full 40-character commit SHA
82+
if isValidFullSHA(strVal) {
83+
return nil
8884
}
8985

90-
return nil
86+
// Accept version tags like "v0", "v1", "v1.0.0"
87+
if isValidVersionTag(strVal) {
88+
return nil
89+
}
90+
91+
return NewValidationError(
92+
"features.action-tag",
93+
strVal,
94+
fmt.Sprintf("action-tag must be a full 40-character commit SHA or a version tag (e.g. v0, v1.0.0). Got: %q", strVal),
95+
"Use a version tag or a full commit SHA. Examples:\nfeatures:\n action-tag: \"v0\"\n\nOr with a full SHA:\nfeatures:\n action-tag: \"a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0\"",
96+
)
9197
}
9298

9399
// isValidFullSHA checks if a string is a valid 40-character hexadecimal SHA

pkg/workflow/features_validation_test.go

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,27 @@ func TestValidateActionTag(t *testing.T) {
9292
value: nil,
9393
expectError: false,
9494
},
95+
{
96+
name: "valid - version tag v0",
97+
value: "v0",
98+
expectError: false,
99+
},
100+
{
101+
name: "valid - version tag v1.0.0",
102+
value: "v1.0.0",
103+
expectError: false,
104+
},
95105
{
96106
name: "invalid - short SHA (7 chars)",
97107
value: "5c3428a",
98108
expectError: true,
99-
errorMsg: "action-tag must be a full 40-character commit SHA",
109+
errorMsg: "action-tag must be a full 40-character commit SHA or a version tag",
100110
},
101111
{
102112
name: "invalid - short SHA (8 chars)",
103113
value: "abc123de",
104114
expectError: true,
105-
errorMsg: "action-tag must be a full 40-character commit SHA",
106-
},
107-
{
108-
name: "invalid - version tag instead of SHA",
109-
value: "v1.0.0",
110-
expectError: true,
111-
errorMsg: "action-tag must be a full 40-character commit SHA",
115+
errorMsg: "action-tag must be a full 40-character commit SHA or a version tag",
112116
},
113117
{
114118
name: "invalid - not a string",
@@ -126,7 +130,7 @@ func TestValidateActionTag(t *testing.T) {
126130
name: "invalid - uppercase SHA",
127131
value: "ABCDEF0123456789ABCDEF0123456789ABCDEF01",
128132
expectError: true,
129-
errorMsg: "action-tag must be a full 40-character commit SHA",
133+
errorMsg: "action-tag must be a full 40-character commit SHA or a version tag",
130134
},
131135
}
132136

@@ -182,17 +186,16 @@ func TestValidateFeatures(t *testing.T) {
182186
},
183187
},
184188
expectError: true,
185-
errorMsg: "action-tag must be a full 40-character commit SHA",
189+
errorMsg: "action-tag must be a full 40-character commit SHA or a version tag",
186190
},
187191
{
188-
name: "invalid action-tag - version tag",
192+
name: "valid action-tag - version tag",
189193
data: &WorkflowData{
190194
Features: map[string]any{
191195
"action-tag": "v2.0.0",
192196
},
193197
},
194-
expectError: true,
195-
errorMsg: "action-tag must be a full 40-character commit SHA",
198+
expectError: false,
196199
},
197200
{
198201
name: "empty action-tag is allowed",

0 commit comments

Comments
 (0)