mirror of
				https://github.com/actions/cache.git
				synced 2025-10-31 14:30:54 +00:00 
			
		
		
		
	Enabling actions/cache for GHES based on presence of AC service (#774)
* initial changes * Update package-lock.json * Update package-lock.json * review comments and updated test cases * package.json * changed name * added new line * changed tookit * updated with 2.0 * changed with public released package * ran code format * linting errors * Update actionUtils.test.ts * Update cache.dep.yml * Update package.json * Update README.md * Create RELEASES.md * Update RELEASES.md * Update package.json * Update package-lock.json * typo
This commit is contained in:
		
					parent
					
						
							
								7d4f40b464
							
						
					
				
			
			
				commit
				
					
						136d96b4ae
					
				
			
		
					 13 changed files with 7680 additions and 105 deletions
				
			
		|  | @ -1,3 +1,4 @@ | |||
| import * as cache from "@actions/cache"; | ||||
| import * as core from "@actions/core"; | ||||
| 
 | ||||
| import { Events, Outputs, RefKey, State } from "../src/constants"; | ||||
|  | @ -5,6 +6,7 @@ import * as actionUtils from "../src/utils/actionUtils"; | |||
| import * as testUtils from "../src/utils/testUtils"; | ||||
| 
 | ||||
| jest.mock("@actions/core"); | ||||
| jest.mock("@actions/cache"); | ||||
| 
 | ||||
| beforeAll(() => { | ||||
|     jest.spyOn(core, "getInput").mockImplementation((name, options) => { | ||||
|  | @ -232,3 +234,41 @@ test("getInputAsInt throws if required and value missing", () => { | |||
|         actionUtils.getInputAsInt("undefined", { required: true }) | ||||
|     ).toThrowError(); | ||||
| }); | ||||
| 
 | ||||
| test("isCacheFeatureAvailable for ac enabled", () => { | ||||
|     jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => true); | ||||
| 
 | ||||
|     expect(actionUtils.isCacheFeatureAvailable()).toBe(true); | ||||
| }); | ||||
| 
 | ||||
| test("isCacheFeatureAvailable for ac disabled on GHES", () => { | ||||
|     jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => false); | ||||
| 
 | ||||
|     const message = | ||||
|         "Cache action is only supported on GHES version >= 3.5. If you are on version >=3.5 Please check with GHES admin if Actions cache service is enabled or not."; | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| 
 | ||||
|     try { | ||||
|         process.env["GITHUB_SERVER_URL"] = "http://example.com"; | ||||
|         expect(actionUtils.isCacheFeatureAvailable()).toBe(false); | ||||
|         expect(infoMock).toHaveBeenCalledWith(`[warning]${message}`); | ||||
|     } finally { | ||||
|         delete process.env["GITHUB_SERVER_URL"]; | ||||
|     } | ||||
| }); | ||||
| 
 | ||||
| test("isCacheFeatureAvailable for ac disabled on dotcom", () => { | ||||
|     jest.spyOn(cache, "isFeatureAvailable").mockImplementation(() => false); | ||||
| 
 | ||||
|     const message = | ||||
|         "An internal error has occurred in cache backend. Please check https://www.githubstatus.com/ for any ongoing issue in actions."; | ||||
|     const infoMock = jest.spyOn(core, "info"); | ||||
| 
 | ||||
|     try { | ||||
|         process.env["GITHUB_SERVER_URL"] = "http://github.com"; | ||||
|         expect(actionUtils.isCacheFeatureAvailable()).toBe(false); | ||||
|         expect(infoMock).toHaveBeenCalledWith(`[warning]${message}`); | ||||
|     } finally { | ||||
|         delete process.env["GITHUB_SERVER_URL"]; | ||||
|     } | ||||
| }); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue