diff --git a/out/in-cloud.entrypoint.js b/out/in-cloud.entrypoint.js index 397c4ba6..126e88c6 100644 --- a/out/in-cloud.entrypoint.js +++ b/out/in-cloud.entrypoint.js @@ -52,6 +52,6 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)},B. that the head commit SHA is not a temporary merge commit, but rather the head of the branch. Therefore we're using the base of the pull request (${t}) to compare the visual snapshots against, and not the base of GitHub's temporary merge commit.`),null;let n=(0,R.execSync)(`git cat-file -p ${a}`).toString().split("\n").filter(e=>e.startsWith("parent ")).map(e=>e.substring(7).trim());if(2!==n.length)return i.error(`GITHUB_SHA (${a}) is not a merge commit, so can't work out true base of the merge commit. Using the base of the pull request instead.`),null;let r=n[0];if(n[1]!==e)return i.error(`The second parent (${n[1]}) of the GITHUB_SHA merge commit (${a}) is not equal to the head of the PR (${e}), - so can not confidently determine the base of the merge commit to compare against. Using the base of the pull request instead (${t}).`),null;return r}catch(e){return i.error(`Error getting base of merge commit (${a}). Using the base of the pull request instead (${t}).`,e),null}},oC=()=>{(0,R.execSync)(`git config --global --add safe.directory "${process.cwd()}"`)},oA=e=>/^[a-f0-9]{40}$/.test(e),oU=(e,t)=>"push"===e?{type:"push",payload:t}:"pull_request"===e?{type:"pull_request",payload:t}:"workflow_dispatch"===e?{type:"workflow_dispatch",payload:t}:null;var r7=G("7SZkG");const oP=e=>{if(null==e)throw Error("github-token is required");try{return(0,ej.getOctokit)(e)}catch(e){throw I(r7).getLogger(av.METICULOUS_LOGGER_NAME).error(e),Error("Error connecting to GitHub. Did you specify a valid 'github-token'?")}},oj=({name:e,required:t,type:a,prefixInputEnv:i=!1})=>{let s=`${i?"INPUT_":""}${e.toUpperCase().replaceAll("-","_")}`,n=process.env[s];if(("string"===a||"string-array"===a)&&""===n&&!t)return null;let r=oI(n,a);if(t&&null==r||t&&oF(r)&&"string-array"!==a)throw Error(`Input ${e} is required`);if(null!=r&&typeof r!==oG(a))throw Error(`Expected ${a} for input ${e}, but got ${typeof r}`);return r},oI=(e,t)=>{if(null==e)return null;if("string"===t)return e;if("string-array"===t)return -1===e.indexOf("\n")?e.split(",").map(e=>e.trim()).filter(e=>""!==e):e.split("\n").map(e=>e.trim()).filter(e=>""!==e);if("int"===t){let t=Number.parseInt(e);return isNaN(t)?null:t}if("float"===t){let t=Number.parseFloat(e);return isNaN(t)?null:t}if("boolean"===t){if(""===e)return null;if("true"!==e&&"false"!==e)throw Error("Boolean inputs must be equal to the string 'true' or the string 'false'");return"true"===e}return oL(t)},oL=e=>{throw Error(`Only string or number inputs currently supported, but got ${e}`)},oF=e=>null==e||"string"==typeof e&&0===e.length,oG=e=>"string-array"===e?"object":"string"===e?"string":"int"===e||"float"===e?"number":"boolean"===e?"boolean":oL(e),oV=()=>({apiToken:oj({name:"api-token",required:!0,type:"string",prefixInputEnv:!0}),githubToken:oj({name:"github-token",required:!0,type:"string",prefixInputEnv:!0}),appUrl:oj({name:"app-url",required:!0,type:"string",prefixInputEnv:!0})});(async()=>{op();let e=await (0,r1.initSentry)("report-diffs-action-in-cloud-v1",1),t=e.startTransaction({name:"report-diffs-action.runMeticulousTestsActionInCloud",description:"Run Meticulous tests action (in cloud)",op:"report-diffs-action.runMeticulousTestsActionInCloud"});+(process.env.RUNNER_DEBUG??"0")&&od("trace");let{apiToken:a,githubToken:i,appUrl:s}=oV(),{payload:n}=ej.context,r=oU(ej.context.eventName,n),o=oP(i),p=I(r7).getLogger(av.METICULOUS_LOGGER_NAME);if(null==r){p.warn(`Running report-diffs-action is only supported for 'push', \ + so can not confidently determine the base of the merge commit to compare against. Using the base of the pull request instead (${t}).`),null;return r}catch(e){return i.error(`Error getting base of merge commit (${a}). Using the base of the pull request instead (${t}).`,e),null}},oC=()=>{(0,R.execSync)(`git config --global --add safe.directory "${process.cwd()}"`)},oA=e=>/^[a-f0-9]{40}$/.test(e),oU=(e,t)=>"push"===e?{type:"push",payload:t}:"pull_request"===e?{type:"pull_request",payload:t}:"workflow_dispatch"===e?{type:"workflow_dispatch",payload:t}:null;var r7=G("7SZkG");const oP=e=>{if(null==e)throw Error("github-token is required");try{return(0,ej.getOctokit)(e)}catch(e){throw I(r7).getLogger(av.METICULOUS_LOGGER_NAME).error(e),Error("Error connecting to GitHub. Did you specify a valid 'github-token'?")}},oj=({name:e,required:t,type:a,prefixInputEnv:i=!1})=>{let s=`${i?"INPUT_":""}${e.toUpperCase().replaceAll("-","_")}`,n=process.env[s];if(("string"===a||"string-array"===a)&&""===n&&!t)return null;let r=oI(n,a);if(t&&null==r||t&&oF(r)&&"string-array"!==a)throw Error(`Input ${e} is required`);if(null!=r&&typeof r!==oG(a))throw Error(`Expected ${a} for input ${e}, but got ${typeof r}`);return r},oI=(e,t)=>{if(null==e)return null;if("string"===t)return e;if("string-array"===t)return -1===e.indexOf("\n")?e.split(",").map(e=>e.trim()).filter(e=>""!==e):e.split("\n").map(e=>e.trim()).filter(e=>""!==e);if("int"===t){let t=Number.parseInt(e);return isNaN(t)?null:t}if("float"===t){let t=Number.parseFloat(e);return isNaN(t)?null:t}if("boolean"===t){if(""===e)return null;if("true"!==e&&"false"!==e)throw Error("Boolean inputs must be equal to the string 'true' or the string 'false'");return"true"===e}return oL(t)},oL=e=>{throw Error(`Only string or number inputs currently supported, but got ${e}`)},oF=e=>null==e||"string"==typeof e&&0===e.length,oG=e=>"string-array"===e?"object":"string"===e?"string":"int"===e||"float"===e?"number":"boolean"===e?"boolean":oL(e),oV=()=>(console.log(process.env),{apiToken:oj({name:"api-token",required:!0,type:"string",prefixInputEnv:!0}),githubToken:oj({name:"github-token",required:!0,type:"string",prefixInputEnv:!0}),appUrl:oj({name:"app-url",required:!0,type:"string",prefixInputEnv:!0})});(async()=>{op();let e=await (0,r1.initSentry)("report-diffs-action-in-cloud-v1",1),t=e.startTransaction({name:"report-diffs-action.runMeticulousTestsActionInCloud",description:"Run Meticulous tests action (in cloud)",op:"report-diffs-action.runMeticulousTestsActionInCloud"});+(process.env.RUNNER_DEBUG??"0")&&od("trace");let{apiToken:a,githubToken:i,appUrl:s}=oV(),{payload:n}=ej.context,r=oU(ej.context.eventName,n),o=oP(i),p=I(r7).getLogger(av.METICULOUS_LOGGER_NAME);if(null==r){p.warn(`Running report-diffs-action is only supported for 'push', \ 'pull_request' and 'workflow_dispatch' events, but was triggered \ on a '${ej.context.eventName}' event. Skipping execution.`);return}let{base:d,head:l}=await oO(r,{useDeploymentUrl:!1});ok({event:r,head:l});let{shaToCompareAgainst:c}=await oy({event:r,apiToken:a,base:d,context:ej.context,octokit:o});null!=c&&"pull_request"===r.type?p.info(`Comparing visual snapshots for the commit head of this PR, ${ol(l)}, against ${ol(c)}`):null!=c?p.info(`Comparing visual snapshots for commit ${ol(l)} against commit ${ol(c)}}`):p.info(`Generating visual snapshots for commit ${ol(l)}`);try{await ot(s),await (0,re.executeRemoteTestRun)({apiToken:a,appUrl:s,commitSha:l,environment:"github-actions",onTunnelCreated:({url:e,basicAuthUser:t,basicAuthPassword:a})=>{p.info(`Secure tunnel to ${s} created: ${e}, user: ${t}, password: ${a}`)}}),t.setStatus("ok"),t.finish(),await e.getClient()?.close(5e3),process.exit(0)}catch(i){let a=i instanceof Error?i.message:`${i}`;(0,B.setFailed)(a),t.setStatus("unknown_error"),t.finish(),await e.getClient()?.close(5e3),process.exit(1)}})().catch(e=>{let t=e instanceof Error?e.message:`${e}`;(0,B.setFailed)(t),process.exit(1)}); \ No newline at end of file diff --git a/src/actions/in-cloud/get-inputs.ts b/src/actions/in-cloud/get-inputs.ts index 5cf8b50e..06832b76 100644 --- a/src/actions/in-cloud/get-inputs.ts +++ b/src/actions/in-cloud/get-inputs.ts @@ -2,6 +2,8 @@ import { getInputFromEnv } from "../../utils/get-input-from-env"; export const getInCloudActionInputs = () => { // The names, required value, and types should match that in action.yml + console.log(process.env); + const apiToken = getInputFromEnv({ name: "api-token", required: true,