Loading __tests__/cache.test.ts +33 Changes for __tests__/cache.test.ts: 33 added lines, 0 removed lines. Original line number Diff line number Diff line import * as cache from '../src/cache' import * as path from 'path' describe('cache', () => { describe('can extract gradle wrapper slug', () => { it('from wrapper properties file', async () => { const version = cache.extractGradleWrapperSlugFrom( path.resolve( '__tests__/data/basic/gradle/wrapper/gradle-wrapper.properties' ) ) expect(version).toBe('6.5-bin') }) it('for -bin dist', async () => { const version = cache.extractGradleWrapperSlugFromDistUri( 'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.5-bin.zip' ) expect(version).toBe('6.5-bin') }) it('for -all dist', async () => { const version = cache.extractGradleWrapperSlugFromDistUri( 'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.5-all.zip' ) expect(version).toBe('6.5-all') }) it('for milestone', async () => { const version = cache.extractGradleWrapperSlugFromDistUri( 'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.6-milestone-1-all.zip' ) expect(version).toBe('6.6-milestone-1-all') }) }) }) __tests__/main.test.ts −3 File deleted. Show changes dist/main/index.js +1 −1 File changed.Preview size limit exceeded, changes collapsed. Show changes dist/post/index.js +1 −1 Changes for dist/post/index.js: 1 added line, 1 removed line. Original line number Diff line number Diff line module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};var o=true;try{e[t].call(n.exports,n,n.exports,__webpack_require__);o=false}finally{if(o)delete r[t]}n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}({87:function(e){e.exports=require("os")},431:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(87));function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+o.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const i="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=i+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${i}${escapeData(this.message)}`;return e}}function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue;function escapeData(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},470:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=r(431);const s=o(r(87));const u=o(r(622));var a;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(a=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const r=i.toCommandValue(t);process.env[e]=r;i.issueCommand("set-env",{name:e},r)}t.exportVariable=exportVariable;function setSecret(e){i.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){i.issueCommand("add-path",{},e);process.env["PATH"]=`${e}${u.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}return r.trim()}t.getInput=getInput;function setOutput(e,t){i.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){i.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=a.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){i.issueCommand("debug",{},e)}t.debug=debug;function error(e){i.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){i.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+s.EOL)}t.info=info;function startGroup(e){i.issue("group",e)}t.startGroup=startGroup;function endGroup(){i.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return n(this,void 0,void 0,function*(){startGroup(e);let r;try{r=yield t()}finally{endGroup()}return r})}t.group=group;function saveState(e,t){i.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},622:function(e){e.exports=require("path")},722:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=o(r(470));const s=o(r(622));function restoreCachedWrapperDist(e){return n(this,void 0,void 0,function*(){i.saveState("WRAPPER_BASE_DIR",s.resolve(e));i.info(`WRAPPER_BASE_DIR = ${i.getState("WRAPPER_BASE_DIR")}`);const t=s.join(e,"gradle/wrapper/gradle-wrapper.properties");i.info(`wrapper properties = ${t}`)})}t.restoreCachedWrapperDist=restoreCachedWrapperDist;function cacheWrapperDist(){return n(this,void 0,void 0,function*(){i.info(`WRAPPER_BASE_DIR = ${i.getState("WRAPPER_BASE_DIR")}`)})}t.cacheWrapperDist=cacheWrapperDist},878:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=o(r(470));const s=o(r(722));function run(){return n(this,void 0,void 0,function*(){i.info("POST Gradle Command Action");yield s.cacheWrapperDist()})}t.run=run;run()}}); No newline at end of file module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};var o=true;try{e[t].call(n.exports,n,n.exports,__webpack_require__);o=false}finally{if(o)delete r[t]}n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}({87:function(e){e.exports=require("os")},431:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(87));function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+o.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const i="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=i+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${i}${escapeData(this.message)}`;return e}}function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue;function escapeData(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},470:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=r(431);const s=o(r(87));const u=o(r(622));var a;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(a=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const r=i.toCommandValue(t);process.env[e]=r;i.issueCommand("set-env",{name:e},r)}t.exportVariable=exportVariable;function setSecret(e){i.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){i.issueCommand("add-path",{},e);process.env["PATH"]=`${e}${u.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}return r.trim()}t.getInput=getInput;function setOutput(e,t){i.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){i.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=a.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){i.issueCommand("debug",{},e)}t.debug=debug;function error(e){i.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){i.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+s.EOL)}t.info=info;function startGroup(e){i.issue("group",e)}t.startGroup=startGroup;function endGroup(){i.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return n(this,void 0,void 0,function*(){startGroup(e);let r;try{r=yield t()}finally{endGroup()}return r})}t.group=group;function saveState(e,t){i.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},622:function(e){e.exports=require("path")},722:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=o(r(470));const s=o(r(622));const u=o(r(747));const a="WRAPPER_CACHE_KEY";const c="WRAPPER_CACHE_PATH";function restoreCachedWrapperDist(e){return n(this,void 0,void 0,function*(){const t=extractGradleWrapperSlugFrom(s.join(s.resolve(e),"gradle/wrapper/gradle-wrapper.properties"));const r=`wrapper-${t}`;const n=s.join(process.env.HOME,`.gradle/wrapper/dists/gradle-${t}`);i.info(`${a} = ${r}`);i.info(`${c} = ${n}`);i.saveState(a,r);i.saveState(c,n);return})}t.restoreCachedWrapperDist=restoreCachedWrapperDist;function cacheWrapperDist(){return n(this,void 0,void 0,function*(){i.info(`${a} = ${i.getState(a)}`);i.info(`${c} = ${i.getState(c)}`);return})}t.cacheWrapperDist=cacheWrapperDist;function extractGradleWrapperSlugFrom(e){const t=u.readFileSync(e,{encoding:"utf8"});const r=t.split("\n").find(e=>e.startsWith("distributionUrl"));if(!r)return null;return extractGradleWrapperSlugFromDistUri(r.substr(16).trim())}t.extractGradleWrapperSlugFrom=extractGradleWrapperSlugFrom;function extractGradleWrapperSlugFromDistUri(e){const t=/.*gradle-(.*-(bin|all))\.zip/;const r=e.match(t);return r?r[1]:null}t.extractGradleWrapperSlugFromDistUri=extractGradleWrapperSlugFromDistUri},747:function(e){e.exports=require("fs")},878:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=o(r(470));const s=o(r(722));function run(){return n(this,void 0,void 0,function*(){i.info("POST Gradle Command Action");yield s.cacheWrapperDist()})}t.run=run;run()}}); No newline at end of file src/cache.ts +40 −6 Changes for src/cache.ts: 40 added lines, 6 removed lines. Original line number Diff line number Diff line import * as core from '@actions/core' import * as path from 'path' import * as fs from 'fs' const WRAPPER_CACHE_KEY = 'WRAPPER_CACHE_KEY' const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH' export async function restoreCachedWrapperDist( executableDirectory: string ): Promise<void> { core.saveState('WRAPPER_BASE_DIR', path.resolve(executableDirectory)) core.info(`WRAPPER_BASE_DIR = ${core.getState('WRAPPER_BASE_DIR')}`) const wrapperProperties = path.join( executableDirectory, const wrapperSlug = extractGradleWrapperSlugFrom( path.join( path.resolve(executableDirectory), 'gradle/wrapper/gradle-wrapper.properties' ) core.info(`wrapper properties = ${wrapperProperties}`) ) const wrapperCacheKey = `wrapper-${wrapperSlug}` const wrapperCachePath = path.join( process.env.HOME!, `.gradle/wrapper/dists/gradle-${wrapperSlug}` ) core.info(`${WRAPPER_CACHE_KEY} = ${wrapperCacheKey}`) core.info(`${WRAPPER_CACHE_PATH} = ${wrapperCachePath}`) core.saveState(WRAPPER_CACHE_KEY, wrapperCacheKey) core.saveState(WRAPPER_CACHE_PATH, wrapperCachePath) return } export async function cacheWrapperDist(): Promise<void> { core.info(`WRAPPER_BASE_DIR = ${core.getState('WRAPPER_BASE_DIR')}`) core.info(`${WRAPPER_CACHE_KEY} = ${core.getState(WRAPPER_CACHE_KEY)}`) core.info(`${WRAPPER_CACHE_PATH} = ${core.getState(WRAPPER_CACHE_PATH)}`) return } export function extractGradleWrapperSlugFrom( wrapperProperties: string ): string | null { const props = fs.readFileSync(wrapperProperties, {encoding: 'utf8'}) const distUrlLine = props .split('\n') .find(line => line.startsWith('distributionUrl')) if (!distUrlLine) return null return extractGradleWrapperSlugFromDistUri(distUrlLine.substr(16).trim()) } export function extractGradleWrapperSlugFromDistUri( distUri: string ): string | null { const regex = /.*gradle-(.*-(bin|all))\.zip/ const match = distUri.match(regex) return match ? match[1] : null } Loading
__tests__/cache.test.ts +33 Changes for __tests__/cache.test.ts: 33 added lines, 0 removed lines. Original line number Diff line number Diff line import * as cache from '../src/cache' import * as path from 'path' describe('cache', () => { describe('can extract gradle wrapper slug', () => { it('from wrapper properties file', async () => { const version = cache.extractGradleWrapperSlugFrom( path.resolve( '__tests__/data/basic/gradle/wrapper/gradle-wrapper.properties' ) ) expect(version).toBe('6.5-bin') }) it('for -bin dist', async () => { const version = cache.extractGradleWrapperSlugFromDistUri( 'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.5-bin.zip' ) expect(version).toBe('6.5-bin') }) it('for -all dist', async () => { const version = cache.extractGradleWrapperSlugFromDistUri( 'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.5-all.zip' ) expect(version).toBe('6.5-all') }) it('for milestone', async () => { const version = cache.extractGradleWrapperSlugFromDistUri( 'distributionUrl=https\\://services.gradle.org/distributions/gradle-6.6-milestone-1-all.zip' ) expect(version).toBe('6.6-milestone-1-all') }) }) })
dist/post/index.js +1 −1 Changes for dist/post/index.js: 1 added line, 1 removed line. Original line number Diff line number Diff line module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};var o=true;try{e[t].call(n.exports,n,n.exports,__webpack_require__);o=false}finally{if(o)delete r[t]}n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}({87:function(e){e.exports=require("os")},431:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(87));function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+o.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const i="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=i+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${i}${escapeData(this.message)}`;return e}}function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue;function escapeData(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},470:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=r(431);const s=o(r(87));const u=o(r(622));var a;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(a=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const r=i.toCommandValue(t);process.env[e]=r;i.issueCommand("set-env",{name:e},r)}t.exportVariable=exportVariable;function setSecret(e){i.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){i.issueCommand("add-path",{},e);process.env["PATH"]=`${e}${u.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}return r.trim()}t.getInput=getInput;function setOutput(e,t){i.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){i.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=a.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){i.issueCommand("debug",{},e)}t.debug=debug;function error(e){i.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){i.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+s.EOL)}t.info=info;function startGroup(e){i.issue("group",e)}t.startGroup=startGroup;function endGroup(){i.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return n(this,void 0,void 0,function*(){startGroup(e);let r;try{r=yield t()}finally{endGroup()}return r})}t.group=group;function saveState(e,t){i.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},622:function(e){e.exports=require("path")},722:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=o(r(470));const s=o(r(622));function restoreCachedWrapperDist(e){return n(this,void 0,void 0,function*(){i.saveState("WRAPPER_BASE_DIR",s.resolve(e));i.info(`WRAPPER_BASE_DIR = ${i.getState("WRAPPER_BASE_DIR")}`);const t=s.join(e,"gradle/wrapper/gradle-wrapper.properties");i.info(`wrapper properties = ${t}`)})}t.restoreCachedWrapperDist=restoreCachedWrapperDist;function cacheWrapperDist(){return n(this,void 0,void 0,function*(){i.info(`WRAPPER_BASE_DIR = ${i.getState("WRAPPER_BASE_DIR")}`)})}t.cacheWrapperDist=cacheWrapperDist},878:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=o(r(470));const s=o(r(722));function run(){return n(this,void 0,void 0,function*(){i.info("POST Gradle Command Action");yield s.cacheWrapperDist()})}t.run=run;run()}}); No newline at end of file module.exports=function(e,t){"use strict";var r={};function __webpack_require__(t){if(r[t]){return r[t].exports}var n=r[t]={i:t,l:false,exports:{}};var o=true;try{e[t].call(n.exports,n,n.exports,__webpack_require__);o=false}finally{if(o)delete r[t]}n.l=true;return n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return __webpack_require__(878)}return startup()}({87:function(e){e.exports=require("os")},431:function(e,t,r){"use strict";var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=n(r(87));function issueCommand(e,t,r){const n=new Command(e,t,r);process.stdout.write(n.toString()+o.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const i="::";class Command{constructor(e,t,r){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=r}toString(){let e=i+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const r in this.properties){if(this.properties.hasOwnProperty(r)){const n=this.properties[r];if(n){if(t){t=false}else{e+=","}e+=`${r}=${escapeProperty(n)}`}}}}e+=`${i}${escapeData(this.message)}`;return e}}function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue;function escapeData(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},470:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=r(431);const s=o(r(87));const u=o(r(622));var a;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(a=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const r=i.toCommandValue(t);process.env[e]=r;i.issueCommand("set-env",{name:e},r)}t.exportVariable=exportVariable;function setSecret(e){i.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){i.issueCommand("add-path",{},e);process.env["PATH"]=`${e}${u.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const r=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!r){throw new Error(`Input required and not supplied: ${e}`)}return r.trim()}t.getInput=getInput;function setOutput(e,t){i.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){i.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=a.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){i.issueCommand("debug",{},e)}t.debug=debug;function error(e){i.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){i.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+s.EOL)}t.info=info;function startGroup(e){i.issue("group",e)}t.startGroup=startGroup;function endGroup(){i.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return n(this,void 0,void 0,function*(){startGroup(e);let r;try{r=yield t()}finally{endGroup()}return r})}t.group=group;function saveState(e,t){i.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},622:function(e){e.exports=require("path")},722:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=o(r(470));const s=o(r(622));const u=o(r(747));const a="WRAPPER_CACHE_KEY";const c="WRAPPER_CACHE_PATH";function restoreCachedWrapperDist(e){return n(this,void 0,void 0,function*(){const t=extractGradleWrapperSlugFrom(s.join(s.resolve(e),"gradle/wrapper/gradle-wrapper.properties"));const r=`wrapper-${t}`;const n=s.join(process.env.HOME,`.gradle/wrapper/dists/gradle-${t}`);i.info(`${a} = ${r}`);i.info(`${c} = ${n}`);i.saveState(a,r);i.saveState(c,n);return})}t.restoreCachedWrapperDist=restoreCachedWrapperDist;function cacheWrapperDist(){return n(this,void 0,void 0,function*(){i.info(`${a} = ${i.getState(a)}`);i.info(`${c} = ${i.getState(c)}`);return})}t.cacheWrapperDist=cacheWrapperDist;function extractGradleWrapperSlugFrom(e){const t=u.readFileSync(e,{encoding:"utf8"});const r=t.split("\n").find(e=>e.startsWith("distributionUrl"));if(!r)return null;return extractGradleWrapperSlugFromDistUri(r.substr(16).trim())}t.extractGradleWrapperSlugFrom=extractGradleWrapperSlugFrom;function extractGradleWrapperSlugFromDistUri(e){const t=/.*gradle-(.*-(bin|all))\.zip/;const r=e.match(t);return r?r[1]:null}t.extractGradleWrapperSlugFromDistUri=extractGradleWrapperSlugFromDistUri},747:function(e){e.exports=require("fs")},878:function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){function adopt(e){return e instanceof r?e:new r(function(t){t(e)})}return new(r||(r=Promise))(function(r,o){function fulfilled(e){try{step(n.next(e))}catch(e){o(e)}}function rejected(e){try{step(n["throw"](e))}catch(e){o(e)}}function step(e){e.done?r(e.value):adopt(e.value).then(fulfilled,rejected)}step((n=n.apply(e,t||[])).next())})};var o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)if(Object.hasOwnProperty.call(e,r))t[r]=e[r];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const i=o(r(470));const s=o(r(722));function run(){return n(this,void 0,void 0,function*(){i.info("POST Gradle Command Action");yield s.cacheWrapperDist()})}t.run=run;run()}}); No newline at end of file
src/cache.ts +40 −6 Changes for src/cache.ts: 40 added lines, 6 removed lines. Original line number Diff line number Diff line import * as core from '@actions/core' import * as path from 'path' import * as fs from 'fs' const WRAPPER_CACHE_KEY = 'WRAPPER_CACHE_KEY' const WRAPPER_CACHE_PATH = 'WRAPPER_CACHE_PATH' export async function restoreCachedWrapperDist( executableDirectory: string ): Promise<void> { core.saveState('WRAPPER_BASE_DIR', path.resolve(executableDirectory)) core.info(`WRAPPER_BASE_DIR = ${core.getState('WRAPPER_BASE_DIR')}`) const wrapperProperties = path.join( executableDirectory, const wrapperSlug = extractGradleWrapperSlugFrom( path.join( path.resolve(executableDirectory), 'gradle/wrapper/gradle-wrapper.properties' ) core.info(`wrapper properties = ${wrapperProperties}`) ) const wrapperCacheKey = `wrapper-${wrapperSlug}` const wrapperCachePath = path.join( process.env.HOME!, `.gradle/wrapper/dists/gradle-${wrapperSlug}` ) core.info(`${WRAPPER_CACHE_KEY} = ${wrapperCacheKey}`) core.info(`${WRAPPER_CACHE_PATH} = ${wrapperCachePath}`) core.saveState(WRAPPER_CACHE_KEY, wrapperCacheKey) core.saveState(WRAPPER_CACHE_PATH, wrapperCachePath) return } export async function cacheWrapperDist(): Promise<void> { core.info(`WRAPPER_BASE_DIR = ${core.getState('WRAPPER_BASE_DIR')}`) core.info(`${WRAPPER_CACHE_KEY} = ${core.getState(WRAPPER_CACHE_KEY)}`) core.info(`${WRAPPER_CACHE_PATH} = ${core.getState(WRAPPER_CACHE_PATH)}`) return } export function extractGradleWrapperSlugFrom( wrapperProperties: string ): string | null { const props = fs.readFileSync(wrapperProperties, {encoding: 'utf8'}) const distUrlLine = props .split('\n') .find(line => line.startsWith('distributionUrl')) if (!distUrlLine) return null return extractGradleWrapperSlugFromDistUri(distUrlLine.substr(16).trim()) } export function extractGradleWrapperSlugFromDistUri( distUri: string ): string | null { const regex = /.*gradle-(.*-(bin|all))\.zip/ const match = distUri.match(regex) return match ? match[1] : null }