From c9410badda4316caf76e39731f4fe642b1440de6 Mon Sep 17 00:00:00 2001 From: soul-walker Date: Fri, 22 Mar 2024 14:59:07 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9cache=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9ci=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/ci.yml | 8 +++++--- dist/index.js | Bin 3352722 -> 3352564 bytes src/installer.ts | 28 ++++++++++++---------------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 1fe37b7..a49445f 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -27,6 +27,8 @@ jobs: with: maven-version: 3.8.2 - - name: Check Setup Result - id: check-setup - run: mvn -version + - name: Check Output + id: output + run: + echo "The cache-hit value is ${{ steps.test-action.outputs.cache-hit + }}" diff --git a/dist/index.js b/dist/index.js index 3e8081e6530479c691ac849c5b0f5dbfdcbc1a0a..3d3a6ef23d31a34629403e32d089777c5f7da439 100644 GIT binary patch delta 236 zcmXxayG{a86ougof}#g?Py`+E0^V>dI9S*iJ2kQO5wKOJp~vD+C{483FF>I^Gbf>< zvmr5dK7*z40X!5IU-Pf^{5kf1KgQl89x0|slVO?}vdl7vA;&xmEaH=AiDe3`P^82v zYXq!QW`j+(*rr029d_Acp95+f4&-~F^;j;n9m|=%#&WGcu@tmF5?_Nv$}gs6^eS;< zH<3$yPvrbR<+W-h)USt3pl>5FlYdU1tQgz3a+At-qUioMiaOf8^NYQ3D9({{?9`ox ObK-oMT?nW8Ttkf33Xyy_7*USWx89C=CrYh@2FK@_-#&Yj~hBO6c8e zjfN(V2cf=!5X}wk4F%B$=p;1tzz-gH-{JXw9-6LShNg3vV1@-&2oPbz80>Js2^YrU zh6fV7n1By{1Q0|BlL#Y%DNJJqvzP-z6fw+W0gH$ufh1Br{@zvN{jbhQ_0G+vg&cHD07w z(QBtWjeBT#AlT_q;|X%b1bgQ)B+`e**NFA`?#-uYrFx$iMn#GV!s!0c=i78&^0{d% zEd*$w@dz=UJE?wUmGr#Mcg$3J^V#BZPOixHYO&Eu{_fgS6g9*Ct*0|t3U^FY^Xp)9Q diff --git a/src/installer.ts b/src/installer.ts index f70e8bb..c37c1c3 100644 --- a/src/installer.ts +++ b/src/installer.ts @@ -6,26 +6,22 @@ import * as ac from '@actions/cache' function getToolDirectoryName(version: string): string { return `apache-maven-${version}` } - const BaseDir = '/denv/maven' export async function getMaven(version: string): Promise { let toolPath: string - toolPath = tc.find('maven', version) - if (!toolPath) { - const toolDirectoryName = getToolDirectoryName(version) - toolPath = path.join(BaseDir, toolDirectoryName) - const rcr = await ac.restoreCache([toolPath], toolDirectoryName) - if (!rcr) { - core.setOutput('cache-hit', false) - core.info(`Maven ${version} is not found in the cache`) - toolPath = await downloadMaven(version, toolDirectoryName) - await ac.saveCache([toolPath], toolDirectoryName) - core.info(`Maven ${version} has been cached, cache path: ${toolPath}`) - } else { - core.setOutput('cache-hit', true) - } + const toolDirectoryName = getToolDirectoryName(version) + toolPath = path.join(BaseDir, toolDirectoryName) + const rcr = await ac.restoreCache([toolPath], toolDirectoryName) + if (!rcr) { + core.setOutput('cache-hit', false) + core.info(`Maven ${version} is not found in the cache`) + toolPath = await downloadMaven(version, toolDirectoryName) + await ac.saveCache([toolPath], toolDirectoryName) + core.info(`Maven ${version} has been cached, cache path: ${toolPath}`) + } else { + core.setOutput('cache-hit', true) } toolPath = path.join(toolPath, 'bin') @@ -43,7 +39,7 @@ async function downloadMaven( const downloadPath = await tc.downloadTool(downloadUrl) const extractedPath = await tc.extractTar(downloadPath, BaseDir) let toolRoot = path.join(extractedPath, toolDirectoryName) - return await tc.cacheDir(toolRoot, 'maven', version) + return toolRoot } catch (err) { throw err }