From 17d3346c1658b3a27c0a9b3e3c1cbb6b0c134e1b Mon Sep 17 00:00:00 2001 From: Alex Ivanov Date: Thu, 28 Mar 2024 19:26:07 +0000 Subject: [PATCH] Fix base test run check in cloud compute action --- out/cloud-compute.entrypoint.js | 2 +- src/actions/cloud-compute/cloud-compute.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/out/cloud-compute.entrypoint.js b/out/cloud-compute.entrypoint.js index 0bbae79c..88c3e34a 100644 --- a/out/cloud-compute.entrypoint.js +++ b/out/cloud-compute.entrypoint.js @@ -51,4 +51,4 @@ Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)},L. of GitHub's temporary merge commit.`),null;let o=(0,R.execSync)(`git cat-file -p ${a}`).toString().split("\n").filter(e=>e.startsWith("parent ")).map(e=>e.substring(7).trim());if(2!==o.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 s=o[0];if(o[1]!==e)return i.error(`The second parent (${o[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 s}catch(e){return i.error(`Error getting base of merge commit (${a}). Using the base of the pull request instead (${t}).`,e),null}},p_=()=>{(0,R.execSync)(`git config --global --add safe.directory "${process.cwd()}"`)},pV=e=>/^[a-f0-9]{40}$/.test(e),pR=(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 r8=X("7SZkG");const pT=e=>{if(null==e)throw Error("github-token is required");try{return(0,eH.getOctokit)(e)}catch(e){throw F(r8).getLogger(aI.METICULOUS_LOGGER_NAME).error(e),Error("Error connecting to GitHub. Did you specify a valid 'github-token'?")}},pE=()=>({apiToken:(0,L.getInput)("api-token",{required:!0}),githubToken:(0,L.getInput)("github-token",{required:!0}),appUrl:(0,L.getInput)("app-url",{required:!0})});(async()=>{pr();let e=await (0,s2.initSentry)("report-diffs-action-cloud-compute-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")&&pp("trace");let{apiToken:a,githubToken:i,appUrl:n}=pE(),{payload:o}=eH.context,s=pR(eH.context.eventName,o),r=pT(i),p=F(r8).getLogger(aI.METICULOUS_LOGGER_NAME);if(null==s){p.warn(`Running report-diffs-action is only supported for 'push', \ 'pull_request' and 'workflow_dispatch' events, but was triggered \ - on a '${eH.context.eventName}' event. Skipping execution.`);return}let{base:l,head:d}=await pG(s,{useDeploymentUrl:!1}),{shaToCompareAgainst:c}=await pC({event:s,apiToken:a,base:l,useCloudReplayEnvironmentVersion:!1,context:eH.context,octokit:r});null!=c&&"pull_request"===s.type?p.info(`Comparing visual snapshots for the commit head of this PR, ${pl(d)}, against ${pl(c)}`):null!=c?p.info(`Comparing visual snapshots for commit ${pl(d)} against commit ${pl(c)}}`):p.info(`Generating visual snapshots for commit ${pl(d)}`);try{await pe(n);let i=process.env.GITHUB_SHA;if(!i)throw Error("GITHUB_SHA is not set.");await (0,sa.executeRemoteTestRun)({apiToken:a,appUrl:n,commitSha:i,environment:"github-actions",onTunnelCreated:({url:e,basicAuthUser:t,basicAuthPassword:a})=>{p.info(`Secure tunnel to ${n} 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,L.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,L.setFailed)(t),process.exit(1)}); \ No newline at end of file + on a '${eH.context.eventName}' event. Skipping execution.`);return}let{base:l,head:d}=await pG(s,{useDeploymentUrl:!1}),{shaToCompareAgainst:c}=await pC({event:s,apiToken:a,base:l,useCloudReplayEnvironmentVersion:!0,context:eH.context,octokit:r});null!=c&&"pull_request"===s.type?p.info(`Comparing visual snapshots for the commit head of this PR, ${pl(d)}, against ${pl(c)}`):null!=c?p.info(`Comparing visual snapshots for commit ${pl(d)} against commit ${pl(c)}}`):p.info(`Generating visual snapshots for commit ${pl(d)}`);try{await pe(n);let i=process.env.GITHUB_SHA;if(!i)throw Error("GITHUB_SHA is not set.");await (0,sa.executeRemoteTestRun)({apiToken:a,appUrl:n,commitSha:i,environment:"github-actions",onTunnelCreated:({url:e,basicAuthUser:t,basicAuthPassword:a})=>{p.info(`Secure tunnel to ${n} 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,L.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,L.setFailed)(t),process.exit(1)}); \ No newline at end of file diff --git a/src/actions/cloud-compute/cloud-compute.ts b/src/actions/cloud-compute/cloud-compute.ts index 9055fadc..4feac586 100644 --- a/src/actions/cloud-compute/cloud-compute.ts +++ b/src/actions/cloud-compute/cloud-compute.ts @@ -56,7 +56,7 @@ export const runMeticulousTestsCloudComputeAction = async (): Promise => { event, apiToken, base, - useCloudReplayEnvironmentVersion: false, + useCloudReplayEnvironmentVersion: true, context, octokit, });