1- import { CancellationToken , commands , Uri , window } from 'vscode' ;
1+ import { CancellationToken , Uri , window } from 'vscode' ;
22import * as path from 'path' ;
33import * as yaml from 'js-yaml' ;
44import * as fs from 'fs-extra' ;
@@ -16,22 +16,17 @@ import {
1616import { Credentials } from '../authentication' ;
1717import * as cli from '../cli' ;
1818import { logger } from '../logging' ;
19- import { getActionBranch , getRemoteControllerRepo , isVariantAnalysisLiveResultsEnabled , setRemoteControllerRepo } from '../config' ;
19+ import { getActionBranch , getRemoteControllerRepo , setRemoteControllerRepo } from '../config' ;
2020import { ProgressCallback , UserCancellationException } from '../commandRunner' ;
2121import { RequestError } from '@octokit/types/dist-types' ;
2222import { RemoteQuery } from './remote-query' ;
23- import { RemoteQuerySubmissionResult } from './remote-query-submission-result' ;
2423import { QueryMetadata } from '../pure/interface-types' ;
2524import { getErrorMessage , REPO_REGEX } from '../pure/helpers-pure' ;
2625import { pluralize } from '../pure/word' ;
2726import * as ghApiClient from './gh-api/gh-api-client' ;
2827import { RemoteQueriesResponse } from './gh-api/remote-queries' ;
2928import { getRepositorySelection , isValidSelection , RepositorySelection } from './repository-selection' ;
30- import { parseVariantAnalysisQueryLanguage , VariantAnalysisSubmission } from './shared/variant-analysis' ;
3129import { Repository } from './shared/repository' ;
32- import { processVariantAnalysis } from './variant-analysis-processor' ;
33- import { VariantAnalysisManager } from './variant-analysis-manager' ;
34- import { CodeQLCliServer } from '../cli' ;
3530
3631export interface QlPack {
3732 name : string ;
@@ -262,98 +257,7 @@ export async function prepareRemoteQueryRun(
262257 } ;
263258}
264259
265- export async function runRemoteQuery (
266- cliServer : CodeQLCliServer ,
267- credentials : Credentials ,
268- uri : Uri | undefined ,
269- progress : ProgressCallback ,
270- token : CancellationToken ,
271- variantAnalysisManager : VariantAnalysisManager ,
272- ) : Promise < void | RemoteQuerySubmissionResult > {
273- if ( ! ( await cliServer . cliConstraints . supportsRemoteQueries ( ) ) ) {
274- throw new Error ( `Variant analysis is not supported by this version of CodeQL. Please upgrade to v${ cli . CliVersionConstraint . CLI_VERSION_REMOTE_QUERIES
275- } or later.`) ;
276- }
277-
278- const {
279- actionBranch,
280- base64Pack,
281- repoSelection,
282- queryFile,
283- queryMetadata,
284- controllerRepo,
285- queryStartTime,
286- language,
287- } = await prepareRemoteQueryRun ( cliServer , credentials , uri , progress , token ) ;
288-
289- if ( isVariantAnalysisLiveResultsEnabled ( ) ) {
290- const queryName = getQueryName ( queryMetadata , queryFile ) ;
291- const variantAnalysisLanguage = parseVariantAnalysisQueryLanguage ( language ) ;
292- if ( variantAnalysisLanguage === undefined ) {
293- throw new UserCancellationException ( `Found unsupported language: ${ language } ` ) ;
294- }
295-
296- const queryText = await fs . readFile ( queryFile , 'utf8' ) ;
297-
298- const variantAnalysisSubmission : VariantAnalysisSubmission = {
299- startTime : queryStartTime ,
300- actionRepoRef : actionBranch ,
301- controllerRepoId : controllerRepo . id ,
302- query : {
303- name : queryName ,
304- filePath : queryFile ,
305- pack : base64Pack ,
306- language : variantAnalysisLanguage ,
307- text : queryText ,
308- } ,
309- databases : {
310- repositories : repoSelection . repositories ,
311- repositoryLists : repoSelection . repositoryLists ,
312- repositoryOwners : repoSelection . owners
313- }
314- } ;
315-
316- const variantAnalysisResponse = await ghApiClient . submitVariantAnalysis (
317- credentials ,
318- variantAnalysisSubmission
319- ) ;
320-
321- const processedVariantAnalysis = processVariantAnalysis ( variantAnalysisSubmission , variantAnalysisResponse ) ;
322-
323- await variantAnalysisManager . onVariantAnalysisSubmitted ( processedVariantAnalysis ) ;
324-
325- void logger . log ( `Variant analysis:\n${ JSON . stringify ( processedVariantAnalysis , null , 2 ) } ` ) ;
326-
327- void showAndLogInformationMessage ( `Variant analysis ${ processedVariantAnalysis . query . name } submitted for processing` ) ;
328-
329- void commands . executeCommand ( 'codeQL.openVariantAnalysisView' , processedVariantAnalysis . id ) ;
330- void commands . executeCommand ( 'codeQL.monitorVariantAnalysis' , processedVariantAnalysis ) ;
331-
332- return { variantAnalysis : processedVariantAnalysis } ;
333- } else {
334- const apiResponse = await runRemoteQueriesApiRequest ( credentials , actionBranch , language , repoSelection , controllerRepo , base64Pack ) ;
335-
336- if ( ! apiResponse ) {
337- return ;
338- }
339-
340- const workflowRunId = apiResponse . workflow_run_id ;
341- const repositoryCount = apiResponse . repositories_queried . length ;
342- const remoteQuery = await buildRemoteQueryEntity (
343- queryFile ,
344- queryMetadata ,
345- controllerRepo ,
346- queryStartTime ,
347- workflowRunId ,
348- language ,
349- repositoryCount ) ;
350-
351- // don't return the path because it has been deleted
352- return { query : remoteQuery } ;
353- }
354- }
355-
356- async function runRemoteQueriesApiRequest (
260+ export async function runRemoteQueriesApiRequest (
357261 credentials : Credentials ,
358262 ref : string ,
359263 language : string ,
@@ -455,7 +359,7 @@ async function ensureNameAndSuite(queryPackDir: string, packRelativePath: string
455359 await fs . writeFile ( packPath , yaml . dump ( qlpack ) ) ;
456360}
457361
458- async function buildRemoteQueryEntity (
362+ export async function buildRemoteQueryEntity (
459363 queryFilePath : string ,
460364 queryMetadata : QueryMetadata | undefined ,
461365 controllerRepo : Repository ,
@@ -483,7 +387,7 @@ async function buildRemoteQueryEntity(
483387 } ;
484388}
485389
486- function getQueryName ( queryMetadata : QueryMetadata | undefined , queryFilePath : string ) : string {
390+ export function getQueryName ( queryMetadata : QueryMetadata | undefined , queryFilePath : string ) : string {
487391 // The query name is either the name as specified in the query metadata, or the file name.
488392 return queryMetadata ?. name ?? path . basename ( queryFilePath ) ;
489393}
0 commit comments