mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-22 01:49:07 +08:00
Merge pull request #1132 from actions/pdotl-empty-cache-bugfix
Fix Empty Cache save when the path is github workspace directory
This commit is contained in:
commit
74ff60c561
6
packages/cache/__tests__/cacheUtils.test.ts
vendored
6
packages/cache/__tests__/cacheUtils.test.ts
vendored
@ -32,3 +32,9 @@ test('assertDefined throws if undefined', () => {
|
|||||||
test('assertDefined returns value', () => {
|
test('assertDefined returns value', () => {
|
||||||
expect(cacheUtils.assertDefined('test', 5)).toBe(5)
|
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)
|
||||||
|
})
|
||||||
|
7
packages/cache/src/internal/cacheUtils.ts
vendored
7
packages/cache/src/internal/cacheUtils.ts
vendored
@ -52,7 +52,12 @@ export async function resolvePaths(patterns: string[]): Promise<string[]> {
|
|||||||
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
||||||
core.debug(`Matched: ${relativeFile}`)
|
core.debug(`Matched: ${relativeFile}`)
|
||||||
// Paths are made relative so the tar entries are all relative to the root of the workspace.
|
// Paths are made relative so the tar entries are all relative to the root of the workspace.
|
||||||
paths.push(`${relativeFile}`)
|
if (relativeFile === '') {
|
||||||
|
// path.relative returns empty string if workspace and file are equal
|
||||||
|
paths.push('.')
|
||||||
|
} else {
|
||||||
|
paths.push(`${relativeFile}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return paths
|
return paths
|
||||||
|
Loading…
x
Reference in New Issue
Block a user