Compare commits

..

1 Commits

Author SHA1 Message Date
Lovepreet Singh bc772ce6eb Move zstd to use long-form flags instead of short-form 2022-07-14 22:17:00 +05:30
6 changed files with 6393 additions and 7155 deletions
+6379 -7129
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -24,7 +24,7 @@
"eslint-plugin-jest": "^22.21.0",
"flow-bin": "^0.115.0",
"jest": "^27.2.5",
"lerna": "^5.2.0",
"lerna": "^4.0.0",
"prettier": "^1.19.1",
"ts-jest": "^27.0.5",
"typescript": "^3.9.9"
-6
View File
@@ -32,9 +32,3 @@ 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)
})
+4 -4
View File
@@ -50,7 +50,7 @@ test('zstd extract tar', async () => {
`"${defaultTarPath}"`,
[
'--use-compress-program',
'unzstd --long=30',
'zstd -d --long=30',
'-xf',
IS_WINDOWS ? archivePath.replace(/\\/g, '/') : archivePath,
'-P',
@@ -140,7 +140,7 @@ test('zstd create tar', async () => {
[
'--posix',
'--use-compress-program',
'zstdmt --long=30',
'zstd -T0 --long=30',
'-cf',
IS_WINDOWS ? CacheFilename.Zstd.replace(/\\/g, '/') : CacheFilename.Zstd,
'--exclude',
@@ -210,7 +210,7 @@ test('zstd list tar', async () => {
`"${defaultTarPath}"`,
[
'--use-compress-program',
'unzstd --long=30',
'zstd -d --long=30',
'-tf',
IS_WINDOWS ? archivePath.replace(/\\/g, '/') : archivePath,
'-P'
@@ -235,7 +235,7 @@ test('zstdWithoutLong list tar', async () => {
`"${defaultTarPath}"`,
[
'--use-compress-program',
'unzstd',
'zstd -d',
'-tf',
IS_WINDOWS ? archivePath.replace(/\\/g, '/') : archivePath,
'-P'
+1 -6
View File
@@ -52,12 +52,7 @@ 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}`)
}
paths.push(`${relativeFile}`)
}
return paths
+8 -9
View File
@@ -61,15 +61,15 @@ export async function extractTar(
// Create directory to extract tar into
const workingDirectory = getWorkingDirectory()
await io.mkdirP(workingDirectory)
// --d: Decompress.
// --decompress: Decompress.
// --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.
function getCompressionProgram(): string[] {
switch (compressionMethod) {
case CompressionMethod.Zstd:
return ['--use-compress-program', 'unzstd --long=30']
return ['--use-compress-program', 'zstd --decompress --long=30']
case CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'unzstd']
return ['--use-compress-program', 'zstd --decompress']
default:
return ['-z']
}
@@ -99,16 +99,16 @@ export async function createTar(
)
const workingDirectory = getWorkingDirectory()
// -T#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
// --threads=#: Compress using # working thread. If # is 0, attempt to detect and use the number of physical CPU cores.
// --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.
// Long range mode is added to zstd in v1.3.2 release, so we will not use --long in older version of zstd.
function getCompressionProgram(): string[] {
switch (compressionMethod) {
case CompressionMethod.Zstd:
return ['--use-compress-program', 'zstdmt --long=30']
return ['--use-compress-program', 'zstd --threads=0 --long=30']
case CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'zstdmt']
return ['--use-compress-program', 'zstd --threads=0']
default:
return ['-z']
}
@@ -133,16 +133,15 @@ export async function listTar(
archivePath: string,
compressionMethod: CompressionMethod
): Promise<void> {
// --d: Decompress.
// --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.
function getCompressionProgram(): string[] {
switch (compressionMethod) {
case CompressionMethod.Zstd:
return ['--use-compress-program', 'unzstd --long=30']
return ['--use-compress-program', 'zstd --long=30']
case CompressionMethod.ZstdWithoutLong:
return ['--use-compress-program', 'unzstd']
return ['--use-compress-program', 'zstd']
default:
return ['-z']
}