Skip to content

Commit 8a24e1e

Browse files
Copilotpelikhan
andcommitted
Fix update_cache_memory job to not be created for restore-only caches
- Move setup action addition to after the check for writable caches - Ensures update_cache_memory job is not created when all caches are restore-only - Fixes TestCacheMemoryWithThreatDetection test Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
1 parent d12c5ba commit 8a24e1e

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

.github/workflows/issue-classifier.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/release.lock.yml

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

.github/workflows/stale-repo-identifier.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/super-linter.lock.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/workflow/cache.go

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -560,24 +560,6 @@ func (c *Compiler) buildUpdateCacheMemoryJob(data *WorkflowData, threatDetection
560560

561561
var steps []string
562562

563-
// Add setup step to copy scripts
564-
setupActionRef := c.resolveActionReference("./actions/setup", data)
565-
if setupActionRef != "" {
566-
// For dev mode (local action path), checkout the actions folder first
567-
if c.actionMode.IsDev() {
568-
steps = append(steps, " - name: Checkout actions folder\n")
569-
steps = append(steps, fmt.Sprintf(" uses: %s\n", GetActionPin("actions/checkout")))
570-
steps = append(steps, " with:\n")
571-
steps = append(steps, " sparse-checkout: |\n")
572-
steps = append(steps, " actions\n")
573-
}
574-
575-
steps = append(steps, " - name: Setup Scripts\n")
576-
steps = append(steps, fmt.Sprintf(" uses: %s\n", setupActionRef))
577-
steps = append(steps, " with:\n")
578-
steps = append(steps, fmt.Sprintf(" destination: %s\n", SetupActionDestination))
579-
}
580-
581563
// Build steps for each cache
582564
for _, cache := range data.CacheMemoryConfig.Caches {
583565
// Skip restore-only caches
@@ -636,6 +618,28 @@ func (c *Compiler) buildUpdateCacheMemoryJob(data *WorkflowData, threatDetection
636618
return nil, nil
637619
}
638620

621+
// Add setup step to copy scripts at the beginning
622+
var setupSteps []string
623+
setupActionRef := c.resolveActionReference("./actions/setup", data)
624+
if setupActionRef != "" {
625+
// For dev mode (local action path), checkout the actions folder first
626+
if c.actionMode.IsDev() {
627+
setupSteps = append(setupSteps, " - name: Checkout actions folder\n")
628+
setupSteps = append(setupSteps, fmt.Sprintf(" uses: %s\n", GetActionPin("actions/checkout")))
629+
setupSteps = append(setupSteps, " with:\n")
630+
setupSteps = append(setupSteps, " sparse-checkout: |\n")
631+
setupSteps = append(setupSteps, " actions\n")
632+
}
633+
634+
setupSteps = append(setupSteps, " - name: Setup Scripts\n")
635+
setupSteps = append(setupSteps, fmt.Sprintf(" uses: %s\n", setupActionRef))
636+
setupSteps = append(setupSteps, " with:\n")
637+
setupSteps = append(setupSteps, fmt.Sprintf(" destination: %s\n", SetupActionDestination))
638+
}
639+
640+
// Prepend setup steps to all cache steps
641+
steps = append(setupSteps, steps...)
642+
639643
// Job condition: only run if detection passed
640644
jobCondition := "always() && needs.detection.outputs.success == 'true'"
641645

0 commit comments

Comments
 (0)