Skip to content

Commit a545576

Browse files
authored
Unify action_pins.json schema and sync generated cache to embedded data (#3933)
1 parent 343c1cc commit a545576

5 files changed

Lines changed: 167 additions & 77 deletions

File tree

.github/aw/actions-lock.json

Lines changed: 39 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,11 @@
1010
"version": "v4",
1111
"sha": "0057852bfaa89a56745cba8c7296529d2fc39830"
1212
},
13-
"actions/checkout@v4": {
14-
"repo": "actions/checkout",
15-
"version": "v4",
16-
"sha": "08eba0b27e820071cde6df949e0beb9ba4906955"
17-
},
1813
"actions/checkout@v5": {
1914
"repo": "actions/checkout",
2015
"version": "v5",
2116
"sha": "08c6903cd8c0fde910a37f88322edcfb5dd907a8"
2217
},
23-
"actions/download-artifact@v4": {
24-
"repo": "actions/download-artifact",
25-
"version": "v4",
26-
"sha": "d3f86a106a0bac45b974a628896c90dbdf5c8093"
27-
},
2818
"actions/download-artifact@v6": {
2919
"repo": "actions/download-artifact",
3020
"version": "v6",
@@ -35,11 +25,21 @@
3525
"version": "v8",
3626
"sha": "ed597411d8f924073f98dfc5c65a23a2325f34cd"
3727
},
28+
"actions/setup-dotnet@v4": {
29+
"repo": "actions/setup-dotnet",
30+
"version": "v4",
31+
"sha": "67a3573c9a986a3f9c594539f4ab511d57bb3ce9"
32+
},
3833
"actions/setup-go@v5": {
3934
"repo": "actions/setup-go",
4035
"version": "v5",
4136
"sha": "d35c59abb061a4a6fb18e82ac0862c26744d6ab5"
4237
},
38+
"actions/setup-java@v4": {
39+
"repo": "actions/setup-java",
40+
"version": "v4",
41+
"sha": "c5195efecf7bdfc987ee8bae7a71cb8b11521c00"
42+
},
4343
"actions/setup-node@v6": {
4444
"repo": "actions/setup-node",
4545
"version": "v6",
@@ -50,11 +50,6 @@
5050
"version": "v5",
5151
"sha": "a26af69be951a213d495a4c3e4e4022e16d87065"
5252
},
53-
"actions/upload-artifact@v4": {
54-
"repo": "actions/upload-artifact",
55-
"version": "v4",
56-
"sha": "ea165f8d65b6e75b540449e92b4886f43607fa02"
57-
},
5853
"actions/upload-artifact@v5": {
5954
"repo": "actions/upload-artifact",
6055
"version": "v5",
@@ -65,10 +60,35 @@
6560
"version": "v5",
6661
"sha": "e58605a9b6da7c637471fab8847a5e5a6b8df081"
6762
},
68-
"super-linter/super-linter@v8.2.1": {
69-
"repo": "super-linter/super-linter",
70-
"version": "v8.2.1",
71-
"sha": "2bdd90ed3262e023ac84bf8fe35dc480721fc1f2"
63+
"denoland/setup-deno@v2": {
64+
"repo": "denoland/setup-deno",
65+
"version": "v2",
66+
"sha": "e95548e56dfa95d4e1a28d6f422fafe75c4c26fb"
67+
},
68+
"erlef/setup-beam@v1": {
69+
"repo": "erlef/setup-beam",
70+
"version": "v1",
71+
"sha": "3559ac3b631a9560f28817e8e7fdde1638664336"
72+
},
73+
"github/codeql-action/upload-sarif@v3": {
74+
"repo": "github/codeql-action/upload-sarif",
75+
"version": "v3",
76+
"sha": "fb2a9d4376843ba94460a73c39ca9a98b33a12ac"
77+
},
78+
"haskell-actions/setup@v2": {
79+
"repo": "haskell-actions/setup",
80+
"version": "v2",
81+
"sha": "d5d0f498b388e1a0eab1cd150202f664c5738e35"
82+
},
83+
"oven-sh/setup-bun@v2": {
84+
"repo": "oven-sh/setup-bun",
85+
"version": "v2",
86+
"sha": "735343b667d3e6f658f44d0eca948eb6282f2b76"
87+
},
88+
"ruby/setup-ruby@v1": {
89+
"repo": "ruby/setup-ruby",
90+
"version": "v1",
91+
"sha": "e5517072e87f198d9533967ae13d97c11b604005"
7292
}
7393
}
7494
}

