From 5b9624008f57ef318bec61a99cfac0e701aefd4f Mon Sep 17 00:00:00 2001 From: Xuanwo Date: Mon, 9 Jan 2023 23:43:42 +0800 Subject: [PATCH] Test Signed-off-by: Xuanwo --- .github/workflows/test.yml | 4 +++- dist/index.js | 14 +++++++++++--- src/sccache.ts | 22 ++++++++++++++++++---- 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0be9c4e..dd18841 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,4 +32,6 @@ jobs: - name: Run sccache stat for check shell: bash - run: ${SCCACHE_PATH} --stat + run: | + ls /opt/hostedtoolcache/sccache/0.3.3/x64/ -lh + ${SCCACHE_PATH} --stat diff --git a/dist/index.js b/dist/index.js index 3502542..0c02c44 100644 --- a/dist/index.js +++ b/dist/index.js @@ -46,14 +46,22 @@ function setup() { // TODO: we can support install latest version by default if version // is not input. const version = core.getInput('version'); - console.log('try to setup for version: ', version); + console.log('try to setup sccache version: ', version); const downloadUrl = `https://github.com/mozilla/sccache/releases/download/${version}/${getFilename(version)}`; - console.log('try to setup from url: ', downloadUrl); + console.log('sccache download from url: ', downloadUrl); // Download and extract. const sccachePackage = yield (0, tool_cache_1.downloadTool)(downloadUrl); - const sccachePath = yield (0, tool_cache_1.extractTar)(sccachePackage); + var sccachePath; + if (getExtension() == 'zip') { + sccachePath = yield (0, tool_cache_1.extractTar)(sccachePackage); + } + else { + sccachePath = yield (0, tool_cache_1.extractTar)(sccachePackage); + } + console.log('sccache extracted to: ', sccachePath); // Cache sccache. const sccacheHome = yield (0, tool_cache_1.cacheDir)(sccachePath, 'sccache', version); + console.log('sccache cached to: ', sccacheHome); // Add cached sccache into path. core.addPath(`${sccacheHome}`); // Expose the sccache path as env. diff --git a/src/sccache.ts b/src/sccache.ts index 099d356..869a761 100644 --- a/src/sccache.ts +++ b/src/sccache.ts @@ -1,5 +1,10 @@ import * as core from '@actions/core'; -import {downloadTool, extractTar, cacheDir} from '@actions/tool-cache'; +import { + downloadTool, + extractTar, + extractZip, + cacheDir +} from '@actions/tool-cache'; import {exec} from 'child_process'; import * as fs from 'fs'; import {promisify} from 'util'; @@ -8,19 +13,28 @@ async function setup() { // TODO: we can support install latest version by default if version // is not input. const version = core.getInput('version'); - console.log('try to setup for version: ', version); + console.log('try to setup sccache version: ', version); const downloadUrl = `https://github.com/mozilla/sccache/releases/download/${version}/${getFilename( version )}`; - console.log('try to setup from url: ', downloadUrl); + console.log('sccache download from url: ', downloadUrl); // Download and extract. const sccachePackage = await downloadTool(downloadUrl); - const sccachePath = await extractTar(sccachePackage); + + var sccachePath; + if (getExtension() == 'zip') { + sccachePath = await extractTar(sccachePackage); + } else { + sccachePath = await extractTar(sccachePackage); + } + console.log('sccache extracted to: ', sccachePath); // Cache sccache. const sccacheHome = await cacheDir(sccachePath, 'sccache', version); + console.log('sccache cached to: ', sccacheHome); + // Add cached sccache into path. core.addPath(`${sccacheHome}`); // Expose the sccache path as env.