From fd3ca5dc103d2c2b5a5ecd1c4b4a73f2101bfc13 Mon Sep 17 00:00:00 2001 From: Kevin Stillhammer Date: Sat, 24 Aug 2024 00:45:44 +0200 Subject: [PATCH] Cache correct dir --- dist/setup/index.js | Bin 3573601 -> 3573407 bytes src/download/download-latest.ts | 21 +++++++++------------ src/download/download-version.ts | 21 +++++++++------------ 3 files changed, 18 insertions(+), 24 deletions(-) diff --git a/dist/setup/index.js b/dist/setup/index.js index 3ca83b0121bc55f07e442a3d56d3b36cdb1f9906..8f632507d90ec9051506974de8caeb41d358189c 100644 GIT binary patch delta 470 zcmaKozb`{^6vgvew0*4~rJnk&>PJhte%636SnIV`8hsw3LMu(%NE1PF!o(!GiA9af zk{6T2WHE_BB|`iG7Nfz}AR-aNXSm5Z_nv!R4hz!BK|$Jq1QX0CLNQ8UffY8$u)~2; zl%X6IaH0}baG@FsYT!mK>QIjcG@=R3Xn_Z<@S+Xv=s+iY@S_Xe2%rbO7ZeOxwNyI3 ztm$bU3(>ygd)kVP%A8oIS`Mq^;be@QhI^Wvk|~qrQ;jCL@15+NzgCJkr_zXdDxTsi zmFj=?G8|AtJ45)yNm4xN9a}N<1=%Rb8|FfEJW!; z`Z*+mXZT^Bl>gGRNdLw+VbZu=r9F;anq}TOx4Zc1w#Len3pC34Bgw+gHd6_&>E!Ti zXz7*S)nq*3TiQ&gL`6%B;>$qGcSnAXMu^ymkivyolK1a)67&iB1p|UX!H{6sxYL7& F-cPNcs|Nr8 delta 599 zcmZ{gOKVd>7=}4*Q)_C{STAW>YsVy-6OHGqmu68FTvTvVTDrFFxnvF*iRb7!6KM#c zA}_cQ73^Y`u0+t47tF8l4|E|&S1$4!bkNvF!GUKp-#ahQe6ODE8sDDp8joOL2*Vgb z0;4#DF&st`<2Zs8(wIO7M=^l0O%M_my(QA>rJ)KnjrX>#oMMaNd}9lHMJrcH(#U!lBu?aeIW(s{muCJM?yb_-G~beu<4Imy5>bVz)CT3$iw(-C_Ecix^BV0XRc@Wu zl(S?ks<(HBtA&U=wVH_74c3&RVcn0ydm4!03{`7C@u9m(%q_)3Q z65As1L({(XM}svVG8wXbu{~(k$=l^?N!C9^tRZ5_WSuiF3?vU^%tD{-zhK&LKdlow z>x%}DwR21GMve77O}>>p`2I^byYRm@?#VD}EwW { - const binary = `uv-${arch}-${platform}` - let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${binary}` + const artifact = `uv-${arch}-${platform}` + let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/latest/download/${artifact}` if (platform === 'pc-windows-msvc') { downloadUrl += '.zip' } else { @@ -27,22 +27,19 @@ export async function downloadLatest( githubToken ) let uvExecutablePath: string - let extractedDir: string + let uvDir: string if (platform === 'pc-windows-msvc') { - extractedDir = await tc.extractZip(downloadPath) - uvExecutablePath = path.join(extractedDir, 'uv.exe') + const extractedDir = await tc.extractZip(downloadPath) + uvDir = path.join(extractedDir, artifact) + uvExecutablePath = path.join(uvDir, 'uv.exe') } else { - extractedDir = await tc.extractTar(downloadPath) + const extractedDir = await tc.extractTar(downloadPath) + uvDir = path.join(extractedDir, artifact) uvExecutablePath = path.join(extractedDir, 'uv') } const version = await getVersion(uvExecutablePath) await validateChecksum(checkSum, downloadPath, arch, platform, version) - const cachedToolDir = await tc.cacheDir( - extractedDir, - TOOL_CACHE_NAME, - version, - arch - ) + const cachedToolDir = await tc.cacheDir(uvDir, TOOL_CACHE_NAME, version, arch) return {cachedToolDir, version} } diff --git a/src/download/download-version.ts b/src/download/download-version.ts index e253863..d566ecf 100644 --- a/src/download/download-version.ts +++ b/src/download/download-version.ts @@ -1,14 +1,10 @@ import * as core from '@actions/core' import * as tc from '@actions/tool-cache' +import * as path from 'path' import {OWNER, REPO, TOOL_CACHE_NAME} from '../utils/utils' import {Architecture, Platform} from '../utils/platforms' import {validateChecksum} from './checksum/checksum' -import * as fs from 'fs' -import * as util from 'util' - -const readdir = util.promisify(fs.readdir) - export function tryGetFromToolCache( arch: Architecture, version: string @@ -26,8 +22,8 @@ export async function downloadVersion( checkSum: string | undefined, githubToken: string | undefined ): Promise { - const binary = `uv-${arch}-${platform}` - let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${version}/${binary}` + const artifact = `uv-${arch}-${platform}` + let downloadUrl = `https://github.com/${OWNER}/${REPO}/releases/download/${version}/${artifact}` if (platform === 'pc-windows-msvc') { downloadUrl += '.zip' } else { @@ -48,10 +44,11 @@ export async function downloadVersion( } else { extractedDir = await tc.extractTar(downloadPath) } - core.info(`Extracted uv to "${extractedDir}"`) - // list the contents of extracted dir - const files = await readdir(extractedDir) - core.info(`Contents of extracted directory: ${files.join(', ')}`) - return await tc.cacheDir(extractedDir, TOOL_CACHE_NAME, version, arch) + return await tc.cacheDir( + path.join(extractedDir, artifact), + TOOL_CACHE_NAME, + version, + arch + ) }