refactor: use boolean input instead of manual conversion (#127)

* refactor: use boolean input instead of manual conversion

* refactor: update setup test with less manual mocks

* chore: upgrade to latest actions core version

* fix: clean up the mock input util

* chore: rebuild from macos

* fix: add text to gitattributes

* chore: remove built files

* chore: add build files back
This commit is contained in:
Cedric van Putten authored and GitHub committed 2021-11-17 12:48:22 +01:00
1 parent ff2ff0f980
commit f1fe877592
11 files changed
+87 -143

No files matched your search

+1 -1
View File
@@ -3,4 +3,4 @@
* text=auto
# These files are text and should be normalized (Convert crlf => lf)
build/** eol=lf
build/** text eol=lf
+2 -2
View File
@@ -1,4 +1,4 @@
require('./sourcemap-register.js');(()=>{var __webpack_modules__={27799:function(e,t,n){"use strict";var i=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,s){function fulfilled(e){try{step(i.next(e))}catch(e){s(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){s(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};var s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=s(n(42186));const a=s(n(85622));const c=s(n(91518));const l=s(n(98245));const u=n(56490);class ValidationError extends Error{constructor(e){super(e);this.name="ValidationError";Object.setPrototypeOf(this,ValidationError.prototype)}}t.ValidationError=ValidationError;class ReserveCacheError extends Error{constructor(e){super(e);this.name="ReserveCacheError";Object.setPrototypeOf(this,ReserveCacheError.prototype)}}t.ReserveCacheError=ReserveCacheError;function checkPaths(e){if(!e||e.length===0){throw new ValidationError(`Path Validation Error: At least one directory or file path is required`)}}function checkKey(e){if(e.length>512){throw new ValidationError(`Key Validation Error: ${e} cannot be larger than 512 characters.`)}const t=/^[^,]*$/;if(!t.test(e)){throw new ValidationError(`Key Validation Error: ${e} cannot contain commas.`)}}function restoreCache(e,t,n,s){return i(this,void 0,void 0,(function*(){checkPaths(e);n=n||[];const i=[t,...n];o.debug("Resolved Keys:");o.debug(JSON.stringify(i));if(i.length>10){throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`)}for(const e of i){checkKey(e)}const p=yield c.getCompressionMethod();const h=yield l.getCacheEntry(i,e,{compressionMethod:p});if(!(h===null||h===void 0?void 0:h.archiveLocation)){return undefined}const m=a.join(yield c.createTempDirectory(),c.getCacheFileName(p));o.debug(`Archive Path: ${m}`);try{yield l.downloadCache(h.archiveLocation,m,s);if(o.isDebug()){yield u.listTar(m,p)}const e=c.getArchiveFileSizeIsBytes(m);o.info(`Cache Size: ~${Math.round(e/(1024*1024))} MB (${e} B)`);yield u.extractTar(m,p);o.info("Cache restored successfully")}finally{try{yield c.unlinkFile(m)}catch(e){o.debug(`Failed to delete archive: ${e}`)}}return h.cacheKey}))}t.restoreCache=restoreCache;function saveCache(e,t,n){return i(this,void 0,void 0,(function*(){checkPaths(e);checkKey(t);const i=yield c.getCompressionMethod();o.debug("Reserving Cache");const s=yield l.reserveCache(t,e,{compressionMethod:i});if(s===-1){throw new ReserveCacheError(`Unable to reserve cache with key ${t}, another job may be creating this cache.`)}o.debug(`Cache ID: ${s}`);const p=yield c.resolvePaths(e);o.debug("Cache Paths:");o.debug(`${JSON.stringify(p)}`);const h=yield c.createTempDirectory();const m=a.join(h,c.getCacheFileName(i));o.debug(`Archive Path: ${m}`);yield u.createTar(h,p,i);if(o.isDebug()){yield u.listTar(m,i)}const d=5*1024*1024*1024;const g=c.getArchiveFileSizeIsBytes(m);o.debug(`File Size: ${g}`);if(g>d){throw new Error(`Cache size of ~${Math.round(g/(1024*1024))} MB (${g} B) is over the 5GB limit, not saving cache.`)}o.debug(`Saving Cache (ID: ${s})`);yield l.saveCache(s,m,n);return s}))}t.saveCache=saveCache},98245:function(e,t,n){"use strict";var i=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,s){function fulfilled(e){try{step(i.next(e))}catch(e){s(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){s(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};var s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=s(n(42186));const a=n(39925);const c=n(23702);const l=s(n(76417));const u=s(n(35747));const p=n(78835);const h=s(n(91518));const m=n(88840);const d=n(55500);const g=n(76215);const y=n(13981);const v="1.0";function getCacheApiUrl(e){const t=(process.env["ACTIONS_CACHE_URL"]||process.env["ACTIONS_RUNTIME_URL"]||"").replace("pipelines","artifactcache");if(!t){throw new Error("Cache Service Url not found, unable to restore cache.")}const n=`${t}_apis/artifactcache/${e}`;o.debug(`Resource Url: ${n}`);return n}function createAcceptHeader(e,t){return`${e};api-version=${t}`}function getRequestOptions(){const e={headers:{Accept:createAcceptHeader("application/json","6.0-preview.1")}};return e}function createHttpClient(){const e=process.env["ACTIONS_RUNTIME_TOKEN"]||"";const t=new c.BearerCredentialHandler(e);return new a.HttpClient("actions/cache",[t],getRequestOptions())}function getCacheVersiLine truncated
require('./sourcemap-register.js');(()=>{var __webpack_modules__={27799:function(e,t,n){"use strict";var i=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,s){function fulfilled(e){try{step(i.next(e))}catch(e){s(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){s(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};var s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=s(n(70448));const a=s(n(85622));const c=s(n(91518));const l=s(n(98245));const u=n(56490);class ValidationError extends Error{constructor(e){super(e);this.name="ValidationError";Object.setPrototypeOf(this,ValidationError.prototype)}}t.ValidationError=ValidationError;class ReserveCacheError extends Error{constructor(e){super(e);this.name="ReserveCacheError";Object.setPrototypeOf(this,ReserveCacheError.prototype)}}t.ReserveCacheError=ReserveCacheError;function checkPaths(e){if(!e||e.length===0){throw new ValidationError(`Path Validation Error: At least one directory or file path is required`)}}function checkKey(e){if(e.length>512){throw new ValidationError(`Key Validation Error: ${e} cannot be larger than 512 characters.`)}const t=/^[^,]*$/;if(!t.test(e)){throw new ValidationError(`Key Validation Error: ${e} cannot contain commas.`)}}function restoreCache(e,t,n,s){return i(this,void 0,void 0,(function*(){checkPaths(e);n=n||[];const i=[t,...n];o.debug("Resolved Keys:");o.debug(JSON.stringify(i));if(i.length>10){throw new ValidationError(`Key Validation Error: Keys are limited to a maximum of 10.`)}for(const e of i){checkKey(e)}const p=yield c.getCompressionMethod();const h=yield l.getCacheEntry(i,e,{compressionMethod:p});if(!(h===null||h===void 0?void 0:h.archiveLocation)){return undefined}const m=a.join(yield c.createTempDirectory(),c.getCacheFileName(p));o.debug(`Archive Path: ${m}`);try{yield l.downloadCache(h.archiveLocation,m,s);if(o.isDebug()){yield u.listTar(m,p)}const e=c.getArchiveFileSizeIsBytes(m);o.info(`Cache Size: ~${Math.round(e/(1024*1024))} MB (${e} B)`);yield u.extractTar(m,p);o.info("Cache restored successfully")}finally{try{yield c.unlinkFile(m)}catch(e){o.debug(`Failed to delete archive: ${e}`)}}return h.cacheKey}))}t.restoreCache=restoreCache;function saveCache(e,t,n){return i(this,void 0,void 0,(function*(){checkPaths(e);checkKey(t);const i=yield c.getCompressionMethod();o.debug("Reserving Cache");const s=yield l.reserveCache(t,e,{compressionMethod:i});if(s===-1){throw new ReserveCacheError(`Unable to reserve cache with key ${t}, another job may be creating this cache.`)}o.debug(`Cache ID: ${s}`);const p=yield c.resolvePaths(e);o.debug("Cache Paths:");o.debug(`${JSON.stringify(p)}`);const h=yield c.createTempDirectory();const m=a.join(h,c.getCacheFileName(i));o.debug(`Archive Path: ${m}`);yield u.createTar(h,p,i);if(o.isDebug()){yield u.listTar(m,i)}const d=5*1024*1024*1024;const g=c.getArchiveFileSizeIsBytes(m);o.debug(`File Size: ${g}`);if(g>d){throw new Error(`Cache size of ~${Math.round(g/(1024*1024))} MB (${g} B) is over the 5GB limit, not saving cache.`)}o.debug(`Saving Cache (ID: ${s})`);yield l.saveCache(s,m,n);return s}))}t.saveCache=saveCache},98245:function(e,t,n){"use strict";var i=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,s){function fulfilled(e){try{step(i.next(e))}catch(e){s(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){s(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};var s=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(Object.hasOwnProperty.call(e,n))t[n]=e[n];t["default"]=e;return t};Object.defineProperty(t,"__esModule",{value:true});const o=s(n(70448));const a=n(39925);const c=n(23702);const l=s(n(76417));const u=s(n(35747));const p=n(78835);const h=s(n(91518));const m=n(88840);const d=n(55500);const g=n(76215);const y=n(13981);const v="1.0";function getCacheApiUrl(e){const t=(process.env["ACTIONS_CACHE_URL"]||process.env["ACTIONS_RUNTIME_URL"]||"").replace("pipelines","artifactcache");if(!t){throw new Error("Cache Service Url not found, unable to restore cache.")}const n=`${t}_apis/artifactcache/${e}`;o.debug(`Resource Url: ${n}`);return n}function createAcceptHeader(e,t){return`${e};api-version=${t}`}function getRequestOptions(){const e={headers:{Accept:createAcceptHeader("application/json","6.0-preview.1")}};return e}function createHttpClient(){const e=process.env["ACTIONS_RUNTIME_TOKEN"]||"";const t=new c.BearerCredentialHandler(e);return new a.HttpClient("actions/cache",[t],getRequestOptions())}function getCacheVersiLine truncated
/*!
* Copyright (c) Microsoft and contributors. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
@@ -249,5 +249,5 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var t;var n;var i;var s;var o;var a;var c;var l;var u;var p;var h;var m;var d;var g;var y;var v;var b;var w;var x;var S;var k;var _;var C;var N;(function(t){var n=typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:{};if(typeof define==="function"&&define.amd){define("tslib",["exports"],(function(e){t(createExporter(n,createExporter(e)))}))}else if(true&&typeof e.exports==="object"){t(createExporter(n,createExporter(e.exports)))}else{t(createExporter(n))}function createExporter(e,t){if(e!==n){if(typeof Object.create==="function"){Object.defineProperty(e,"__esModule",{value:true})}else{e.__esModule=true}}return function(n,i){return e[n]=t?t(n,i):i}}})((function(e){var R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]};t=function(e,t){if(typeof t!=="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");R(e,t);function __(){this.constructor=e}e.prototype=t===null?Object.create(t):(__.prototype=t.prototype,new __)};n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s))e[s]=t[s]}return e};i=function(e,t){var n={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0)n[i]=e[i];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++){if(t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s]))n[i[s]]=e[i[s]]}return n};s=function(e,t,n,i){var s=arguments.length,o=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,t,n,i);else for(var c=e.length-1;c>=0;c--)if(a=e[c])o=(s<3?a(o):s>3?a(t,n,o):a(t,n))||o;return s>3&&o&&Object.defineProperty(t,n,o),o};o=function(e,t){return function(n,i){t(n,i,e)}};a=function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};c=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,s){function fulfilled(e){try{step(i.next(e))}catch(e){s(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){s(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};l=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,s,o,a;return a={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function verb(e){return function(t){return step([e,t])}}function step(a){if(i)throw new TypeError("Generator is already executing.");while(n)try{if(i=1,s&&(o=a[0]&2?s["return"]:a[0]?s["throw"]||((o=s["return"])&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;if(s=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;s=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];s=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};u=function(e,t){for(var n in e)if(n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n))N(t,e,n)};N=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]};p=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&i>=e.length)e=void 0;return{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};h=function(e,t){var n=typeof Symbol==="function"&&e[Symbol.iterator];if(!n)return e;var i=n.call(e),s,o=[],a;try{while((t===void 0||t-- >0)&&!(s=i.next()).done)o.push(s.value)}catch(e){a={error:e}}finally{try{if(s&&!s.done&&(n=i["return"]))n.call(i)}finally{if(a)throw a.error}}return o};m=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e};d=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var i=Array(e),s=0,t=0;t<n;t++)for(var o=arguments[t],a=0,c=o.length;a<c;a++,s++)i[s]=o[a];return i};g=function(e,t,n){if(n||arguments.length===2)for(var i=0,s=t.length,o;i<s;i++){if(o||!(i in t)){if(!o)o=Array.prototype.slice.call(t,0,i);o[i]=t[i]}}return e.concat(o||t)};y=function(e){return this instanceof y?(this.v=e,this):new y(e)};v=function(e,t,n){if(!Symbol.asyncItLine truncated
var t;var n;var i;var s;var o;var a;var c;var l;var u;var p;var h;var m;var d;var g;var y;var v;var b;var w;var x;var S;var k;var _;var C;var N;(function(t){var n=typeof global==="object"?global:typeof self==="object"?self:typeof this==="object"?this:{};if(typeof define==="function"&&define.amd){define("tslib",["exports"],(function(e){t(createExporter(n,createExporter(e)))}))}else if(true&&typeof e.exports==="object"){t(createExporter(n,createExporter(e.exports)))}else{t(createExporter(n))}function createExporter(e,t){if(e!==n){if(typeof Object.create==="function"){Object.defineProperty(e,"__esModule",{value:true})}else{e.__esModule=true}}return function(n,i){return e[n]=t?t(n,i):i}}})((function(e){var R=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)if(Object.prototype.hasOwnProperty.call(t,n))e[n]=t[n]};t=function(e,t){if(typeof t!=="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");R(e,t);function __(){this.constructor=e}e.prototype=t===null?Object.create(t):(__.prototype=t.prototype,new __)};n=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++){t=arguments[n];for(var s in t)if(Object.prototype.hasOwnProperty.call(t,s))e[s]=t[s]}return e};i=function(e,t){var n={};for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0)n[i]=e[i];if(e!=null&&typeof Object.getOwnPropertySymbols==="function")for(var s=0,i=Object.getOwnPropertySymbols(e);s<i.length;s++){if(t.indexOf(i[s])<0&&Object.prototype.propertyIsEnumerable.call(e,i[s]))n[i[s]]=e[i[s]]}return n};s=function(e,t,n,i){var s=arguments.length,o=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,n):i,a;if(typeof Reflect==="object"&&typeof Reflect.decorate==="function")o=Reflect.decorate(e,t,n,i);else for(var c=e.length-1;c>=0;c--)if(a=e[c])o=(s<3?a(o):s>3?a(t,n,o):a(t,n))||o;return s>3&&o&&Object.defineProperty(t,n,o),o};o=function(e,t){return function(n,i){t(n,i,e)}};a=function(e,t){if(typeof Reflect==="object"&&typeof Reflect.metadata==="function")return Reflect.metadata(e,t)};c=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,s){function fulfilled(e){try{step(i.next(e))}catch(e){s(e)}}function rejected(e){try{step(i["throw"](e))}catch(e){s(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((i=i.apply(e,t||[])).next())}))};l=function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,s,o,a;return a={next:verb(0),throw:verb(1),return:verb(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function verb(e){return function(t){return step([e,t])}}function step(a){if(i)throw new TypeError("Generator is already executing.");while(n)try{if(i=1,s&&(o=a[0]&2?s["return"]:a[0]?s["throw"]||((o=s["return"])&&o.call(s),0):s.next)&&!(o=o.call(s,a[1])).done)return o;if(s=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;s=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(e){a=[6,e];s=0}finally{i=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};u=function(e,t){for(var n in e)if(n!=="default"&&!Object.prototype.hasOwnProperty.call(t,n))N(t,e,n)};N=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]};p=function(e){var t=typeof Symbol==="function"&&Symbol.iterator,n=t&&e[t],i=0;if(n)return n.call(e);if(e&&typeof e.length==="number")return{next:function(){if(e&&i>=e.length)e=void 0;return{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")};h=function(e,t){var n=typeof Symbol==="function"&&e[Symbol.iterator];if(!n)return e;var i=n.call(e),s,o=[],a;try{while((t===void 0||t-- >0)&&!(s=i.next()).done)o.push(s.value)}catch(e){a={error:e}}finally{try{if(s&&!s.done&&(n=i["return"]))n.call(i)}finally{if(a)throw a.error}}return o};m=function(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(h(arguments[t]));return e};d=function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var i=Array(e),s=0,t=0;t<n;t++)for(var o=arguments[t],a=0,c=o.length;a<c;a++,s++)i[s]=o[a];return i};g=function(e,t,n){if(n||arguments.length===2)for(var i=0,s=t.length,o;i<s;i++){if(o||!(i in t)){if(!o)o=Array.prototype.slice.call(t,0,i);o[i]=t[i]}}return e.concat(o||t)};y=function(e){return this instanceof y?(this.v=e,this):new y(e)};v=function(e,t,n){if(!Symbol.asyncItLine truncated
//# sourceMappingURL=index.js.map
+1 -1
View File
@@ -1 +1 @@
{"version":3,"sources":["../webpack:/expo-github-action/node_modules/@actions/cache/lib/cache.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/cacheHttpClient.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/cacheUtils.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/constants.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/downloadUtils.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/requestUtils.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/tar.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/options.js","../webpack:/expo-github-action/node_modules/@actions/cache/node_modules/semver/semver.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/command.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/core.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/file-command.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/utils.js","../webpack:/expo-github-action/node_modules/@actions/exec/lib/exec.js","../webpack:/expo-github-action/node_modules/@actions/exec/lib/toolrunner.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/glob.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-glob-options-helper.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-globber.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-match-kind.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-path-helper.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-path.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-pattern-helper.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-pattern.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-search-state.js","../webpack:/expo-github-action/node_modules/@actions/http-client/auth.js","../webpack:/expo-github-action/node_modules/@actions/http-client/index.js","../webpack:/expo-github-action/node_modules/@actions/http-client/proxy.js","../webpack:/expo-github-action/node_modules/@actions/io/lib/io-util.js","../webpack:/expo-github-action/node_modules/@actions/io/lib/io.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/lib/manifest.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/lib/retry-helper.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/lib/tool-cache.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/node_modules/semver/semver.js","../webpack:/expo-github-action/node_modules/@azure/abort-controller/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-asynciterator-polyfill/dist-esm/index.js","../webpack:/expo-github-action/node_modules/@azure/core-auth/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-http/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/md5.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/nil.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/parse.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/regex.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/rng.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/sha1.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/stringify.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/v1.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/v3.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/v35.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/v4.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/v5.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/validate.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/version.js","../webpack:/expo-github-action/node_modules/@azure/core-lro/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-paging/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-tracing/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/logger/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/storage-blob/dist/index.js","../webpack:/expo-github-action/node_modules/@opentelemetry/api/build/src/api/context.js","../webpack:/expo-github-action/node_Line truncated
{"version":3,"sources":["../webpack:/expo-github-action/node_modules/@actions/cache/lib/cache.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/cacheHttpClient.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/cacheUtils.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/constants.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/downloadUtils.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/requestUtils.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/internal/tar.js","../webpack:/expo-github-action/node_modules/@actions/cache/lib/options.js","../webpack:/expo-github-action/node_modules/@actions/cache/node_modules/@actions/core/lib/command.js","../webpack:/expo-github-action/node_modules/@actions/cache/node_modules/@actions/core/lib/core.js","../webpack:/expo-github-action/node_modules/@actions/cache/node_modules/@actions/core/lib/file-command.js","../webpack:/expo-github-action/node_modules/@actions/cache/node_modules/@actions/core/lib/utils.js","../webpack:/expo-github-action/node_modules/@actions/cache/node_modules/semver/semver.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/command.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/core.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/file-command.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/oidc-utils.js","../webpack:/expo-github-action/node_modules/@actions/core/lib/utils.js","../webpack:/expo-github-action/node_modules/@actions/exec/lib/exec.js","../webpack:/expo-github-action/node_modules/@actions/exec/lib/toolrunner.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/glob.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-glob-options-helper.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-globber.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-match-kind.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-path-helper.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-path.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-pattern-helper.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-pattern.js","../webpack:/expo-github-action/node_modules/@actions/glob/lib/internal-search-state.js","../webpack:/expo-github-action/node_modules/@actions/glob/node_modules/@actions/core/lib/command.js","../webpack:/expo-github-action/node_modules/@actions/glob/node_modules/@actions/core/lib/core.js","../webpack:/expo-github-action/node_modules/@actions/glob/node_modules/@actions/core/lib/file-command.js","../webpack:/expo-github-action/node_modules/@actions/glob/node_modules/@actions/core/lib/utils.js","../webpack:/expo-github-action/node_modules/@actions/http-client/auth.js","../webpack:/expo-github-action/node_modules/@actions/http-client/index.js","../webpack:/expo-github-action/node_modules/@actions/http-client/proxy.js","../webpack:/expo-github-action/node_modules/@actions/io/lib/io-util.js","../webpack:/expo-github-action/node_modules/@actions/io/lib/io.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/lib/manifest.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/lib/retry-helper.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/lib/tool-cache.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/node_modules/@actions/core/lib/command.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/node_modules/@actions/core/lib/core.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/node_modules/@actions/core/lib/file-command.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/node_modules/@actions/core/lib/utils.js","../webpack:/expo-github-action/node_modules/@actions/tool-cache/node_modules/semver/semver.js","../webpack:/expo-github-action/node_modules/@azure/abort-controller/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-asynciterator-polyfill/dist-esm/index.js","../webpack:/expo-github-action/node_modules/@azure/core-auth/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-http/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/index.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/md5.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/nil.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/parse.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/regex.js","../webpack:/expo-github-action/node_modules/@azure/core-http/node_modules/uuid/dist/rng.js","../webpack:/expo-github-action/nodLine truncated
+1
View File
@@ -1,3 +1,4 @@
/** @type {import('@jest/types').Config.InitialOptions} */
module.exports = {
verbose: true,
clearMocks: true,
+1 -1
View File
@@ -23,7 +23,7 @@
},
"dependencies": {
"@actions/cache": "^1.0.7",
"@actions/core": "^1.4.0",
"@actions/core": "^1.6.0",
"@actions/exec": "^1.1.0",
"@actions/io": "^1.1.1",
"@actions/tool-cache": "^1.7.1",
+3 -3
View File
@@ -1,4 +1,4 @@
import { addPath, getInput, group, info } from '@actions/core';
import { addPath, getBooleanInput, getInput, group, info } from '@actions/core';
import { install } from '../install';
import * as tools from '../tools';
@@ -19,7 +19,7 @@ export async function setupAction(): Promise<void> {
})
);
if (tools.getBoolean(getInput('patch-watchers'), true)) {
if (!getInput('patch-watchers') || getBooleanInput('patch-watchers') !== false) {
await group('Patching system watchers for the `ENOSPC` error', () => tools.maybePatchWatchers());
}
}
@@ -34,7 +34,7 @@ async function installCli(name: tools.PackageName): Promise<string | void> {
}
const version = await tools.resolveVersion(name, inputVersion);
const cache = tools.getBoolean(getInput(`${shortName}-cache`), false);
const cache = getBooleanInput(`${shortName}-cache`);
try {
const path = await group(
-7
View File
@@ -14,13 +14,6 @@ export type AuthenticateOptions = {
password?: string;
};
/**
* Get a boolean value from string, useful for GitHub Actions boolean inputs.
*/
export function getBoolean(value: string, defaultValue = false): boolean {
return (value || String(defaultValue)).toLowerCase() === 'true';
}
/**
* Convert `expo-cli` or `eas-cli` to just their binary name.
* For windows we have to use `<bin>.cmd`, toolkit will handle the Windows binary with that.
+59 -103
View File
@@ -1,67 +1,71 @@
import { getToolsMock } from '../utils';
import { getToolsMock, mockInput } from '../utils';
const core = {
addPath: jest.fn(),
getInput: jest.fn(),
group: <T>(message: string, action: () => Promise<T>): Promise<T> => action(),
info: jest.fn(),
};
const exec = { exec: jest.fn() };
const install = { install: jest.fn() };
const tools = getToolsMock();
jest.mock('../../src/tools', () => getToolsMock());
jest.mock('@actions/core', () => core);
jest.mock('@actions/exec', () => exec);
jest.mock('../../src/tools', () => tools);
jest.mock('../../src/install', () => install);
import * as core from '@actions/core';
import * as install from '../../src/install';
import * as tools from '../../src/tools';
import { setupAction } from '../../src/actions/setup';
describe('run', () => {
it('patches the system when set to true', async () => {
mockInput({ patchWatchers: 'true' });
await setupAction();
expect(tools.maybePatchWatchers).toHaveBeenCalled();
describe(setupAction, () => {
describe('patch watchers', () => {
it('patches the system when set to true', async () => {
mockInput({ 'patch-watchers': 'true' });
await setupAction();
expect(tools.maybePatchWatchers).toHaveBeenCalled();
});
it('patches the system when not set', async () => {
mockInput({ 'patch-watchers': '' });
await setupAction();
expect(tools.maybePatchWatchers).toHaveBeenCalled();
});
it('skips the system patch when set to false', async () => {
mockInput({ 'patch-watchers': 'false' });
await setupAction();
expect(tools.maybePatchWatchers).not.toHaveBeenCalled();
});
});
it('patches the system when not set', async () => {
mockInput({ patchWatchers: '' });
await setupAction();
expect(tools.maybePatchWatchers).toHaveBeenCalled();
});
describe('authentication', () => {
it('authenticates with provided credentials', async () => {
mockInput({ username: 'bycedric', password: 'mypassword' });
await setupAction();
expect(tools.maybeAuthenticate).toBeCalledWith({ username: 'bycedric', password: 'mypassword' });
});
it('skips the system patch when set to false', async () => {
mockInput({ patchWatchers: 'false' });
await setupAction();
expect(tools.maybePatchWatchers).not.toHaveBeenCalled();
});
it('authenticates with provided credentials', async () => {
mockInput({ username: 'bycedric', password: 'mypassword', patchWatchers: 'false' });
await setupAction();
expect(tools.maybeAuthenticate).toBeCalledWith({ username: 'bycedric', password: 'mypassword' });
});
it('authenticates with provided token', async () => {
mockInput({ token: 'ABC123', patchWatchers: 'false' });
await setupAction();
expect(tools.maybeAuthenticate).toBeCalledWith({ token: 'ABC123' });
it('authenticates with provided token', async () => {
mockInput({ token: 'ABC123' });
await setupAction();
expect(tools.maybeAuthenticate).toBeCalledWith({ token: 'ABC123' });
});
});
['expo', 'eas'].forEach(cliName => {
const packageName = `${cliName}-cli`;
let installMock: jest.SpyInstance;
beforeEach(() => {
installMock = jest.spyOn(install, 'install').mockImplementation();
});
afterEach(() => {
installMock.mockRestore();
});
describe(packageName, () => {
it(`skips installation without \`${cliName}-version\``, async () => {
mockInput();
await setupAction();
expect(install.install).not.toBeCalledWith({ package: packageName });
expect(installMock).not.toBeCalledWith({ package: packageName });
});
it('installs with yarn by default', async () => {
mockInput({ [`${cliName}Version`]: 'latest' });
mockInput({ [`${cliName}-version`]: 'latest' });
await setupAction();
expect(install.install).toBeCalledWith({
expect(installMock).toBeCalledWith({
package: packageName,
version: 'latest',
packager: 'yarn',
@@ -70,9 +74,9 @@ describe('run', () => {
});
it('installs provided version with npm', async () => {
mockInput({ [`${cliName}Version`]: '3.0.10', packager: 'npm' });
mockInput({ [`${cliName}-version`]: '3.0.10', packager: 'npm' });
await setupAction();
expect(install.install).toBeCalledWith({
expect(installMock).toBeCalledWith({
package: packageName,
version: '3.0.10',
packager: 'npm',
@@ -83,11 +87,11 @@ describe('run', () => {
it('installs with yarn and cache enabled', async () => {
mockInput({
packager: 'yarn',
[`${cliName}Version`]: '4.2.0',
[`${cliName}Cache`]: 'true',
[`${cliName}-version`]: '4.2.0',
[`${cliName}-cache`]: 'true',
});
await setupAction();
expect(install.install).toBeCalledWith({
expect(installMock).toBeCalledWith({
package: packageName,
version: '4.2.0',
packager: 'yarn',
@@ -98,12 +102,12 @@ describe('run', () => {
it('installs with yarn and custom cache key', async () => {
mockInput({
packager: 'yarn',
[`${cliName}Version`]: '4.2.0',
[`${cliName}Cache`]: 'true',
[`${cliName}CacheKey`]: 'custom-key',
[`${cliName}-version`]: '4.2.0',
[`${cliName}-cache`]: 'true',
[`${cliName}-cache-key`]: 'custom-key',
});
await setupAction();
expect(install.install).toBeCalledWith({
expect(installMock).toBeCalledWith({
package: packageName,
version: '4.2.0',
packager: 'yarn',
@@ -113,59 +117,11 @@ describe('run', () => {
});
it('installs path to global path', async () => {
install.install.mockResolvedValue(`/${cliName}/install/path`);
installMock.mockResolvedValue(`/${cliName}/install/path`);
const addPathSpy = jest.spyOn(core, 'addPath').mockImplementation();
await setupAction();
expect(core.addPath).toBeCalledWith(`/${cliName}/install/path`);
expect(addPathSpy).toBeCalledWith(`/${cliName}/install/path`);
});
});
});
});
interface MockInputProps {
expoVersion?: string;
expoCache?: string;
expoCacheKey?: string;
easVersion?: string;
easCache?: string;
easCacheKey?: string;
packager?: string;
token?: string;
username?: string;
password?: string;
patchWatchers?: string;
}
function mockInput(props: MockInputProps = {}) {
// fix: kind of dirty workaround for missing "mock 'value' based on arguments"
const input = (name: string) => {
switch (name) {
case 'expo-version':
return props.expoVersion || '';
case 'expo-cache':
return props.expoCache || '';
case 'expo-cache-key':
return props.expoCacheKey || '';
case 'eas-version':
return props.easVersion || '';
case 'eas-cache':
return props.easCache || '';
case 'eas-cache-key':
return props.easCacheKey || '';
case 'packager':
return props.packager || '';
case 'token':
return props.token || '';
case 'username':
return props.username || '';
case 'password':
return props.password || '';
case 'patch-watchers':
return props.patchWatchers || '';
default:
return '';
}
};
// eslint-disable-next-line @typescript-eslint/no-explicit-any
core.getInput = input as any;
}
-22
View File
@@ -7,28 +7,6 @@ import * as cli from '@actions/exec';
import * as tools from '../src/tools';
import * as utils from './utils';
describe(tools.getBoolean, () => {
it('rreturns false for empty strings by default', () => {
expect(tools.getBoolean('')).toBeFalsy();
});
it('returns true for empty strings with default set to true', () => {
expect(tools.getBoolean('', true)).toBeTruthy();
});
it('returns true for `true` strings by default', () => {
expect(tools.getBoolean('true')).toBeTruthy();
});
it('returns false for `false` strings with default set to false', () => {
expect(tools.getBoolean('false', false)).toBeFalsy();
});
it('returns false for `false` strings with default set to true', () => {
expect(tools.getBoolean('false', true)).toBeFalsy();
});
});
describe(tools.getBinaryName, () => {
it('returns expo for `expo-cli`', () => {
expect(tools.getBinaryName('expo-cli')).toBe('expo');
+10 -1
View File
@@ -1,3 +1,5 @@
import * as core from '@actions/core';
// keep track of the original one to revert the platform
const originalPlatform = process.platform;
@@ -38,7 +40,6 @@ export function restoreEnv(): void {
*/
export function getToolsMock() {
return {
getBoolean: jest.fn((v, d) => (v ? v === 'true' : d)),
getBinaryName: jest.fn(v => v.replace('-cli', '')),
resolveVersion: jest.fn((n, v) => v),
maybeAuthenticate: jest.fn(),
@@ -48,3 +49,11 @@ export function getToolsMock() {
performAction: jest.fn(),
};
}
/**
* Mock both the input and boolean input methods from `@actions/core`.
*/
export function mockInput(inputs: Record<string, string> = {}) {
jest.spyOn(core, 'getInput').mockImplementation(name => inputs[name]);
jest.spyOn(core, 'getBooleanInput').mockImplementation(name => inputs[name] === 'true');
}
+9 -2
View File
@@ -17,11 +17,18 @@
semver "^6.1.0"
uuid "^3.3.3"
"@actions/core@^1.2.6", "@actions/core@^1.4.0":
"@actions/core@^1.2.6":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.4.0.tgz#cf2e6ee317e314b03886adfeb20e448d50d6e524"
integrity sha512-CGx2ilGq5i7zSLgiiGUtBCxhRRxibJYU6Fim0Q1Wg2aQL2LTnF27zbqZOrxfvFQ55eSBW0L8uVStgtKMpa0Qlg==
"@actions/core@^1.6.0":
version "1.6.0"
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.6.0.tgz#0568e47039bfb6a9170393a73f3b7eb3b22462cb"
integrity sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==
dependencies:
"@actions/http-client" "^1.0.11"
"@actions/exec@^1.0.0", "@actions/exec@^1.0.1", "@actions/exec@^1.1.0":
version "1.1.0"
resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.1.0.tgz#53441d968e56d2fec69ad3f15773d4d94e01162c"
@@ -37,7 +44,7 @@
"@actions/core" "^1.2.6"
minimatch "^3.0.4"
"@actions/http-client@^1.0.8", "@actions/http-client@^1.0.9":
"@actions/http-client@^1.0.11", "@actions/http-client@^1.0.8", "@actions/http-client@^1.0.9":
version "1.0.11"
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0"
integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==