1
0
Fork 0

Merge pull request #1132 from actions/pdotl-empty-cache-bugfix

Fix Empty Cache save when the path is github workspace directory
pull/1138/head
Lovepreet Singh 2022-07-26 14:34:01 +05:30 committed by GitHub
commit 74ff60c561
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -32,3 +32,9 @@ test('assertDefined throws if undefined', () => {
test('assertDefined returns value', () => {
expect(cacheUtils.assertDefined('test', 5)).toBe(5)
})
test('resolvePaths works on github workspace directory', async () => {
const workspace = process.env['GITHUB_WORKSPACE'] ?? '.'
const paths = await cacheUtils.resolvePaths([workspace])
expect(paths.length).toBeGreaterThan(0)
})

View File

@ -52,8 +52,13 @@ export async function resolvePaths(patterns: string[]): Promise<string[]> {
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
core.debug(`Matched: ${relativeFile}`)
// Paths are made relative so the tar entries are all relative to the root of the workspace.
if (relativeFile === '') {
// path.relative returns empty string if workspace and file are equal
paths.push('.')
} else {
paths.push(`${relativeFile}`)
}
}
return paths
}