mirror of https://github.com/actions/toolkit
cache: add support for `zstd --adapt`
Signed-off-by: Sora Morimoto <sora@morimoto.io>pull/1772/head
parent
1db73622df
commit
2faac2af45
|
@ -1,9 +1,14 @@
|
||||||
# @actions/cache Releases
|
# @actions/cache Releases
|
||||||
|
|
||||||
|
### 3.3.0
|
||||||
|
|
||||||
|
- Add support for zstd adapt mode. [#1772](https://github.com/actions/toolkit/pull/1772)
|
||||||
|
- Unlock zstd long mode. [#1772](https://github.com/actions/toolkit/pull/1772)
|
||||||
|
|
||||||
### 3.2.4
|
### 3.2.4
|
||||||
|
|
||||||
- Updated `isGhes` check to include `.ghe.com` and `.ghe.localhost` as accepted hosts
|
- Updated `isGhes` check to include `.ghe.com` and `.ghe.localhost` as accepted hosts
|
||||||
|
|
||||||
### 3.2.3
|
### 3.2.3
|
||||||
|
|
||||||
- Fixed a bug that mutated path arguments to `getCacheVersion` [#1378](https://github.com/actions/toolkit/pull/1378)
|
- Fixed a bug that mutated path arguments to `getCacheVersion` [#1378](https://github.com/actions/toolkit/pull/1378)
|
||||||
|
@ -160,11 +165,11 @@
|
||||||
### 0.2.1
|
### 0.2.1
|
||||||
|
|
||||||
- Fix to await async function getCompressionMethod
|
- Fix to await async function getCompressionMethod
|
||||||
|
|
||||||
### 0.2.0
|
### 0.2.0
|
||||||
|
|
||||||
- Fixes issues with the zstd compression algorithm on Windows and Ubuntu 16.04 [#469](https://github.com/actions/toolkit/pull/469)
|
- Fixes issues with the zstd compression algorithm on Windows and Ubuntu 16.04 [#469](https://github.com/actions/toolkit/pull/469)
|
||||||
|
|
||||||
### 0.1.0
|
### 0.1.0
|
||||||
|
|
||||||
- Initial release
|
- Initial release
|
||||||
|
|
|
@ -71,10 +71,7 @@ test('zstd extract tar', async () => {
|
||||||
]
|
]
|
||||||
.concat(IS_WINDOWS ? ['--force-local'] : [])
|
.concat(IS_WINDOWS ? ['--force-local'] : [])
|
||||||
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
|
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
|
||||||
.concat([
|
.concat(['--use-compress-program', '"zstd -d --long=30"'])
|
||||||
'--use-compress-program',
|
|
||||||
IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
|
|
||||||
])
|
|
||||||
.join(' '),
|
.join(' '),
|
||||||
undefined,
|
undefined,
|
||||||
{
|
{
|
||||||
|
@ -231,10 +228,7 @@ test('zstd create tar', async () => {
|
||||||
]
|
]
|
||||||
.concat(IS_WINDOWS ? ['--force-local'] : [])
|
.concat(IS_WINDOWS ? ['--force-local'] : [])
|
||||||
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
|
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
|
||||||
.concat([
|
.concat(['--use-compress-program', '"zstd -T0 --adapt --long=30"'])
|
||||||
'--use-compress-program',
|
|
||||||
IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
|
|
||||||
])
|
|
||||||
.join(' '),
|
.join(' '),
|
||||||
undefined, // args
|
undefined, // args
|
||||||
{
|
{
|
||||||
|
@ -292,7 +286,7 @@ test('zstd create tar with windows BSDtar', async () => {
|
||||||
expect(execMock).toHaveBeenNthCalledWith(
|
expect(execMock).toHaveBeenNthCalledWith(
|
||||||
2,
|
2,
|
||||||
[
|
[
|
||||||
'zstd -T0 --long=30 --force -o',
|
'zstd -T0 --adapt --long=30 --force -o',
|
||||||
CacheFilename.Zstd.replace(/\\/g, '/'),
|
CacheFilename.Zstd.replace(/\\/g, '/'),
|
||||||
TarFilename.replace(/\\/g, '/')
|
TarFilename.replace(/\\/g, '/')
|
||||||
].join(' '),
|
].join(' '),
|
||||||
|
@ -365,10 +359,7 @@ test('zstd list tar', async () => {
|
||||||
]
|
]
|
||||||
.concat(IS_WINDOWS ? ['--force-local'] : [])
|
.concat(IS_WINDOWS ? ['--force-local'] : [])
|
||||||
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
|
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
|
||||||
.concat([
|
.concat(['--use-compress-program', '"zstd -d --long=30"'])
|
||||||
'--use-compress-program',
|
|
||||||
IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
|
|
||||||
])
|
|
||||||
.join(' '),
|
.join(' '),
|
||||||
undefined,
|
undefined,
|
||||||
{
|
{
|
||||||
|
@ -442,7 +433,7 @@ test('zstdWithoutLong list tar', async () => {
|
||||||
]
|
]
|
||||||
.concat(IS_WINDOWS ? ['--force-local'] : [])
|
.concat(IS_WINDOWS ? ['--force-local'] : [])
|
||||||
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
|
.concat(IS_MAC ? ['--delay-directory-restore'] : [])
|
||||||
.concat(['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd'])
|
.concat(['--use-compress-program', '"zstd -d"'])
|
||||||
.join(' '),
|
.join(' '),
|
||||||
undefined,
|
undefined,
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,10 +102,14 @@ export async function getCompressionMethod(): Promise<CompressionMethod> {
|
||||||
const version = semver.clean(versionOutput)
|
const version = semver.clean(versionOutput)
|
||||||
core.debug(`zstd version: ${version}`)
|
core.debug(`zstd version: ${version}`)
|
||||||
|
|
||||||
if (versionOutput === '') {
|
if (version === null) {
|
||||||
return CompressionMethod.Gzip
|
return CompressionMethod.Gzip
|
||||||
} else {
|
} else if (semver.lt(version, '1.3.2')) {
|
||||||
return CompressionMethod.ZstdWithoutLong
|
return CompressionMethod.ZstdWithoutLong
|
||||||
|
} else if (semver.lt(version, '1.3.6')) {
|
||||||
|
return CompressionMethod.ZstdWithoutAdapt
|
||||||
|
} else {
|
||||||
|
return CompressionMethod.Zstd
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,11 @@ export enum CacheFilename {
|
||||||
export enum CompressionMethod {
|
export enum CompressionMethod {
|
||||||
Gzip = 'gzip',
|
Gzip = 'gzip',
|
||||||
// Long range mode was added to zstd in v1.3.2.
|
// Long range mode was added to zstd in v1.3.2.
|
||||||
// This enum is for earlier version of zstd that does not have --long support
|
// https://github.com/facebook/zstd/releases/tag/v1.3.2
|
||||||
ZstdWithoutLong = 'zstd-without-long',
|
ZstdWithoutLong = 'zstd-without-long',
|
||||||
|
// Adapt mode was added to zstd in v1.3.6.
|
||||||
|
// https://github.com/facebook/zstd/releases/tag/v1.3.6
|
||||||
|
ZstdWithoutAdapt = 'zstd-without-adapt',
|
||||||
Zstd = 'zstd'
|
Zstd = 'zstd'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -172,7 +172,6 @@ async function getDecompressionProgram(
|
||||||
archivePath: string
|
archivePath: string
|
||||||
): Promise<string[]> {
|
): Promise<string[]> {
|
||||||
// -d: Decompress.
|
// -d: Decompress.
|
||||||
// unzstd is equivalent to 'zstd -d'
|
|
||||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||||
// Using 30 here because we also support 32-bit self-hosted runners.
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
||||||
const BSD_TAR_ZSTD =
|
const BSD_TAR_ZSTD =
|
||||||
|
@ -187,10 +186,7 @@ async function getDecompressionProgram(
|
||||||
TarFilename,
|
TarFilename,
|
||||||
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
||||||
]
|
]
|
||||||
: [
|
: ['--use-compress-program', '"zstd -d --long=30"']
|
||||||
'--use-compress-program',
|
|
||||||
IS_WINDOWS ? '"zstd -d --long=30"' : 'unzstd --long=30'
|
|
||||||
]
|
|
||||||
case CompressionMethod.ZstdWithoutLong:
|
case CompressionMethod.ZstdWithoutLong:
|
||||||
return BSD_TAR_ZSTD
|
return BSD_TAR_ZSTD
|
||||||
? [
|
? [
|
||||||
|
@ -198,7 +194,7 @@ async function getDecompressionProgram(
|
||||||
TarFilename,
|
TarFilename,
|
||||||
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
archivePath.replace(new RegExp(`\\${path.sep}`, 'g'), '/')
|
||||||
]
|
]
|
||||||
: ['--use-compress-program', IS_WINDOWS ? '"zstd -d"' : 'unzstd']
|
: ['--use-compress-program', '"zstd -d"']
|
||||||
default:
|
default:
|
||||||
return ['-z']
|
return ['-z']
|
||||||
}
|
}
|
||||||
|
@ -206,7 +202,7 @@ async function getDecompressionProgram(
|
||||||
|
|
||||||
// Used for creating the archive
|
// Used for creating the archive
|
||||||
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
|
||||||
// zstdmt is equivalent to 'zstd -T0'
|
// --adapt: Dynamically adapt compression level to I/O conditions.
|
||||||
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
// --long=#: Enables long distance matching with # bits. Maximum is 30 (1GB) on 32-bit OS and 31 (2GB) on 64-bit.
|
||||||
// Using 30 here because we also support 32-bit self-hosted runners.
|
// Using 30 here because we also support 32-bit self-hosted runners.
|
||||||
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
|
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
|
||||||
|
@ -221,16 +217,21 @@ async function getCompressionProgram(
|
||||||
IS_WINDOWS
|
IS_WINDOWS
|
||||||
switch (compressionMethod) {
|
switch (compressionMethod) {
|
||||||
case CompressionMethod.Zstd:
|
case CompressionMethod.Zstd:
|
||||||
|
return BSD_TAR_ZSTD
|
||||||
|
? [
|
||||||
|
'zstd -T0 --adapt --long=30 --force -o',
|
||||||
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
|
TarFilename
|
||||||
|
]
|
||||||
|
: ['--use-compress-program', '"zstd -T0 --adapt --long=30"']
|
||||||
|
case CompressionMethod.ZstdWithoutAdapt:
|
||||||
return BSD_TAR_ZSTD
|
return BSD_TAR_ZSTD
|
||||||
? [
|
? [
|
||||||
'zstd -T0 --long=30 --force -o',
|
'zstd -T0 --long=30 --force -o',
|
||||||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
TarFilename
|
TarFilename
|
||||||
]
|
]
|
||||||
: [
|
: ['--use-compress-program', '"zstd -T0 --long=30"']
|
||||||
'--use-compress-program',
|
|
||||||
IS_WINDOWS ? '"zstd -T0 --long=30"' : 'zstdmt --long=30'
|
|
||||||
]
|
|
||||||
case CompressionMethod.ZstdWithoutLong:
|
case CompressionMethod.ZstdWithoutLong:
|
||||||
return BSD_TAR_ZSTD
|
return BSD_TAR_ZSTD
|
||||||
? [
|
? [
|
||||||
|
@ -238,7 +239,7 @@ async function getCompressionProgram(
|
||||||
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
cacheFileName.replace(new RegExp(`\\${path.sep}`, 'g'), '/'),
|
||||||
TarFilename
|
TarFilename
|
||||||
]
|
]
|
||||||
: ['--use-compress-program', IS_WINDOWS ? '"zstd -T0"' : 'zstdmt']
|
: ['--use-compress-program', '"zstd -T0"']
|
||||||
default:
|
default:
|
||||||
return ['-z']
|
return ['-z']
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue