@@ -206,6 +206,51 @@ describe("loadInputs", () => {
206206 expect ( inputs . enableCache ) . toBe ( true ) ;
207207 } ) ;
208208
209+ it ( "restores but does not save cache automatically for merge groups" , ( ) => {
210+ mockInputs [ "working-directory" ] = "/workspace" ;
211+ mockInputs [ "enable-cache" ] = "auto" ;
212+ mockInputs [ "restore-cache" ] = "true" ;
213+ mockInputs [ "save-cache" ] = "auto" ;
214+ process . env . RUNNER_ENVIRONMENT = "github-hosted" ;
215+ process . env . RUNNER_TEMP = "/runner-temp" ;
216+ process . env . GITHUB_EVENT_NAME = "merge_group" ;
217+
218+ const inputs = loadInputs ( ) ;
219+
220+ expect ( inputs . enableCache ) . toBe ( true ) ;
221+ expect ( inputs . restoreCache ) . toBe ( true ) ;
222+ expect ( inputs . saveCache ) . toBe ( false ) ;
223+ expect ( mockInfo ) . toHaveBeenCalledWith (
224+ "Cache saving is disabled for the merge_group event" ,
225+ ) ;
226+ } ) ;
227+
228+ it . each ( [
229+ [ "true" , true ] ,
230+ [ "false" , false ] ,
231+ ] ) ( "honors save-cache %s for merge groups" , ( saveCacheInput , expected ) => {
232+ mockInputs [ "working-directory" ] = "/workspace" ;
233+ mockInputs [ "save-cache" ] = saveCacheInput ;
234+ process . env . GITHUB_EVENT_NAME = "merge_group" ;
235+
236+ const inputs = loadInputs ( ) ;
237+
238+ expect ( inputs . saveCache ) . toBe ( expected ) ;
239+ expect ( mockInfo ) . not . toHaveBeenCalledWith (
240+ "Cache saving is disabled for the merge_group event" ,
241+ ) ;
242+ } ) ;
243+
244+ it ( "automatically saves cache for other events" , ( ) => {
245+ mockInputs [ "working-directory" ] = "/workspace" ;
246+ mockInputs [ "save-cache" ] = "auto" ;
247+ process . env . GITHUB_EVENT_NAME = "push" ;
248+
249+ const inputs = loadInputs ( ) ;
250+
251+ expect ( inputs . saveCache ) . toBe ( true ) ;
252+ } ) ;
253+
209254 it ( "uses cache-dir from pyproject.toml when present" , ( ) => {
210255 mockInputs [ "working-directory" ] = createTempProject ( {
211256 "pyproject.toml" : `[project]
0 commit comments