MCPcopy Create free account
hub / github.com/github/gh-aw / buildDailyAICUsageCacheSteps

Function buildDailyAICUsageCacheSteps

pkg/workflow/notify_comment.go:141–189  ·  view source on GitHub ↗

buildDailyAICUsageCacheSteps creates steps that compute AIC for the current run and persist it to a per-workflow JSONL cache via actions/cache/save. The cache is restored by the activation job so that subsequent guardrail checks can skip artifact downloads for known runs. The sequence is: restore

(data *WorkflowData, pinAction func(string) string)

Source from the content-addressed store, hash-verified

139// The restore step uses a prefix restore-key so it picks up the most recent snapshot even when
140// the exact key (which includes the current run ID) does not exist yet.
141func buildDailyAICUsageCacheSteps(data *WorkflowData, pinAction func(string) string) []string {
142 sanitized := SanitizeWorkflowIDForCacheKey(data.WorkflowID)
143 cacheKeyPrefix := fmt.Sprintf("agentic-workflow-usage-%s-", sanitized)
144 cacheKey := cacheKeyPrefix + "${{ github.run_id }}"
145 return []string{
146 " - name: Restore daily AIC usage cache\n",
147 " id: restore-daily-aic-cache-conclusion\n",
148 " if: always()\n",
149 " continue-on-error: true\n",
150 fmt.Sprintf(" uses: %s\n", pinAction("actions/cache/restore")),
151 " with:\n",
152 fmt.Sprintf(" key: %s\n", cacheKey),
153 fmt.Sprintf(" restore-keys: %s\n", cacheKeyPrefix),
154 " path: /tmp/gh-aw/agentic-workflow-usage-cache.jsonl\n",
155 " - name: Write daily AIC usage cache entry\n",
156 " id: write-daily-aic-cache\n",
157 " if: always()\n",
158 " continue-on-error: true\n",
159 fmt.Sprintf(" uses: %s\n", pinAction("actions/github-script")),
160 " with:\n",
161 " github-token: ${{ github.token }}\n",
162 " script: |\n",
163 " const { setupGlobals } = require('" + SetupActionDestination + "/setup_globals.cjs');\n",
164 " setupGlobals(core, github, context);\n",
165 " const { main } = require('" + SetupActionDestination + "/write_daily_aic_usage_cache.cjs');\n",
166 " await main();\n",
167 " - name: Save daily AIC usage cache\n",
168 " id: save-daily-aic-cache\n",
169 " if: always()\n",
170 " continue-on-error: true\n",
171 fmt.Sprintf(" uses: %s\n", pinAction("actions/cache/save")),
172 " with:\n",
173 fmt.Sprintf(" key: %s\n", cacheKey),
174 " path: /tmp/gh-aw/agentic-workflow-usage-cache.jsonl\n",
175 // Upload the cache file as an artifact so the activation job's artifact-based
176 // fallback can retrieve it on a different PR branch where actions/cache is
177 // branch-scoped and would otherwise always miss.
178 " - name: Upload daily AIC usage cache artifact\n",
179 " id: upload-daily-aic-cache\n",
180 " if: always()\n",
181 " continue-on-error: true\n",
182 fmt.Sprintf(" uses: %s\n", pinAction("actions/upload-artifact")),
183 " with:\n",
184 " name: aic-usage-cache\n",
185 " path: /tmp/gh-aw/agentic-workflow-usage-cache.jsonl\n",
186 " if-no-files-found: ignore\n",
187 " retention-days: 7\n",
188 }
189}
190
191// isGroupConcurrencyQueueEnabled reports whether compiler-generated concurrency groups
192// should include queue: max. The feature is enabled by default and can be disabled

Callers 1

Calls 1

Tested by

no test coverage detected