Commit bf92df3
ci: fix Windows npm cache corruption (ECOMPROMISED error)
Fix fundamental issue causing "npm error code ECOMPROMISED" in Windows CI.
Root Cause Analysis:
--------------------
1. Environment Variable Timing Issue:
- Writing to $env:GITHUB_ENV only affects FUTURE steps, not current step
- Previous workflow: Set NPM_CONFIG_CACHE in GITHUB_ENV, then ran
"npm cache clean" in SAME step
- Result: Cache clean ran against DEFAULT cache, not configured cache
2. Configuration Order Issue:
- NPM_CONFIG_PREFIX was set AFTER installing promptfoo globally
- npm install used default prefix, then config pointed to different location
- Created mismatch between package location and npm expectations
- Caused cache lock file integrity errors (ECOMPROMISED)
3. Cache Clean Timing:
- Cache was cleaned before configuring where cache should be located
- Wrong cache was cleaned, leaving actual cache potentially corrupted
The Fix:
--------
- Use "npm config set" to configure cache/prefix IMMEDIATELY (not GITHUB_ENV)
- Configure cache location FIRST
- Configure prefix location SECOND
- Clean and verify cache THIRD (now cleans correctly-configured cache)
- Only THEN export to GITHUB_ENV for future steps
- Consolidated "Add npm global bin to PATH" into single configuration step
Changes Applied to Both Jobs:
- test: Uses global promptfoo install
- test-npx-fallback: Uses npx fallback (no global install)
This ensures npm configuration is consistent and cache integrity is maintained
across all Windows CI runs.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 4ebee1b commit bf92df3
1 file changed
+54
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
79 | 79 | | |
80 | 80 | | |
81 | 81 | | |
82 | | - | |
| 82 | + | |
83 | 83 | | |
| 84 | + | |
84 | 85 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
98 | 94 | | |
99 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
| 107 | + | |
| 108 | + | |
102 | 109 | | |
103 | 110 | | |
104 | 111 | | |
105 | 112 | | |
106 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
107 | 122 | | |
108 | 123 | | |
109 | 124 | | |
| |||
138 | 153 | | |
139 | 154 | | |
140 | 155 | | |
141 | | - | |
| 156 | + | |
142 | 157 | | |
| 158 | + | |
143 | 159 | | |
144 | | - | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
145 | 174 | | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
146 | 184 | | |
147 | 185 | | |
148 | 186 | | |
| |||
0 commit comments