mirror of
https://github.com/gradle/actions.git
synced 2026-10-16 19:57:12 +08:00
Only cache the wrapper ZIP, not the exploded dir
Prior to this change, the wrapper cache contained both the downloaded zip file as well as the exploded wrapper dir. Only the zip file is required, as Gradle will automatically detect and unpack.
This commit is contained in:
1 parent
15a8123fbc
commit
e4ec586f46
3 files changed
+55
-45
No files matched your search
Vendored
+1
-1
@@ -1 +1 @@
|
||||
module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var i=n[t]={i:t,l:false,exports:{}};var r=true;try{e[t].call(i.exports,i,i.exports,__webpack_require__);r=false}finally{if(r)delete n[t]}i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}([,function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){if(i===undefined)i=n;Object.defineProperty(e,i,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,i){if(i===undefined)i=n;e[i]=t[n]});var r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))i(t,e,n);r(t,e);return t};var o=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,r){function fulfilled(e){try{step(i.next(e))}catch(e){r(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){r(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.findInPath=t.which=t.mkdirP=t.rmRF=t.mv=t.cp=void 0;const s=n(357);const c=a(n(129));const u=a(n(622));const l=n(669);const p=a(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return o(this,void 0,void 0,function*(){const{force:i,recursive:r,copySourceDirectory:a}=readCopyOptions(n);const o=(yield p.exists(t))?yield p.stat(t):null;if(o&&o.isFile()&&!i){return}const s=o&&o.isDirectory()&&a?u.join(t,u.basename(e)):t;if(!(yield p.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield p.stat(e);if(c.isDirectory()){if(!r){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,i)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,i)}})}t.cp=cp;function mv(e,t,n={}){return o(this,void 0,void 0,function*(){if(yield p.exists(t)){let i=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));i=yield p.exists(t)}if(i){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(u.dirname(t));yield p.rename(e,t)})}t.mv=mv;function rmRF(e){return o(this,void 0,void 0,function*(){if(p.IS_WINDOWS){if(/[*"<>|]/.test(e)){throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows')}try{const t=p.getCmdPath();if(yield p.isDirectory(e,true)){yield m(`${t} /s /c "rd /s /q "%inputPath%""`,{env:{inputPath:e}})}else{yield m(`${t} /s /c "del /f /a "%inputPath%""`,{env:{inputPath:e}})}}catch(e){if(e.code!=="ENOENT")throw e}try{yield p.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield p.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield d(`rm`,[`-rf`,`${e}`])}else{yield p.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return o(this,void 0,void 0,function*(){s.ok(e,"a path argument must be provided");yield p.mkdir(e,{recursive:true})})}t.mkdirP=mkdirP;function which(e,t){return o(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(p.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}return t}const n=yield findInPath(e);if(n&&n.length>0){return n[0]}return""})}t.which=which;function findInPath(e){return o(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}const t=[];if(p.IS_WINDOWS&&process.env["PATHEXT"]){for(const e of process.env["PATHEXT"].split(u.delimiter)){if(e){t.push(e)}}}if(p.isRooted(e)){const n=yield p.tryGetExecutablePath(e,t);if(n){return[n]}return[]}if(e.includes(u.sep)){return[]}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(u.delimiter)){if(e){n.push(e)}}}const i=[];for(const r of n){const n=yield p.tryGetExecutablePath(u.join(r,e),t);if(n){i.push(n)}}return i})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const i=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:i}}function cpDirRecursive(e,t,n,i){return o(this,voLine truncated
|
||||
module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var i=n[t]={i:t,l:false,exports:{}};var r=true;try{e[t].call(i.exports,i,i.exports,__webpack_require__);r=false}finally{if(r)delete n[t]}i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}([,function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){if(i===undefined)i=n;Object.defineProperty(e,i,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,i){if(i===undefined)i=n;e[i]=t[n]});var r=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))i(t,e,n);r(t,e);return t};var o=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,r){function fulfilled(e){try{step(i.next(e))}catch(e){r(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){r(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.findInPath=t.which=t.mkdirP=t.rmRF=t.mv=t.cp=void 0;const s=n(357);const c=a(n(129));const u=a(n(622));const l=n(669);const p=a(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return o(this,void 0,void 0,function*(){const{force:i,recursive:r,copySourceDirectory:a}=readCopyOptions(n);const o=(yield p.exists(t))?yield p.stat(t):null;if(o&&o.isFile()&&!i){return}const s=o&&o.isDirectory()&&a?u.join(t,u.basename(e)):t;if(!(yield p.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield p.stat(e);if(c.isDirectory()){if(!r){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,i)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,i)}})}t.cp=cp;function mv(e,t,n={}){return o(this,void 0,void 0,function*(){if(yield p.exists(t)){let i=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));i=yield p.exists(t)}if(i){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(u.dirname(t));yield p.rename(e,t)})}t.mv=mv;function rmRF(e){return o(this,void 0,void 0,function*(){if(p.IS_WINDOWS){if(/[*"<>|]/.test(e)){throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows')}try{const t=p.getCmdPath();if(yield p.isDirectory(e,true)){yield m(`${t} /s /c "rd /s /q "%inputPath%""`,{env:{inputPath:e}})}else{yield m(`${t} /s /c "del /f /a "%inputPath%""`,{env:{inputPath:e}})}}catch(e){if(e.code!=="ENOENT")throw e}try{yield p.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield p.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield d(`rm`,[`-rf`,`${e}`])}else{yield p.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return o(this,void 0,void 0,function*(){s.ok(e,"a path argument must be provided");yield p.mkdir(e,{recursive:true})})}t.mkdirP=mkdirP;function which(e,t){return o(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(p.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}return t}const n=yield findInPath(e);if(n&&n.length>0){return n[0]}return""})}t.which=which;function findInPath(e){return o(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}const t=[];if(p.IS_WINDOWS&&process.env["PATHEXT"]){for(const e of process.env["PATHEXT"].split(u.delimiter)){if(e){t.push(e)}}}if(p.isRooted(e)){const n=yield p.tryGetExecutablePath(e,t);if(n){return[n]}return[]}if(e.includes(u.sep)){return[]}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(u.delimiter)){if(e){n.push(e)}}}const i=[];for(const r of n){const n=yield p.tryGetExecutablePath(u.join(r,e),t);if(n){i.push(n)}}return i})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const i=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:i}}function cpDirRecursive(e,t,n,i){return o(this,voLine truncated
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var i=n[t]={i:t,l:false,exports:{}};var a=true;try{e[t].call(i.exports,i,i.exports,__webpack_require__);a=false}finally{if(a)delete n[t]}i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}([,function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){if(i===undefined)i=n;Object.defineProperty(e,i,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,i){if(i===undefined)i=n;e[i]=t[n]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))i(t,e,n);a(t,e);return t};var o=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function fulfilled(e){try{step(i.next(e))}catch(e){a(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){a(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.findInPath=t.which=t.mkdirP=t.rmRF=t.mv=t.cp=void 0;const s=n(357);const c=r(n(129));const u=r(n(622));const l=n(669);const p=r(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return o(this,void 0,void 0,function*(){const{force:i,recursive:a,copySourceDirectory:r}=readCopyOptions(n);const o=(yield p.exists(t))?yield p.stat(t):null;if(o&&o.isFile()&&!i){return}const s=o&&o.isDirectory()&&r?u.join(t,u.basename(e)):t;if(!(yield p.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield p.stat(e);if(c.isDirectory()){if(!a){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,i)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,i)}})}t.cp=cp;function mv(e,t,n={}){return o(this,void 0,void 0,function*(){if(yield p.exists(t)){let i=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));i=yield p.exists(t)}if(i){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(u.dirname(t));yield p.rename(e,t)})}t.mv=mv;function rmRF(e){return o(this,void 0,void 0,function*(){if(p.IS_WINDOWS){if(/[*"<>|]/.test(e)){throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows')}try{const t=p.getCmdPath();if(yield p.isDirectory(e,true)){yield m(`${t} /s /c "rd /s /q "%inputPath%""`,{env:{inputPath:e}})}else{yield m(`${t} /s /c "del /f /a "%inputPath%""`,{env:{inputPath:e}})}}catch(e){if(e.code!=="ENOENT")throw e}try{yield p.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield p.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield d(`rm`,[`-rf`,`${e}`])}else{yield p.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return o(this,void 0,void 0,function*(){s.ok(e,"a path argument must be provided");yield p.mkdir(e,{recursive:true})})}t.mkdirP=mkdirP;function which(e,t){return o(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(p.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}return t}const n=yield findInPath(e);if(n&&n.length>0){return n[0]}return""})}t.which=which;function findInPath(e){return o(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}const t=[];if(p.IS_WINDOWS&&process.env["PATHEXT"]){for(const e of process.env["PATHEXT"].split(u.delimiter)){if(e){t.push(e)}}}if(p.isRooted(e)){const n=yield p.tryGetExecutablePath(e,t);if(n){return[n]}return[]}if(e.includes(u.sep)){return[]}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(u.delimiter)){if(e){n.push(e)}}}const i=[];for(const a of n){const n=yield p.tryGetExecutablePath(u.join(a,e),t);if(n){i.push(n)}}return i})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const i=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:i}}function cpDirRecursive(e,t,n,i){return o(this,voLine truncated
|
||||
module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var i=n[t]={i:t,l:false,exports:{}};var a=true;try{e[t].call(i.exports,i,i.exports,__webpack_require__);a=false}finally{if(a)delete n[t]}i.l=true;return i.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}([,function(e,t,n){"use strict";var i=this&&this.__createBinding||(Object.create?function(e,t,n,i){if(i===undefined)i=n;Object.defineProperty(e,i,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,i){if(i===undefined)i=n;e[i]=t[n]});var a=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var r=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))i(t,e,n);a(t,e);return t};var o=this&&this.__awaiter||function(e,t,n,i){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,a){function fulfilled(e){try{step(i.next(e))}catch(e){a(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){a(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:true});t.findInPath=t.which=t.mkdirP=t.rmRF=t.mv=t.cp=void 0;const s=n(357);const c=r(n(129));const u=r(n(622));const l=n(669);const p=r(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return o(this,void 0,void 0,function*(){const{force:i,recursive:a,copySourceDirectory:r}=readCopyOptions(n);const o=(yield p.exists(t))?yield p.stat(t):null;if(o&&o.isFile()&&!i){return}const s=o&&o.isDirectory()&&r?u.join(t,u.basename(e)):t;if(!(yield p.exists(e))){throw new Error(`no such file or directory: ${e}`)}const c=yield p.stat(e);if(c.isDirectory()){if(!a){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,i)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,i)}})}t.cp=cp;function mv(e,t,n={}){return o(this,void 0,void 0,function*(){if(yield p.exists(t)){let i=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));i=yield p.exists(t)}if(i){if(n.force==null||n.force){yield rmRF(t)}else{throw new Error("Destination already exists")}}}yield mkdirP(u.dirname(t));yield p.rename(e,t)})}t.mv=mv;function rmRF(e){return o(this,void 0,void 0,function*(){if(p.IS_WINDOWS){if(/[*"<>|]/.test(e)){throw new Error('File path must not contain `*`, `"`, `<`, `>` or `|` on Windows')}try{const t=p.getCmdPath();if(yield p.isDirectory(e,true)){yield m(`${t} /s /c "rd /s /q "%inputPath%""`,{env:{inputPath:e}})}else{yield m(`${t} /s /c "del /f /a "%inputPath%""`,{env:{inputPath:e}})}}catch(e){if(e.code!=="ENOENT")throw e}try{yield p.unlink(e)}catch(e){if(e.code!=="ENOENT")throw e}}else{let t=false;try{t=yield p.isDirectory(e)}catch(e){if(e.code!=="ENOENT")throw e;return}if(t){yield d(`rm`,[`-rf`,`${e}`])}else{yield p.unlink(e)}}})}t.rmRF=rmRF;function mkdirP(e){return o(this,void 0,void 0,function*(){s.ok(e,"a path argument must be provided");yield p.mkdir(e,{recursive:true})})}t.mkdirP=mkdirP;function which(e,t){return o(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}if(t){const t=yield which(e,false);if(!t){if(p.IS_WINDOWS){throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also verify the file has a valid extension for an executable file.`)}else{throw new Error(`Unable to locate executable file: ${e}. Please verify either the file path exists or the file can be found within a directory specified by the PATH environment variable. Also check the file mode to verify the file is executable.`)}}return t}const n=yield findInPath(e);if(n&&n.length>0){return n[0]}return""})}t.which=which;function findInPath(e){return o(this,void 0,void 0,function*(){if(!e){throw new Error("parameter 'tool' is required")}const t=[];if(p.IS_WINDOWS&&process.env["PATHEXT"]){for(const e of process.env["PATHEXT"].split(u.delimiter)){if(e){t.push(e)}}}if(p.isRooted(e)){const n=yield p.tryGetExecutablePath(e,t);if(n){return[n]}return[]}if(e.includes(u.sep)){return[]}const n=[];if(process.env.PATH){for(const e of process.env.PATH.split(u.delimiter)){if(e){n.push(e)}}}const i=[];for(const a of n){const n=yield p.tryGetExecutablePath(u.join(a,e),t);if(n){i.push(n)}}return i})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const i=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:i}}function cpDirRecursive(e,t,n,i){return o(this,voLine truncated
|
||||
+53
-43
@@ -7,9 +7,7 @@ import * as cache from '@actions/cache'
|
||||
|
||||
import * as github from './github-utils'
|
||||
|
||||
const WRAPPER_CACHE_KEY = 'WRAPPER_CACHE_KEY'
|
||||
const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH'
|
||||
const WRAPPER_CACHE_RESULT = 'WRAPPER_CACHE_RESULT'
|
||||
const WRAPPER_SLUG = 'WRAPPER_SLUG'
|
||||
|
||||
export async function restoreCachedWrapperDist(
|
||||
gradlewDirectory: string | null
|
||||
@@ -17,68 +15,62 @@ export async function restoreCachedWrapperDist(
|
||||
if (isWrapperCacheDisabled()) return
|
||||
if (gradlewDirectory == null) return
|
||||
|
||||
const wrapperSlug = extractGradleWrapperSlugFrom(
|
||||
path.join(
|
||||
path.resolve(gradlewDirectory),
|
||||
'gradle/wrapper/gradle-wrapper.properties'
|
||||
const wrapperProperties = path.join(
|
||||
path.resolve(gradlewDirectory),
|
||||
'gradle/wrapper/gradle-wrapper.properties'
|
||||
)
|
||||
const wrapperSlug = extractGradleWrapperSlugFrom(wrapperProperties)
|
||||
if (!wrapperSlug) {
|
||||
core.warning(
|
||||
`Could not calculate wrapper version from ${wrapperProperties}`
|
||||
)
|
||||
)
|
||||
if (!wrapperSlug) return
|
||||
return
|
||||
}
|
||||
|
||||
const wrapperCacheKey = `wrapper-${wrapperSlug}`
|
||||
const wrapperCachePath = path.resolve(
|
||||
os.homedir(),
|
||||
`.gradle/wrapper/dists/gradle-${wrapperSlug}`
|
||||
)
|
||||
if (fs.existsSync(wrapperCachePath)) return
|
||||
const wrapperDir = getWrapperDir(wrapperSlug)
|
||||
const cacheKey = getCacheKey(wrapperSlug)
|
||||
const cachePath = getCachePath(wrapperSlug)
|
||||
|
||||
core.saveState(WRAPPER_CACHE_KEY, wrapperCacheKey)
|
||||
core.saveState(WRAPPER_CACHE_PATH, wrapperCachePath)
|
||||
// Check if the wrapper has already been downloaded to Gradle User Home
|
||||
if (fs.existsSync(wrapperDir)) return
|
||||
|
||||
try {
|
||||
const restoredKey = await cache.restoreCache(
|
||||
[wrapperCachePath],
|
||||
wrapperCacheKey
|
||||
)
|
||||
const restoredKey = await cache.restoreCache([cachePath], cacheKey)
|
||||
|
||||
if (!restoredKey) {
|
||||
if (restoredKey) {
|
||||
core.info(
|
||||
'Wrapper installation cache not found, expect a Gradle distribution download.'
|
||||
`Wrapper installation restored from cache key: ${restoredKey}`
|
||||
)
|
||||
return
|
||||
} else {
|
||||
core.info(
|
||||
`Wrapper installation cache not found. Will download and cache with key: ${cacheKey}.`
|
||||
)
|
||||
// Save the slug to trigger caching of the downloaded wrapper
|
||||
core.saveState(WRAPPER_SLUG, wrapperSlug)
|
||||
}
|
||||
|
||||
core.saveState(WRAPPER_CACHE_RESULT, restoredKey)
|
||||
core.info(
|
||||
`Wrapper installation restored from cache key: ${restoredKey}`
|
||||
)
|
||||
return
|
||||
} catch (error) {
|
||||
core.info(
|
||||
`Wrapper installation cache restore failed, expect a Gradle distribution download\n ${error}`
|
||||
`Wrapper installation cache restore failed for key: ${cacheKey}.\n ${error}`
|
||||
)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
export async function cacheWrapperDist(): Promise<void> {
|
||||
if (isWrapperCacheDisabled()) return
|
||||
|
||||
const cacheKey = core.getState(WRAPPER_CACHE_KEY)
|
||||
const cachePath = core.getState(WRAPPER_CACHE_PATH)
|
||||
const cacheResult = core.getState(WRAPPER_CACHE_RESULT)
|
||||
const wrapperSlug = core.getState(WRAPPER_SLUG)
|
||||
if (!wrapperSlug) return
|
||||
|
||||
if (!cachePath || !fs.existsSync(cachePath)) {
|
||||
core.debug('No wrapper installation to cache.')
|
||||
const wrapperDir = getWrapperDir(wrapperSlug)
|
||||
const cacheKey = getCacheKey(wrapperSlug)
|
||||
const cachePath = getCachePath(wrapperSlug)
|
||||
|
||||
if (!fs.existsSync(wrapperDir)) {
|
||||
core.warning(`No wrapper installation to cache at ${wrapperDir}`)
|
||||
return
|
||||
}
|
||||
|
||||
if (cacheResult && cacheKey === cacheResult) {
|
||||
core.info(
|
||||
`Wrapper installation cache hit occurred on the cache key ${cacheKey}, not saving cache.`
|
||||
)
|
||||
return
|
||||
}
|
||||
core.info(`Will cache wrapper zip ${cachePath} with key ${cacheKey}`)
|
||||
|
||||
try {
|
||||
await cache.saveCache([cachePath], cacheKey)
|
||||
@@ -117,3 +109,21 @@ export function extractGradleWrapperSlugFromDistUri(
|
||||
function isWrapperCacheDisabled(): boolean {
|
||||
return !github.inputBoolean('wrapper-cache-enabled', true)
|
||||
}
|
||||
|
||||
function getCacheKey(wrapperSlug: string): string {
|
||||
return `wrapper-v1-${wrapperSlug}`
|
||||
}
|
||||
|
||||
function getWrapperDir(wrapperSlug: string): string {
|
||||
return path.resolve(
|
||||
os.homedir(),
|
||||
`.gradle/wrapper/dists/gradle-${wrapperSlug}`
|
||||
)
|
||||
}
|
||||
|
||||
function getCachePath(wrapperSlug: string): string {
|
||||
return path.resolve(
|
||||
os.homedir(),
|
||||
`.gradle/wrapper/dists/gradle-${wrapperSlug}/*/gradle-${wrapperSlug}.zip`
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user