From aebf1f5f2e801739c13337e27555d6f6e6c7ba1c Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 10:05:34 +0000 Subject: [PATCH 01/15] Add debug statements --- src/internal/cacheUtils.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index ea1e7de..02a2e98 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -95,7 +95,9 @@ async function getVersion(app: string): Promise { // Use zstandard if possible to maximize cache performance export async function getCompressionMethod(): Promise { const versionOutput = await getVersion('zstd') + core.debug(`versionOutput: ${versionOutput}`) const version = semver.clean(versionOutput) + core.debug(`version: ${version}`) if (!versionOutput.toLowerCase().includes('zstd command line interface')) { // zstd is not installed From 4809ec01529aefa639dcc0af359f5fefbec93fcd Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 10:30:41 +0000 Subject: [PATCH 02/15] Test passing quiet as argument --- src/internal/cacheUtils.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index 02a2e98..e413d10 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -3,6 +3,7 @@ import * as exec from '@actions/exec' import * as glob from '@actions/glob' import * as io from '@actions/io' import * as fs from 'fs' +import { type } from 'os' import * as path from 'path' import * as semver from 'semver' import * as util from 'util' @@ -71,11 +72,13 @@ export async function unlinkFile(filePath: fs.PathLike): Promise { return util.promisify(fs.unlink)(filePath) } -async function getVersion(app: string): Promise { +async function getVersion(app: string, args?: string[]): Promise { core.debug(`Checking ${app} --version`) let versionOutput = '' + typeof args !== 'undefined' ? args : (args = []) + args.push('--version') try { - await exec.exec(`${app} --version`, [], { + await exec.exec(`${app}`, args, { ignoreReturnCode: true, silent: true, listeners: { @@ -94,7 +97,7 @@ async function getVersion(app: string): Promise { // Use zstandard if possible to maximize cache performance export async function getCompressionMethod(): Promise { - const versionOutput = await getVersion('zstd') + const versionOutput = await getVersion('zstd', ['--quiet']) core.debug(`versionOutput: ${versionOutput}`) const version = semver.clean(versionOutput) core.debug(`version: ${version}`) From a6d4a2a1d4faca276e111d5c4f28119a9704b90a Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 10:32:34 +0000 Subject: [PATCH 03/15] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index f274e00..3d5dda6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@actions/cache", - "version": "3.1.3", + "version": "3.1.4", "preview": true, "description": "Actions cache lib", "keywords": [ From cd561cfa0eae1ff72df26e7dfe0d1a238e2ee3ab Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 12:51:49 +0000 Subject: [PATCH 04/15] Fix bug with version shortcircuiting because of version being null --- src/internal/cacheUtils.ts | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index e413d10..f9aa379 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -98,20 +98,13 @@ async function getVersion(app: string, args?: string[]): Promise { // Use zstandard if possible to maximize cache performance export async function getCompressionMethod(): Promise { const versionOutput = await getVersion('zstd', ['--quiet']) - core.debug(`versionOutput: ${versionOutput}`) const version = semver.clean(versionOutput) - core.debug(`version: ${version}`) - - if (!versionOutput.toLowerCase().includes('zstd command line interface')) { - // zstd is not installed - return CompressionMethod.Gzip - } else if (!version || semver.lt(version, 'v1.3.2')) { - // zstd is installed but using a version earlier than v1.3.2 - // v1.3.2 is required to use the `--long` options in zstd + if (version) { return CompressionMethod.ZstdWithoutLong } else { - return CompressionMethod.Zstd + return CompressionMethod.Gzip } + } export function getCacheFileName(compressionMethod: CompressionMethod): string { From 8feecbb839a094a384d79e25f9e7c398295fdf50 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 13:08:22 +0000 Subject: [PATCH 05/15] Hotfix zstd version change only --- src/internal/cacheUtils.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index f9aa379..b767f96 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -99,12 +99,17 @@ async function getVersion(app: string, args?: string[]): Promise { export async function getCompressionMethod(): Promise { const versionOutput = await getVersion('zstd', ['--quiet']) const version = semver.clean(versionOutput) - if (version) { + + if (versionOutput === '') { + // zstd is not installed + return CompressionMethod.Gzip + } else if (!version || semver.lt(version, 'v1.3.2')) { + // zstd is installed but using a version earlier than v1.3.2 + // v1.3.2 is required to use the `--long` options in zstd return CompressionMethod.ZstdWithoutLong } else { - return CompressionMethod.Gzip + return CompressionMethod.Zstd } - } export function getCacheFileName(compressionMethod: CompressionMethod): string { From 90e2025fce09ec3773ee799ca4f452fcd152354b Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 13:27:45 +0000 Subject: [PATCH 06/15] Removed code that checks for version less than 1.3.2 as it was not working. Defaulting to zstd without long as that is what is always happening currently. --- src/internal/cacheUtils.ts | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index b767f96..e258028 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -3,7 +3,6 @@ import * as exec from '@actions/exec' import * as glob from '@actions/glob' import * as io from '@actions/io' import * as fs from 'fs' -import { type } from 'os' import * as path from 'path' import * as semver from 'semver' import * as util from 'util' @@ -100,15 +99,11 @@ export async function getCompressionMethod(): Promise { const versionOutput = await getVersion('zstd', ['--quiet']) const version = semver.clean(versionOutput) - if (versionOutput === '') { + if (versionOutput === '' || version === null) { // zstd is not installed return CompressionMethod.Gzip - } else if (!version || semver.lt(version, 'v1.3.2')) { - // zstd is installed but using a version earlier than v1.3.2 - // v1.3.2 is required to use the `--long` options in zstd + } else{ return CompressionMethod.ZstdWithoutLong - } else { - return CompressionMethod.Zstd } } From 333f1c33b04e4c1cede9633563cb1c7289af832c Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 13:33:16 +0000 Subject: [PATCH 07/15] Fix lint issues --- src/internal/cacheUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index e258028..1c4f55c 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -102,7 +102,7 @@ export async function getCompressionMethod(): Promise { if (versionOutput === '' || version === null) { // zstd is not installed return CompressionMethod.Gzip - } else{ + } else { return CompressionMethod.ZstdWithoutLong } } From 92b08106f45c6eb95fe82e7b8f95ffa1b0a6e1f0 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 13:43:24 +0000 Subject: [PATCH 08/15] Fix version number --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3d5dda6..f274e00 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@actions/cache", - "version": "3.1.4", + "version": "3.1.3", "preview": true, "description": "Actions cache lib", "keywords": [ From 8f9607997bbfddb047c70106bdda2e3a54ff6922 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 13:44:07 +0000 Subject: [PATCH 09/15] Bump version using npm --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index f9a2010..408660c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@actions/cache", - "version": "3.1.3", + "version": "3.1.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@actions/cache", - "version": "3.1.3", + "version": "3.1.4", "license": "MIT", "dependencies": { "@actions/core": "^1.10.0", diff --git a/package.json b/package.json index f274e00..3d5dda6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@actions/cache", - "version": "3.1.3", + "version": "3.1.4", "preview": true, "description": "Actions cache lib", "keywords": [ From 9ec0ae519001cd9e02d43dd550370f7ad2fd2079 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 14:23:53 +0000 Subject: [PATCH 10/15] Update debug statement to include latest command --- src/internal/cacheUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index 1c4f55c..0ab64ea 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -72,10 +72,10 @@ export async function unlinkFile(filePath: fs.PathLike): Promise { } async function getVersion(app: string, args?: string[]): Promise { - core.debug(`Checking ${app} --version`) let versionOutput = '' typeof args !== 'undefined' ? args : (args = []) args.push('--version') + core.debug(`Checking ${app} ${args.join(' ')}`) try { await exec.exec(`${app}`, args, { ignoreReturnCode: true, From 6888c9c2c416588f0563693b0bac8793b3f7767f Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 14:59:12 +0000 Subject: [PATCH 11/15] Add default value and rename args --- src/internal/cacheUtils.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index 0ab64ea..8de857f 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -71,13 +71,12 @@ export async function unlinkFile(filePath: fs.PathLike): Promise { return util.promisify(fs.unlink)(filePath) } -async function getVersion(app: string, args?: string[]): Promise { +async function getVersion(app: string, additionalArgs: string[] = []): Promise { let versionOutput = '' - typeof args !== 'undefined' ? args : (args = []) - args.push('--version') - core.debug(`Checking ${app} ${args.join(' ')}`) + additionalArgs.push('--version') + core.debug(`Checking ${app} ${additionalArgs.join(' ')}`) try { - await exec.exec(`${app}`, args, { + await exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, silent: true, listeners: { From 78384d81fc1828352919c7350f4dab873be85c25 Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 15:26:04 +0000 Subject: [PATCH 12/15] Fix lint issues --- src/internal/cacheUtils.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index 8de857f..8ccae2f 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -71,7 +71,10 @@ export async function unlinkFile(filePath: fs.PathLike): Promise { return util.promisify(fs.unlink)(filePath) } -async function getVersion(app: string, additionalArgs: string[] = []): Promise { +async function getVersion( + app: string, + additionalArgs: string[] = [] +): Promise { let versionOutput = '' additionalArgs.push('--version') core.debug(`Checking ${app} ${additionalArgs.join(' ')}`) From 2f7397272f8642f6c0adc9515a07fd0d50dfcf6d Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 18:38:47 +0000 Subject: [PATCH 13/15] Add release info --- RELEASES.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/RELEASES.md b/RELEASES.md index b1d5211..76bec60 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -114,4 +114,7 @@ - Fix issue with symlink restoration on windows. ### 3.1.3 -- Fix to prevent from setting MYSYS environement variable globally [#1329](https://github.com/actions/toolkit/pull/1329). \ No newline at end of file +- Fix to prevent from setting MYSYS environement variable globally [#1329](https://github.com/actions/toolkit/pull/1329). + +### 3.1.4 +- Fix zstd not being used due to `zstd --version` output change in zstd 1.5.4 release. See [#1353](https://github.com/actions/toolkit/pull/1353). \ No newline at end of file From 6fb8e7b25e91a03ef56a94fbba7d73fce3d5d88a Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 18:50:26 +0000 Subject: [PATCH 14/15] Fix failing windows test --- src/internal/cacheUtils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index 8ccae2f..ea69b7c 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -79,7 +79,7 @@ async function getVersion( additionalArgs.push('--version') core.debug(`Checking ${app} ${additionalArgs.join(' ')}`) try { - await exec.exec(`${app}`, additionalArgs, { + await exec.exec(`${app} `, additionalArgs, { ignoreReturnCode: true, silent: true, listeners: { From 0191d8805c6fab01eb9fee5518ff0c14e66bf33f Mon Sep 17 00:00:00 2001 From: Lovepreet Singh Date: Mon, 20 Feb 2023 19:03:44 +0000 Subject: [PATCH 15/15] Add debug statement for exact zstd version value and remove dependence on version for now --- src/internal/cacheUtils.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/internal/cacheUtils.ts b/src/internal/cacheUtils.ts index ea69b7c..650653a 100644 --- a/src/internal/cacheUtils.ts +++ b/src/internal/cacheUtils.ts @@ -79,7 +79,7 @@ async function getVersion( additionalArgs.push('--version') core.debug(`Checking ${app} ${additionalArgs.join(' ')}`) try { - await exec.exec(`${app} `, additionalArgs, { + await exec.exec(`${app}`, additionalArgs, { ignoreReturnCode: true, silent: true, listeners: { @@ -100,9 +100,9 @@ async function getVersion( export async function getCompressionMethod(): Promise { const versionOutput = await getVersion('zstd', ['--quiet']) const version = semver.clean(versionOutput) + core.debug(`zstd version: ${version}`) - if (versionOutput === '' || version === null) { - // zstd is not installed + if (versionOutput === '') { return CompressionMethod.Gzip } else { return CompressionMethod.ZstdWithoutLong