mirror of
https://github.com/gradle/actions.git
synced 2026-10-16 19:57:12 +08:00
Consolidate logic for separate artifact file caching
Making this functionality more general will make it easier to add other artifacts to the set that we cache separately.
This commit is contained in:
3 files changed
+54
-136
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 r=n[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(r.exports,r,r.exports,__webpack_require__);i=false}finally{if(i)delete n[t]}r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}([,function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=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))r(t,e,n);i(t,e);return t};var a=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.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=o(n(129));const u=o(n(622));const l=n(669);const p=o(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return a(this,void 0,void 0,function*(){const{force:r,recursive:i,copySourceDirectory:o}=readCopyOptions(n);const a=(yield p.exists(t))?yield p.stat(t):null;if(a&&a.isFile()&&!r){return}const s=a&&a.isDirectory()&&o?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(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,r)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,r)}})}t.cp=cp;function mv(e,t,n={}){return a(this,void 0,void 0,function*(){if(yield p.exists(t)){let r=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));r=yield p.exists(t)}if(r){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 a(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 a(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 a(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 a(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 r=[];for(const i of n){const n=yield p.tryGetExecutablePath(u.join(i,e),t);if(n){r.push(n)}}return r})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const r=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:r}}function cpDirRecursive(e,t,n,r){return a(this,voLine truncated
|
module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var r=n[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(r.exports,r,r.exports,__webpack_require__);i=false}finally{if(i)delete n[t]}r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(131)}return startup()}([,function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=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))r(t,e,n);i(t,e);return t};var a=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.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=o(n(129));const u=o(n(622));const l=n(669);const p=o(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return a(this,void 0,void 0,function*(){const{force:r,recursive:i,copySourceDirectory:o}=readCopyOptions(n);const a=(yield p.exists(t))?yield p.stat(t):null;if(a&&a.isFile()&&!r){return}const s=a&&a.isDirectory()&&o?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(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,r)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,r)}})}t.cp=cp;function mv(e,t,n={}){return a(this,void 0,void 0,function*(){if(yield p.exists(t)){let r=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));r=yield p.exists(t)}if(r){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 a(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 a(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 a(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 a(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 r=[];for(const i of n){const n=yield p.tryGetExecutablePath(u.join(i,e),t);if(n){r.push(n)}}return r})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const r=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:r}}function cpDirRecursive(e,t,n,r){return a(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 r=n[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(r.exports,r,r.exports,__webpack_require__);i=false}finally{if(i)delete n[t]}r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}([,function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=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))r(t,e,n);i(t,e);return t};var a=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.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=o(n(129));const u=o(n(622));const l=n(669);const p=o(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return a(this,void 0,void 0,function*(){const{force:r,recursive:i,copySourceDirectory:o}=readCopyOptions(n);const a=(yield p.exists(t))?yield p.stat(t):null;if(a&&a.isFile()&&!r){return}const s=a&&a.isDirectory()&&o?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(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,r)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,r)}})}t.cp=cp;function mv(e,t,n={}){return a(this,void 0,void 0,function*(){if(yield p.exists(t)){let r=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));r=yield p.exists(t)}if(r){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 a(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 a(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 a(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 a(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 r=[];for(const i of n){const n=yield p.tryGetExecutablePath(u.join(i,e),t);if(n){r.push(n)}}return r})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const r=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:r}}function cpDirRecursive(e,t,n,r){return a(this,voLine truncated
|
module.exports=function(e,t){"use strict";var n={};function __webpack_require__(t){if(n[t]){return n[t].exports}var r=n[t]={i:t,l:false,exports:{}};var i=true;try{e[t].call(r.exports,r,r.exports,__webpack_require__);i=false}finally{if(i)delete n[t]}r.l=true;return r.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}([,function(e,t,n){"use strict";var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var o=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))r(t,e,n);i(t,e);return t};var a=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||(n=Promise))(function(n,i){function fulfilled(e){try{step(r.next(e))}catch(e){i(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){i(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.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=o(n(129));const u=o(n(622));const l=n(669);const p=o(n(672));const m=l.promisify(c.exec);const d=l.promisify(c.execFile);function cp(e,t,n={}){return a(this,void 0,void 0,function*(){const{force:r,recursive:i,copySourceDirectory:o}=readCopyOptions(n);const a=(yield p.exists(t))?yield p.stat(t):null;if(a&&a.isFile()&&!r){return}const s=a&&a.isDirectory()&&o?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(!i){throw new Error(`Failed to copy. ${e} is a directory, but tried to copy without recursive flag.`)}else{yield cpDirRecursive(e,s,0,r)}}else{if(u.relative(e,s)===""){throw new Error(`'${s}' and '${e}' are the same file`)}yield copyFile(e,s,r)}})}t.cp=cp;function mv(e,t,n={}){return a(this,void 0,void 0,function*(){if(yield p.exists(t)){let r=true;if(yield p.isDirectory(t)){t=u.join(t,u.basename(e));r=yield p.exists(t)}if(r){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 a(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 a(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 a(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 a(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 r=[];for(const i of n){const n=yield p.tryGetExecutablePath(u.join(i,e),t);if(n){r.push(n)}}return r})}t.findInPath=findInPath;function readCopyOptions(e){const t=e.force==null?true:e.force;const n=Boolean(e.recursive);const r=e.copySourceDirectory==null?true:Boolean(e.copySourceDirectory);return{force:t,recursive:n,copySourceDirectory:r}}function cpDirRecursive(e,t,n,r){return a(this,voLine truncated
|
||||||
+52
-134
@@ -10,11 +10,16 @@ import {AbstractCache} from './cache-utils'
|
|||||||
|
|
||||||
const CACHE_PATH = [
|
const CACHE_PATH = [
|
||||||
'~/.gradle/caches/*', // All directories in 'caches'
|
'~/.gradle/caches/*', // All directories in 'caches'
|
||||||
'!~/.gradle/caches/*/generated-gradle-jars', // Exclude generated-gradle-jars
|
|
||||||
'~/.gradle/notifications/*', // Prevent the re-rendering of first-use message for version
|
'~/.gradle/notifications/*', // Prevent the re-rendering of first-use message for version
|
||||||
'~/.gradle/wrapper/dists/*/*/*.zip.txt' // Only wrapper zips are required : Gradle will expand these on demand
|
'~/.gradle/wrapper/dists/*/*/*.zip.txt' // Only wrapper zips are required : We do not want to cache the exploded distributions
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const DEDUPLCIATED_PATHS = [
|
||||||
|
'~/.gradle/wrapper/dists/*/*/*.zip',
|
||||||
|
'~/.gradle/caches/*/generated-gradle-jars/*.jar'
|
||||||
|
]
|
||||||
|
const MARKER_FILE_EXTENSION = '.txt'
|
||||||
|
|
||||||
export class GradleUserHomeCache extends AbstractCache {
|
export class GradleUserHomeCache extends AbstractCache {
|
||||||
constructor() {
|
constructor() {
|
||||||
super('gradle', 'Gradle User Home')
|
super('gradle', 'Gradle User Home')
|
||||||
@@ -23,90 +28,48 @@ export class GradleUserHomeCache extends AbstractCache {
|
|||||||
async restore(): Promise<void> {
|
async restore(): Promise<void> {
|
||||||
await super.restore()
|
await super.restore()
|
||||||
await this.reportCacheEntrySize()
|
await this.reportCacheEntrySize()
|
||||||
await this.restoreWrapperZips()
|
await this.restoreDeduplicatedPaths()
|
||||||
await this.restoreGeneratedJars()
|
await this.reportCacheEntrySize()
|
||||||
}
|
}
|
||||||
|
|
||||||
private async restoreWrapperZips(): Promise<void> {
|
private async restoreDeduplicatedPaths(): Promise<void> {
|
||||||
const globber = await glob.create(
|
const markerFilePatterns = DEDUPLCIATED_PATHS.map(targetPath => {
|
||||||
'~/.gradle/wrapper/dists/*/*/*.zip.txt'
|
return targetPath + MARKER_FILE_EXTENSION
|
||||||
)
|
}).join('\n')
|
||||||
const wrapperMarkers = await globber.glob()
|
|
||||||
|
|
||||||
core.info('Found the following wrapper zips')
|
core.info(`Using marker file patterns: ${markerFilePatterns}`)
|
||||||
for (const wrapperMarker of wrapperMarkers) {
|
const globber = await glob.create(markerFilePatterns)
|
||||||
const wrapperZip = wrapperMarker.substring(
|
const markerFiles = await globber.glob()
|
||||||
|
|
||||||
|
for (const markerFile of markerFiles) {
|
||||||
|
const targetFile = markerFile.substring(
|
||||||
0,
|
0,
|
||||||
wrapperMarker.length - '.txt'.length
|
markerFile.length - MARKER_FILE_EXTENSION.length
|
||||||
)
|
)
|
||||||
core.info(
|
core.info(
|
||||||
`Wrapper marker: ${wrapperMarker}. Looking for zip ${wrapperZip}`
|
`Found marker file: ${markerFile}. Looking for ${targetFile}`
|
||||||
)
|
)
|
||||||
|
|
||||||
if (!fs.existsSync(wrapperZip)) {
|
if (!fs.existsSync(targetFile)) {
|
||||||
// Extract the wrapper URL hash
|
const key = path.relative(this.getGradleUserHome(), targetFile)
|
||||||
const wrapperKey = path.basename(path.dirname(wrapperMarker))
|
const cacheKey = `gradle-dedup-${key}`
|
||||||
core.info(`Wrapper key: ${wrapperKey}`)
|
core.info(`Cache key: ${cacheKey}. Cache path: ${targetFile}`)
|
||||||
|
|
||||||
const cacheKey = `gradle-wrapper-${wrapperKey}`
|
|
||||||
core.info(`Cache key: ${cacheKey}. Cache path: ${wrapperZip}`)
|
|
||||||
|
|
||||||
const restoreKey = await cache.restoreCache(
|
const restoreKey = await cache.restoreCache(
|
||||||
[wrapperZip],
|
[targetFile],
|
||||||
cacheKey
|
cacheKey
|
||||||
)
|
)
|
||||||
if (restoreKey) {
|
if (restoreKey) {
|
||||||
core.info(
|
core.info(
|
||||||
`Restored wrapper zip ${cacheKey} from cache to ${wrapperZip}`
|
`Restored ${cacheKey} from cache to ${targetFile}`
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
core.info(
|
||||||
`Did NOT restore wrapper zip from ${cacheKey} to ${wrapperZip}`
|
`Did NOT restore from ${cacheKey} to ${targetFile}`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
core.info(`Wrapper zip file already exists: ${wrapperZip}`)
|
core.info(`Target file already exists: ${targetFile}`)
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async restoreGeneratedJars(): Promise<void> {
|
|
||||||
const globber = await glob.create(
|
|
||||||
'~/.gradle/caches/*/generated-gradle-jars/*.jar.txt'
|
|
||||||
)
|
|
||||||
const generatedJarMarkers = await globber.glob()
|
|
||||||
|
|
||||||
core.info('Found the following generated jars')
|
|
||||||
for (const jarMarker of generatedJarMarkers) {
|
|
||||||
const generatedJar = jarMarker.substring(
|
|
||||||
0,
|
|
||||||
jarMarker.length - '.txt'.length
|
|
||||||
)
|
|
||||||
core.info(
|
|
||||||
`Jar marker: ${jarMarker}. Looking for jar ${generatedJar}`
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!fs.existsSync(generatedJar)) {
|
|
||||||
// Extract the wrapper URL hash
|
|
||||||
const jarKey = path.basename(generatedJar)
|
|
||||||
const cacheKey = `gradle-generated-jar-${jarKey}`
|
|
||||||
core.info(`Cache key: ${cacheKey}. Cache path: ${generatedJar}`)
|
|
||||||
|
|
||||||
const restoreKey = await cache.restoreCache(
|
|
||||||
[generatedJar],
|
|
||||||
cacheKey
|
|
||||||
)
|
|
||||||
if (restoreKey) {
|
|
||||||
core.info(
|
|
||||||
`Restored generated jar ${cacheKey} from cache to ${generatedJar}`
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
core.info(
|
|
||||||
`Did NOT restore generated jar from ${cacheKey} to ${generatedJar}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
core.info(`Generated jar file already exists: ${generatedJar}`)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -125,30 +88,28 @@ export class GradleUserHomeCache extends AbstractCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async save(): Promise<void> {
|
async save(): Promise<void> {
|
||||||
await this.cacheWrapperZips()
|
await this.cacheDeduplicatedPaths()
|
||||||
await this.cacheGeneratedJars()
|
|
||||||
await super.save()
|
await super.save()
|
||||||
}
|
}
|
||||||
|
|
||||||
private async cacheWrapperZips(): Promise<void> {
|
private async cacheDeduplicatedPaths(): Promise<void> {
|
||||||
const globber = await glob.create('~/.gradle/wrapper/dists/*/*/*.zip')
|
const targetFilePatterns = DEDUPLCIATED_PATHS.join('\n')
|
||||||
const wrapperZips = await globber.glob()
|
core.info(`Using target file patterns: ${targetFilePatterns}`)
|
||||||
|
const globber = await glob.create(targetFilePatterns)
|
||||||
|
const targetFiles = await globber.glob()
|
||||||
|
|
||||||
for (const wrapperZip of wrapperZips) {
|
for (const targetFile of targetFiles) {
|
||||||
core.info(`Wrapper zip: ${wrapperZip}`)
|
core.info(`Deduplicate caching: ${targetFile}`)
|
||||||
|
|
||||||
const wrapperMarkerFile = `${wrapperZip}.txt`
|
const markerFile = `${targetFile}${MARKER_FILE_EXTENSION}`
|
||||||
|
|
||||||
if (!fs.existsSync(wrapperMarkerFile)) {
|
if (!fs.existsSync(markerFile)) {
|
||||||
// Extract the wrapper URL hash
|
const key = path.relative(this.getGradleUserHome(), targetFile)
|
||||||
const wrapperKey = path.basename(path.dirname(wrapperZip))
|
const cacheKey = `gradle-dedup-${key}`
|
||||||
core.info(`Wrapper key: ${wrapperKey}`)
|
core.info(`Cache key: ${cacheKey}. Cache path: ${targetFile}`)
|
||||||
|
|
||||||
const cacheKey = `gradle-wrapper-${wrapperKey}`
|
|
||||||
|
|
||||||
core.info(`Caching wrapper with cache key: ${cacheKey}`)
|
|
||||||
try {
|
try {
|
||||||
await cache.saveCache([wrapperZip], cacheKey)
|
await cache.saveCache([targetFile], cacheKey)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// Fail on validation errors or non-errors (the latter to keep Typescript happy)
|
// Fail on validation errors or non-errors (the latter to keep Typescript happy)
|
||||||
if (
|
if (
|
||||||
@@ -162,71 +123,28 @@ export class GradleUserHomeCache extends AbstractCache {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the marker file and delete the original
|
// Write the marker file and delete the original
|
||||||
fs.writeFileSync(wrapperMarkerFile, 'dummy')
|
fs.writeFileSync(markerFile, 'dummy')
|
||||||
} else {
|
} else {
|
||||||
core.info(
|
core.info(`Marker file already exists: ${markerFile}`)
|
||||||
`Wrapper marker file already exists: ${wrapperMarkerFile}`
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : Should not need to delete. Just exclude from cache path.
|
// TODO : Should not need to delete. Just exclude from cache path.
|
||||||
// Delete the wrapper
|
// Delete the target file
|
||||||
fs.unlinkSync(wrapperZip)
|
fs.unlinkSync(targetFile)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private async cacheGeneratedJars(): Promise<void> {
|
|
||||||
const globber = await glob.create(
|
|
||||||
'~/.gradle/caches/*/generated-gradle-jars/*.jar'
|
|
||||||
)
|
|
||||||
const generatedJars = await globber.glob()
|
|
||||||
|
|
||||||
for (const generatedJar of generatedJars) {
|
|
||||||
core.info(`Generated jar: ${generatedJar}`)
|
|
||||||
|
|
||||||
const generatedJarMarkerFile = `${generatedJar}.txt`
|
|
||||||
|
|
||||||
if (!fs.existsSync(generatedJarMarkerFile)) {
|
|
||||||
// Key by jar file name: this includes Gradle version
|
|
||||||
const jarKey = path.basename(generatedJar)
|
|
||||||
const cacheKey = `gradle-generated-jar-${jarKey}`
|
|
||||||
|
|
||||||
core.info(`Caching generated jar with cache key: ${cacheKey}`)
|
|
||||||
try {
|
|
||||||
await cache.saveCache([generatedJar], cacheKey)
|
|
||||||
} catch (error) {
|
|
||||||
// Fail on validation errors or non-errors (the latter to keep Typescript happy)
|
|
||||||
if (
|
|
||||||
error instanceof cache.ValidationError ||
|
|
||||||
!(error instanceof Error)
|
|
||||||
) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
// TODO : Avoid warning for reserve cache error: this is expected
|
|
||||||
core.warning(error.message)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the marker file and delete the original
|
|
||||||
fs.writeFileSync(generatedJarMarkerFile, 'dummy')
|
|
||||||
} else {
|
|
||||||
core.info(
|
|
||||||
`Wrapper marker file already exists: ${generatedJarMarkerFile}`
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO : Should not need to delete. Just exclude from cache path.
|
|
||||||
// Delete the jar
|
|
||||||
fs.unlinkSync(generatedJar)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected cacheOutputExists(): boolean {
|
protected cacheOutputExists(): boolean {
|
||||||
// Need to check for 'caches' directory to avoid incorrect detection on MacOS agents
|
// Need to check for 'caches' directory to avoid incorrect detection on MacOS agents
|
||||||
const dir = path.resolve(os.homedir(), '.gradle/caches')
|
const dir = path.resolve(this.getGradleUserHome(), 'caches')
|
||||||
return fs.existsSync(dir)
|
return fs.existsSync(dir)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected getCachePath(): string[] {
|
protected getCachePath(): string[] {
|
||||||
return CACHE_PATH
|
return CACHE_PATH
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected getGradleUserHome(): string {
|
||||||
|
return path.resolve(os.homedir(), '.gradle')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user