Skip to content

Commit 7f9dbc3

Browse files
Copilotpethers
andcommitted
Fix cache keys to remove non-existent file references (code review feedback)
Co-authored-by: pethers <[email protected]>
1 parent 8d60f1d commit 7f9dbc3

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
path: |
6666
~/.cache/pip
6767
~/.local/lib/python3.12/site-packages
68-
key: ${{ runner.os }}-pip-cfn-lint-checkov-${{ hashFiles('**/requirements.txt', '.github/workflows/main.yml') }}
68+
key: ${{ runner.os }}-pip-cfn-lint-checkov-${{ hashFiles('.github/workflows/main.yml') }}
6969
restore-keys: |
7070
${{ runner.os }}-pip-cfn-lint-checkov-
7171
${{ runner.os }}-pip-
@@ -79,7 +79,7 @@ jobs:
7979
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
8080
with:
8181
path: vendor/bundle
82-
key: ${{ runner.os }}-gems-cfn-nag-${{ hashFiles('**/Gemfile.lock', '.github/workflows/main.yml') }}
82+
key: ${{ runner.os }}-gems-cfn-nag-${{ hashFiles('.github/workflows/main.yml') }}
8383
restore-keys: |
8484
${{ runner.os }}-gems-cfn-nag-
8585
${{ runner.os }}-gems-

.github/workflows/pullrequest.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
path: |
4545
~/.cache/pip
4646
~/.local/lib/python3.12/site-packages
47-
key: ${{ runner.os }}-pip-cfn-lint-checkov-${{ hashFiles('**/requirements.txt', '.github/workflows/pullrequest.yml') }}
47+
key: ${{ runner.os }}-pip-cfn-lint-checkov-${{ hashFiles('.github/workflows/pullrequest.yml') }}
4848
restore-keys: |
4949
${{ runner.os }}-pip-cfn-lint-checkov-
5050
${{ runner.os }}-pip-
@@ -58,7 +58,7 @@ jobs:
5858
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
5959
with:
6060
path: vendor/bundle
61-
key: ${{ runner.os }}-gems-cfn-nag-${{ hashFiles('**/Gemfile.lock', '.github/workflows/pullrequest.yml') }}
61+
key: ${{ runner.os }}-gems-cfn-nag-${{ hashFiles('.github/workflows/pullrequest.yml') }}
6262
restore-keys: |
6363
${{ runner.os }}-gems-cfn-nag-
6464
${{ runner.os }}-gems-

CACHING_STRATEGY.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ Caches Python packages for cfn-lint and checkov security scanning tools.
6868
path: |
6969
~/.cache/pip
7070
~/.local/lib/python3.12/site-packages
71-
key: ${{ runner.os }}-pip-cfn-lint-checkov-${{ hashFiles('**/requirements.txt', '.github/workflows/*.yml') }}
71+
key: ${{ runner.os }}-pip-cfn-lint-checkov-${{ hashFiles('.github/workflows/*.yml') }}
7272
restore-keys: |
7373
${{ runner.os }}-pip-cfn-lint-checkov-
7474
${{ runner.os }}-pip-
@@ -79,7 +79,7 @@ Caches Python packages for cfn-lint and checkov security scanning tools.
7979
- `~/.local/lib/python3.12/site-packages` - Installed Python packages
8080

8181
**Cache Key Strategy:**
82-
- Primary key includes requirements.txt and workflow file hashes
82+
- Primary key includes workflow file hash for invalidation on workflow changes
8383
- Multiple restore keys for progressive fallback
8484
- Tool-specific prefix for better cache organization
8585

@@ -103,7 +103,7 @@ Caches Ruby gems for cfn-nag security scanning tool.
103103
uses: actions/cache@9255dc7a253b0ccc959486e2bca901246202afeb # v5.0.1
104104
with:
105105
path: vendor/bundle
106-
key: ${{ runner.os }}-gems-cfn-nag-${{ hashFiles('**/Gemfile.lock', '.github/workflows/*.yml') }}
106+
key: ${{ runner.os }}-gems-cfn-nag-${{ hashFiles('.github/workflows/*.yml') }}
107107
restore-keys: |
108108
${{ runner.os }}-gems-cfn-nag-
109109
${{ runner.os }}-gems-
@@ -113,7 +113,7 @@ Caches Ruby gems for cfn-nag security scanning tool.
113113
- `vendor/bundle` - Bundler gem installation directory
114114

115115
**Cache Key Strategy:**
116-
- Primary key includes Gemfile.lock and workflow file hashes
116+
- Primary key includes workflow file hash for invalidation on workflow changes
117117
- Multiple restore keys for progressive fallback
118118
- Tool-specific prefix for better cache organization
119119

@@ -183,9 +183,10 @@ Caches Docker image layers for ZAP API security scanning.
183183
### When Caches Are Invalidated
184184

185185
1. **Workflow File Changes**: Cache key includes workflow file hash
186-
2. **Dependency Changes**: Cache key includes requirements.txt, Gemfile.lock hashes
187-
3. **OS Changes**: Cache key includes runner.os
188-
4. **Manual Invalidation**: Update cache key prefix in workflow
186+
2. **OS Changes**: Cache key includes runner.os
187+
3. **Manual Invalidation**: Update cache key prefix in workflow
188+
189+
**Note**: Since the repository doesn't have requirements.txt or Gemfile.lock files (dependencies are managed by composite actions), the cache keys are based on workflow file hashes. This means caches will be invalidated when workflows are modified.
189190

190191
### Automatic Fallback
191192

0 commit comments

Comments
 (0)