Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotfix Zstd breaking due to version change in runners #1353

Merged
merged 16 commits into from
Feb 20, 2023
4 changes: 2 additions & 2 deletions 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": "3.1.3",
"version": "3.1.4",
"preview": true,
"description": "Actions cache lib",
"keywords": [
Expand Down
18 changes: 8 additions & 10 deletions packages/cache/src/internal/cacheUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,13 @@ export async function unlinkFile(filePath: fs.PathLike): Promise<void> {
return util.promisify(fs.unlink)(filePath)
}

async function getVersion(app: string): Promise<string> {
core.debug(`Checking ${app} --version`)
async function getVersion(app: string, args?: string[]): Promise<string> {
bishal-pdMSFT marked this conversation as resolved.
Show resolved Hide resolved
lvpx marked this conversation as resolved.
Show resolved Hide resolved
lvpx marked this conversation as resolved.
Show resolved Hide resolved
let versionOutput = ''
typeof args !== 'undefined' ? args : (args = [])
args.push('--version')
core.debug(`Checking ${app} ${args.join(' ')}`)
try {
await exec.exec(`${app} --version`, [], {
await exec.exec(`${app}`, args, {
ignoreReturnCode: true,
silent: true,
listeners: {
Expand All @@ -94,18 +96,14 @@ async function getVersion(app: string): Promise<string> {

// Use zstandard if possible to maximize cache performance
export async function getCompressionMethod(): Promise<CompressionMethod> {
const versionOutput = await getVersion('zstd')
const versionOutput = await getVersion('zstd', ['--quiet'])
bishal-pdMSFT marked this conversation as resolved.
Show resolved Hide resolved
const version = semver.clean(versionOutput)

if (!versionOutput.toLowerCase().includes('zstd command line interface')) {
if (versionOutput === '' || version === null) {
bishal-pdMSFT marked this conversation as resolved.
Show resolved Hide resolved
lvpx marked this conversation as resolved.
Show resolved Hide resolved
// 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.Zstd
return CompressionMethod.ZstdWithoutLong
}
}

Expand Down