Skip to content

Commit

Permalink
replace throw with warn
Browse files Browse the repository at this point in the history
  • Loading branch information
dsame committed Dec 9, 2022
1 parent 676975d commit d0c43c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
3 changes: 2 additions & 1 deletion __tests__/cache-utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ describe('cache-utils', () => {
isFeatureAvailable.mockImplementation(() => false);
process.env['GITHUB_SERVER_URL'] = 'https://www.test.com';

expect(() => isCacheFeatureAvailable()).toThrowError(
expect(isCacheFeatureAvailable()).toBeFalsy();
expect(warningSpy).toHaveBeenCalledWith(
'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.'
);
});
Expand Down
6 changes: 4 additions & 2 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -61187,8 +61187,10 @@ exports.isGhes = isGhes;
function isCacheFeatureAvailable() {
if (cache.isFeatureAvailable())
return true;
if (isGhes())
throw new Error('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.');
if (isGhes()) {
core.warning('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.');
return false;
}
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73141,8 +73141,10 @@ exports.isGhes = isGhes;
function isCacheFeatureAvailable() {
if (cache.isFeatureAvailable())
return true;
if (isGhes())
throw new Error('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.');
if (isGhes()) {
core.warning('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.');
return false;
}
core.warning('The runner was not able to contact the cache service. Caching will be skipped');
return false;
}
Expand Down
6 changes: 4 additions & 2 deletions src/cache-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,12 @@ export function isGhes(): boolean {
export function isCacheFeatureAvailable(): boolean {
if (cache.isFeatureAvailable()) return true;

if (isGhes())
throw new Error(
if (isGhes()) {
core.warning(
'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.'
);
return false;
}

core.warning(
'The runner was not able to contact the cache service. Caching will be skipped'
Expand Down

0 comments on commit d0c43c2

Please sign in to comment.