Makefile

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ all: build
1313

1414
# Build the binary, run make deps before this
1515
.PHONY: build
16-
build: sync-templates
16+
build: sync-templates sync-action-pins
1717
go build $(LDFLAGS) -o $(BINARY_NAME) ./cmd/gh-aw
1818

1919
# Build for all platforms
@@ -239,6 +239,17 @@ sync-templates:
239239
@cp .github/agents/create-shared-agentic-workflow.md pkg/cli/templates/
240240
@echo "✓ Templates synced successfully"
241241

242+
# Sync action pins from .github/aw to pkg/workflow/data
243+
.PHONY: sync-action-pins
244+
sync-action-pins:
245+
@echo "Syncing actions-lock.json from .github/aw to pkg/workflow/data/action_pins.json..."
246+
@if [ -f .github/aw/actions-lock.json ]; then \
247+
cp .github/aw/actions-lock.json pkg/workflow/data/action_pins.json; \
248+
echo "✓ Action pins synced successfully"; \
249+
else \
250+
echo "⚠ Warning: .github/aw/actions-lock.json does not exist yet"; \
251+
fi
252+
242253
# Recompile all workflow files
243254
.PHONY: recompile
244255
recompile: sync-templates build
@@ -304,6 +315,7 @@ help:
304315
@echo " validate - Run all validations (fmt-check, lint, validate-workflows)"
305316
@echo " install - Install binary locally"
306317
@echo " sync-templates - Sync templates from .github to pkg/cli/templates (runs automatically during build)"
318+
@echo " sync-action-pins - Sync actions-lock.json from .github/aw to pkg/workflow/data (runs automatically during build)"
307319
@echo " recompile - Recompile all workflow files (runs init, depends on build)"
308320
@echo " dependabot - Generate Dependabot manifests for npm dependencies in workflows"
309321
@echo " generate-schema-docs - Generate frontmatter full reference documentation from JSON schema"

pkg/cli/compile_command.go

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,22 @@ func CompileWorkflows(config CompileConfig) ([]*workflow.WorkflowData, error) {
459459
printCompilationSummary(stats)
460460
}
461461

462+
// Save the action cache after all compilations
463+
actionCache := compiler.GetSharedActionCache()
464+
if actionCache != nil {
465+
if err := actionCache.Save(); err != nil {
466+
compileLog.Printf("Failed to save action cache: %v", err)
467+
if verbose {
468+
fmt.Fprintf(os.Stderr, "⚠️ Failed to save action cache: %v\n", err)
469+
}
470+
} else {
471+
compileLog.Print("Action cache saved successfully")
472+
if verbose {
473+
fmt.Fprintf(os.Stderr, "✓ Action cache saved to %s\n", actionCache.GetCachePath())
474+
}
475+
}
476+
}
477+
462478
// Return error if any compilations failed
463479
if errorCount > 0 {
464480
// Return the first error message for backward compatibility with tests
@@ -669,6 +685,22 @@ func CompileWorkflows(config CompileConfig) ([]*workflow.WorkflowData, error) {
669685
printCompilationSummary(stats)
670686
}
671687

688+
// Save the action cache after all compilations
689+
actionCache := compiler.GetSharedActionCache()
690+
if actionCache != nil {
691+
if err := actionCache.Save(); err != nil {
692+
compileLog.Printf("Failed to save action cache: %v", err)
693+
if verbose {
694+
fmt.Fprintf(os.Stderr, "⚠️ Failed to save action cache: %v\n", err)
695+
}
696+
} else {
697+
compileLog.Print("Action cache saved successfully")
698+
if verbose {
699+
fmt.Fprintf(os.Stderr, "✓ Action cache saved to %s\n", actionCache.GetCachePath())
700+
}
701+
}
702+
}
703+
672704
// Return error if any compilations failed
673705
if errorCount > 0 {
674706
return workflowDataList, fmt.Errorf("compilation failed")
@@ -922,6 +954,22 @@ func compileAllWorkflowFiles(compiler *workflow.Compiler, workflowsDir string, v
922954
// Get warning count from compiler
923955
stats.Warnings = compiler.GetWarningCount()
924956

957+
// Save the action cache after all compilations
958+
actionCache := compiler.GetSharedActionCache()
959+
if actionCache != nil {
960+
if err := actionCache.Save(); err != nil {
961+
compileLog.Printf("Failed to save action cache: %v", err)
962+
if verbose {
963+
fmt.Fprintf(os.Stderr, "⚠️ Failed to save action cache: %v\n", err)
964+
}
965+
} else {
966+
compileLog.Print("Action cache saved successfully")
967+
if verbose {
968+
fmt.Fprintf(os.Stderr, "✓ Action cache saved to %s\n", actionCache.GetCachePath())
969+
}
970+
}
971+
}
972+
925973
// Ensure .gitattributes marks .lock.yml files as generated
926974
if err := ensureGitAttributes(); err != nil {
927975
if verbose {
@@ -959,6 +1007,19 @@ func compileModifiedFiles(compiler *workflow.Compiler, files []string, verbose b
9591007
// Get warning count from compiler
9601008
stats.Warnings = compiler.GetWarningCount()
9611009

1010+
// Save the action cache after compilations
1011+
actionCache := compiler.GetSharedActionCache()
1012+
if actionCache != nil {
1013+
if err := actionCache.Save(); err != nil {
1014+
compileLog.Printf("Failed to save action cache: %v", err)
1015+
if verbose {
1016+
fmt.Fprintf(os.Stderr, "⚠️ Failed to save action cache: %v\n", err)
1017+
}
1018+
} else {
1019+
compileLog.Print("Action cache saved successfully")
1020+
}
1021+
}
1022+
9621023
// Ensure .gitattributes marks .lock.yml files as generated
9631024
if err := ensureGitAttributes(); err != nil {
9641025
if verbose {

pkg/workflow/action_pins.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ type ActionPin struct {
2424
}
2525

2626
// ActionPinsData represents the structure of the embedded JSON file
27+
// This matches the schema used by ActionCache for consistency
2728
type ActionPinsData struct {
28-
Version string `json:"version"`
29-
Description string `json:"description"`
30-
Actions map[string]ActionPin `json:"actions"`
29+
Entries map[string]ActionPin `json:"entries"` // key: "repo@version"
3130
}
3231

3332
// getActionPins unmarshals and returns the action pins from the embedded JSON
@@ -43,8 +42,8 @@ func getActionPins() []ActionPin {
4342
}
4443

4544
// Convert map to sorted slice
46-
pins := make([]ActionPin, 0, len(data.Actions))
47-
for _, pin := range data.Actions {
45+
pins := make([]ActionPin, 0, len(data.Entries))
46+
for _, pin := range data.Entries {
4847
pins = append(pins, pin)
4948
}
5049

pkg/workflow/data/action_pins.json

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,91 @@
11
{
2-
"version": "1.0",
3-
"description": "Default pinned GitHub Actions with their commit SHAs. These are the 'golden' versions used across all generated workflows.",
4-
"actions": {
5-
"actions/github-script": {
6-
"repo": "actions/github-script",
7-
"version": "v8",
8-
"sha": "ed597411d8f924073f98dfc5c65a23a2325f34cd"
2+
"entries": {
3+
"actions/ai-inference@v1": {
4+
"repo": "actions/ai-inference",
5+
"version": "v1",
6+
"sha": "b81b2afb8390ee6839b494a404766bef6493c7d9"
97
},
10-
"oven-sh/setup-bun": {
11-
"repo": "oven-sh/setup-bun",
12-
"version": "v2",
13-
"sha": "735343b667d3e6f658f44d0eca948eb6282f2b76"
8+
"actions/cache@v4": {
9+
"repo": "actions/cache",
10+
"version": "v4",
11+
"sha": "0057852bfaa89a56745cba8c7296529d2fc39830"
1412
},
15-
"actions/checkout": {
13+
"actions/checkout@v5": {
1614
"repo": "actions/checkout",
1715
"version": "v5",
1816
"sha": "08c6903cd8c0fde910a37f88322edcfb5dd907a8"
1917
},
20-
"actions/download-artifact": {
18+
"actions/download-artifact@v6": {
2119
"repo": "actions/download-artifact",
2220
"version": "v6",
2321
"sha": "018cc2cf5baa6db3ef3c5f8a56943fffe632ef53"
2422
},
25-
"actions/setup-go": {
23+
"actions/github-script@v8": {
24+
"repo": "actions/github-script",
25+
"version": "v8",
26+
"sha": "ed597411d8f924073f98dfc5c65a23a2325f34cd"
27+
},
28+
"actions/setup-dotnet@v4": {
29+
"repo": "actions/setup-dotnet",
30+
"version": "v4",
31+
"sha": "67a3573c9a986a3f9c594539f4ab511d57bb3ce9"
32+
},
33+
"actions/setup-go@v5": {
2634
"repo": "actions/setup-go",
2735
"version": "v5",
2836
"sha": "d35c59abb061a4a6fb18e82ac0862c26744d6ab5"
2937
},
30-
"actions/setup-python": {
31-
"repo": "actions/setup-python",
32-
"version": "v5",
33-
"sha": "a26af69be951a213d495a4c3e4e4022e16d87065"
38+
"actions/setup-java@v4": {
39+
"repo": "actions/setup-java",
40+
"version": "v4",
41+
"sha": "c5195efecf7bdfc987ee8bae7a71cb8b11521c00"
3442
},
35-
"actions/setup-node": {
43+
"actions/setup-node@v6": {
3644
"repo": "actions/setup-node",
3745
"version": "v6",
3846
"sha": "2028fbc5c25fe9cf00d9f06a71cc4710d4507903"
3947
},
40-
"astral-sh/setup-uv": {
48+
"actions/setup-python@v5": {
49+
"repo": "actions/setup-python",
50+
"version": "v5",
51+
"sha": "a26af69be951a213d495a4c3e4e4022e16d87065"
52+
},
53+
"actions/upload-artifact@v5": {
54+
"repo": "actions/upload-artifact",
55+
"version": "v5",
56+
"sha": "330a01c490aca151604b8cf639adc76d48f6c5d4"
57+
},
58+
"astral-sh/setup-uv@v5": {
4159
"repo": "astral-sh/setup-uv",
4260
"version": "v5",
4361
"sha": "e58605a9b6da7c637471fab8847a5e5a6b8df081"
4462
},
45-
"actions/cache": {
46-
"repo": "actions/cache",
47-
"version": "v4",
48-
"sha": "0057852bfaa89a56745cba8c7296529d2fc39830"
49-
},
50-
"denoland/setup-deno": {
63+
"denoland/setup-deno@v2": {
5164
"repo": "denoland/setup-deno",
5265
"version": "v2",
5366
"sha": "e95548e56dfa95d4e1a28d6f422fafe75c4c26fb"
5467
},
55-
"actions/setup-dotnet": {
56-
"repo": "actions/setup-dotnet",
57-
"version": "v4",
58-
"sha": "67a3573c9a986a3f9c594539f4ab511d57bb3ce9"
59-
},
60-
"actions/setup-java": {
61-
"repo": "actions/setup-java",
62-
"version": "v4",
63-
"sha": "c5195efecf7bdfc987ee8bae7a71cb8b11521c00"
64-
},
65-
"actions/upload-artifact": {
66-
"repo": "actions/upload-artifact",
67-
"version": "v5",
68-
"sha": "330a01c490aca151604b8cf639adc76d48f6c5d4"
68+
"erlef/setup-beam@v1": {
69+
"repo": "erlef/setup-beam",
70+
"version": "v1",
71+
"sha": "3559ac3b631a9560f28817e8e7fdde1638664336"
6972
},
70-
"github/codeql-action/upload-sarif": {
73+
"github/codeql-action/upload-sarif@v3": {
7174
"repo": "github/codeql-action/upload-sarif",
7275
"version": "v3",
7376
"sha": "fb2a9d4376843ba94460a73c39ca9a98b33a12ac"
7477
},
75-
"haskell-actions/setup": {
78+
"haskell-actions/setup@v2": {
7679
"repo": "haskell-actions/setup",
7780
"version": "v2",
7881
"sha": "d5d0f498b388e1a0eab1cd150202f664c5738e35"
7982
},
80-
"actions/ai-inference": {
81-
"repo": "actions/ai-inference",
82-
"version": "v1",
83-
"sha": "b81b2afb8390ee6839b494a404766bef6493c7d9"
84-
},
85-
"erlef/setup-beam": {
86-
"repo": "erlef/setup-beam",
87-
"version": "v1",
88-
"sha": "3559ac3b631a9560f28817e8e7fdde1638664336"
83+
"oven-sh/setup-bun@v2": {
84+
"repo": "oven-sh/setup-bun",
85+
"version": "v2",
86+
"sha": "735343b667d3e6f658f44d0eca948eb6282f2b76"
8987
},
90-
"ruby/setup-ruby": {
88+
"ruby/setup-ruby@v1": {
9189
"repo": "ruby/setup-ruby",
9290
"version": "v1",
9391
"sha": "e5517072e87f198d9533967ae13d97c11b604005"

0 commit comments

Comments
 (0)