Skip to content

Commit

Permalink
Merge pull request actions#767 from actions/dhadka/fix-permissions
Browse files Browse the repository at this point in the history
Fix permissions issues using gtar on mac
  • Loading branch information
dhadka authored Apr 9, 2021
2 parents a6966e3 + aad34ab commit 634dc61
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 10 deletions.
5 changes: 4 additions & 1 deletion packages/cache/RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,7 @@

### 1.0.6
- Make caching more verbose [#650](https://github.com/actions/toolkit/pull/650)
- Use GNU tar on macOS if available [#701](https://github.com/actions/toolkit/pull/701)
- Use GNU tar on macOS if available [#701](https://github.com/actions/toolkit/pull/701)

### 1.0.7
- Fixes permissions issue extracting archives with GNU tar on macOS ([issue](https://github.com/actions/cache/issues/527))
23 changes: 16 additions & 7 deletions packages/cache/__tests__/tar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jest.mock('@actions/exec')
jest.mock('@actions/io')

const IS_WINDOWS = process.platform === 'win32'
const IS_MAC = process.platform === 'darwin'

const defaultTarPath = process.platform === 'darwin' ? 'gtar' : 'tar'

Expand Down Expand Up @@ -55,7 +56,9 @@ test('zstd extract tar', async () => {
'-P',
'-C',
IS_WINDOWS ? workspace?.replace(/\\/g, '/') : workspace
].concat(IS_WINDOWS ? ['--force-local'] : []),
]
.concat(IS_WINDOWS ? ['--force-local'] : [])
.concat(IS_MAC ? ['--delay-directory-restore'] : []),
{cwd: undefined}
)
})
Expand Down Expand Up @@ -84,7 +87,7 @@ test('gzip extract tar', async () => {
'-P',
'-C',
IS_WINDOWS ? workspace?.replace(/\\/g, '/') : workspace
],
].concat(IS_MAC ? ['--delay-directory-restore'] : []),
{cwd: undefined}
)
})
Expand Down Expand Up @@ -145,7 +148,9 @@ test('zstd create tar', async () => {
IS_WINDOWS ? workspace?.replace(/\\/g, '/') : workspace,
'--files-from',
'manifest.txt'
].concat(IS_WINDOWS ? ['--force-local'] : []),
]
.concat(IS_WINDOWS ? ['--force-local'] : [])
.concat(IS_MAC ? ['--delay-directory-restore'] : []),
{
cwd: archiveFolder
}
Expand Down Expand Up @@ -180,7 +185,7 @@ test('gzip create tar', async () => {
IS_WINDOWS ? workspace?.replace(/\\/g, '/') : workspace,
'--files-from',
'manifest.txt'
],
].concat(IS_MAC ? ['--delay-directory-restore'] : []),
{
cwd: archiveFolder
}
Expand All @@ -205,7 +210,9 @@ test('zstd list tar', async () => {
'-tf',
IS_WINDOWS ? archivePath.replace(/\\/g, '/') : archivePath,
'-P'
].concat(IS_WINDOWS ? ['--force-local'] : []),
]
.concat(IS_WINDOWS ? ['--force-local'] : [])
.concat(IS_MAC ? ['--delay-directory-restore'] : []),
{cwd: undefined}
)
})
Expand All @@ -228,7 +235,9 @@ test('zstdWithoutLong list tar', async () => {
'-tf',
IS_WINDOWS ? archivePath.replace(/\\/g, '/') : archivePath,
'-P'
].concat(IS_WINDOWS ? ['--force-local'] : []),
]
.concat(IS_WINDOWS ? ['--force-local'] : [])
.concat(IS_MAC ? ['--delay-directory-restore'] : []),
{cwd: undefined}
)
})
Expand All @@ -252,7 +261,7 @@ test('gzip list tar', async () => {
'-tf',
IS_WINDOWS ? archivePath.replace(/\\/g, '/') : archivePath,
'-P'
],
].concat(IS_MAC ? ['--delay-directory-restore'] : []),
{cwd: undefined}
)
})
2 changes: 1 addition & 1 deletion packages/cache/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@actions/cache",
"version": "1.0.6",
"version": "1.0.7",
"preview": true,
"description": "Actions cache lib",
"keywords": [
Expand Down
2 changes: 2 additions & 0 deletions packages/cache/src/internal/tar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ async function getTarPath(
case 'darwin': {
const gnuTar = await io.which('gtar', false)
if (gnuTar) {
// fix permission denied errors when extracting BSD tar archive with GNU tar - https://github.com/actions/cache/issues/527
args.push('--delay-directory-restore')
return gnuTar
}
break
Expand Down

0 comments on commit 634dc61

Please sign in to comment.