From cf7040c0a561411ae2443965a9e8271a5eca4fc4 Mon Sep 17 00:00:00 2001 From: pshu Date: Mon, 20 Jun 2022 10:40:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20action=20not=20working=20?= =?UTF-8?q?in=20windows=20or=20with=20pnpm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- action.yml | 3 +++ index.js | 20 ++++++++++++++++---- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/action.yml b/action.yml index 26552c81b..93de77ac5 100644 --- a/action.yml +++ b/action.yml @@ -38,6 +38,9 @@ inputs: install-command: description: 'Custom install command to use' required: false + hash-file: + description: 'Path to the file for cypress cache key generation' + required: false runTests: description: 'Whether or not to run tests' required: false diff --git a/index.js b/index.js index 6e8a77603..4d4b51029 100644 --- a/index.js +++ b/index.js @@ -102,10 +102,18 @@ const packageLockFilename = path.join( const useYarn = () => fs.existsSync(yarnFilename) +const gegUserSpecifiedHashFile = () => { + const userSpecifiedHashFile = core.getInput('lock-hash'); + if (userSpecifiedHashFile) { + return path.join(workingDirectory, userSpecifiedHashFile); + } + return useYarn() ? yarnFilename : packageLockFilename; +} + const lockHash = () => { - const lockFilename = useYarn() ? yarnFilename : packageLockFilename - const fileHash = hasha.fromFileSync(lockFilename) - debug(`Hash from file ${lockFilename} is ${fileHash}`) + const hashFile = gegUserSpecifiedHashFile(); + const fileHash = hasha.fromFileSync(hashFile); + debug(`Hash from file ${hashFile} is ${fileHash}`) return fileHash } @@ -635,7 +643,11 @@ const runTests = async () => { } // export common environment variables that help run Cypress - core.exportVariable('CYPRESS_CACHE_FOLDER', CYPRESS_CACHE_FOLDER) + if(getInputBool('install', true)) { + // only when cypress is installed by action self, we can export the Cache Folder, + // otherwise use the default one in Cypress + core.exportVariable('CYPRESS_CACHE_FOLDER', CYPRESS_CACHE_FOLDER) + } core.exportVariable('TERM', 'xterm') if (customCommand) {