@@ -331,7 +331,7 @@ export async function runRemoteQuery(
331331 return ;
332332 }
333333
334- const remoteQuery = buildRemoteQueryEntity ( repositories , queryFile , owner , repo , queryStartTime , workflowRunId ) ;
334+ const remoteQuery = await buildRemoteQueryEntity ( repositories , queryFile , owner , repo , queryStartTime , workflowRunId ) ;
335335
336336 // don't return the path because it has been deleted
337337 return { query : remoteQuery } ;
@@ -451,14 +451,14 @@ async function ensureNameAndSuite(queryPackDir: string, packRelativePath: string
451451 await fs . writeFile ( packPath , yaml . safeDump ( qlpack ) ) ;
452452}
453453
454- function buildRemoteQueryEntity (
454+ async function buildRemoteQueryEntity (
455455 repositories : string [ ] ,
456456 queryFilePath : string ,
457457 controllerRepoOwner : string ,
458458 controllerRepoName : string ,
459459 queryStartTime : Date ,
460460 workflowRunId : number
461- ) : RemoteQuery {
461+ ) : Promise < RemoteQuery > {
462462 // For now, just use the file name as the query name.
463463 const queryName = path . basename ( queryFilePath ) ;
464464
@@ -467,8 +467,21 @@ function buildRemoteQueryEntity(
467467 return { owner : owner , name : repo } ;
468468 } ) ;
469469
470- // TODO: Get query text from query file and save it in a temporary .ql file.
471- const queryTextTmpFilePath = '' ;
470+ // Get the query text from query file and save it in a temporary .ql file.
471+ const queryTextTmpFilePath = path . join ( tmpDir . name , `tmp-${ queryName } ` ) ;
472+ const queryText = await fs . readFile ( queryFilePath , 'utf8' ) ;
473+ await fs . writeFile (
474+ queryTextTmpFilePath , `\
475+ ////////////////////////////////////////////////////////////////////////////////////
476+ // This is the text of the entire query file when it was executed for this query //
477+ // run. The text or dependent libraries may have changed since then. //
478+ // //
479+ // To make changes to the query and the dependent libraries, save this file in a //
480+ // suitable, permanent location. //
481+ ////////////////////////////////////////////////////////////////////////////////////
482+
483+ ${ queryText } `
484+ ) ;
472485
473486 return {
474487 queryName,
0 commit comments