Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Cache Error Message for Improved Clarity #947

Closed
4 changes: 1 addition & 3 deletions __tests__/cache-restore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,7 @@ virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/patrick/Library/Caches/py
);

await expect(cacheDistributor.restoreCache()).rejects.toThrow(
`No file in ${process.cwd()} matched to [${cacheDependencyPath
.split('\n')
.join(',')}], make sure you have checked out the target repository`
`The cache folder path(s) for the package manager "pipenv" were retrieved but do not exist on the disk. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`
);
}
);
Expand Down
4 changes: 2 additions & 2 deletions dist/cache-save/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -81041,7 +81041,7 @@ class CacheDistributor {
.split('\n')
.join(',')} or ${constants_1.CACHE_DEPENDENCY_BACKUP_PATH}`
: this.cacheDependencyPath.split('\n').join(',');
throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`);
throw new Error(`The cache folder path(s) for the package manager "${this.packageManager}" were retrieved but do not exist on the disk. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`);
}
const cachePath = yield this.getCacheGlobalDirectories();
core.saveState(State.CACHE_PATHS, cachePath);
Expand Down Expand Up @@ -81165,7 +81165,7 @@ function saveCache(packageManager) {
const cachePaths = JSON.parse(cachePathState);
core.debug(`paths for caching are ${cachePaths.join(', ')}`);
if (!isCacheDirectoryExists(cachePaths)) {
throw new Error(`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(', ')}`);
throw new Error(`The cache folder path(s) for the package manager "${packageManager}" were retrieved but do not exist on the disk. The following paths were checked: ${cachePaths.join(', ')}. No cache paths were identified for "${packageManager}" with the cached paths. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`);
}
const primaryKey = core.getState(cache_distributor_1.State.STATE_CACHE_PRIMARY_KEY);
const matchedKey = core.getState(cache_distributor_1.State.CACHE_MATCHED_KEY);
Expand Down
2 changes: 1 addition & 1 deletion dist/setup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90243,7 +90243,7 @@ class CacheDistributor {
.split('\n')
.join(',')} or ${constants_1.CACHE_DEPENDENCY_BACKUP_PATH}`
: this.cacheDependencyPath.split('\n').join(',');
throw new Error(`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`);
throw new Error(`The cache folder path(s) for the package manager "${this.packageManager}" were retrieved but do not exist on the disk. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`);
}
const cachePath = yield this.getCacheGlobalDirectories();
core.saveState(State.CACHE_PATHS, cachePath);
Expand Down
2 changes: 1 addition & 1 deletion src/cache-distributions/cache-distributor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@
public async restoreCache() {
const {primaryKey, restoreKey} = await this.computeKeys();
if (primaryKey.endsWith('-')) {
const file =

Check warning on line 28 in src/cache-distributions/cache-distributor.ts

View workflow job for this annotation

GitHub Actions / Basic validation / build (ubuntu-latest)

'file' is assigned a value but never used

Check warning on line 28 in src/cache-distributions/cache-distributor.ts

View workflow job for this annotation

GitHub Actions / Basic validation / build (windows-latest)

'file' is assigned a value but never used

Check warning on line 28 in src/cache-distributions/cache-distributor.ts

View workflow job for this annotation

GitHub Actions / Basic validation / build (macos-latest)

'file' is assigned a value but never used
this.packageManager === 'pip'
? `${this.cacheDependencyPath
.split('\n')
.join(',')} or ${CACHE_DEPENDENCY_BACKUP_PATH}`
: this.cacheDependencyPath.split('\n').join(',');
throw new Error(
`No file in ${process.cwd()} matched to [${file}], make sure you have checked out the target repository`
`The cache folder path(s) for the package manager "${this.packageManager}" were retrieved but do not exist on the disk. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`
);
}

Expand Down
4 changes: 2 additions & 2 deletions src/cache-save.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ async function saveCache(packageManager: string) {

if (!isCacheDirectoryExists(cachePaths)) {
throw new Error(
`Cache folder path is retrieved for ${packageManager} but doesn't exist on disk: ${cachePaths.join(
`The cache folder path(s) for the package manager "${packageManager}" were retrieved but do not exist on the disk. The following paths were checked: ${cachePaths.join(
', '
)}`
)}. No cache paths were identified for "${packageManager}" with the cached paths. This likely indicates that there are no dependencies to cache. Consider removing the cache step if it is not needed.`
);
}

Expand Down
Loading