Skip to content

Commit a666267

Browse files
committed
Moves calls to pack download to the init action
This ensures all steps to gather queries happens in the init action. This is where checking out queries in other repos happens as well.
1 parent a59fbe2 commit a666267

9 files changed

Lines changed: 130 additions & 28 deletions

lib/analyze.js

Lines changed: 0 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/analyze.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.js

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.test.js

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/config-utils.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/analyze.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -280,21 +280,6 @@ export async function runQueries(
280280
logger.endGroup();
281281
logger.info(analysisSummary);
282282
} else {
283-
if (hasPackWithCustomQueries) {
284-
logger.info("Performing analysis with custom CodeQL Packs.");
285-
logger.startGroup(`Downloading custom packs for ${language}`);
286-
287-
const results = await codeql.packDownload(packsWithVersion);
288-
289-
logger.info(
290-
`Downloaded packs: ${results.packs
291-
.map((r) => `${r.name}@${r.version || "latest"}`)
292-
.join(", ")}`
293-
);
294-
295-
logger.endGroup();
296-
}
297-
298283
logger.startGroup(`Running queries for ${language}`);
299284
const querySuitePaths: string[] = [];
300285
if (queries["builtin"].length > 0) {

src/config-utils.test.ts

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import test, { ExecutionContext } from "ava";
66
import * as sinon from "sinon";
77

88
import * as api from "./api-client";
9-
import { getCachedCodeQL, setCodeQL } from "./codeql";
9+
import { getCachedCodeQL, PackDownloadOutput, setCodeQL } from "./codeql";
1010
import * as configUtils from "./config-utils";
1111
import { createFeatureFlags, FeatureFlag } from "./feature-flags";
1212
import { Language } from "./languages";
@@ -78,6 +78,9 @@ test("load empty config", async (t) => {
7878
multipleDeclaredLanguages: {},
7979
};
8080
},
81+
async packDownload(): Promise<PackDownloadOutput> {
82+
return { packs: [] };
83+
},
8184
});
8285

8386
const config = await configUtils.initConfig(
@@ -139,6 +142,9 @@ test("loading config saves config", async (t) => {
139142
multipleDeclaredLanguages: {},
140143
};
141144
},
145+
async packDownload(): Promise<PackDownloadOutput> {
146+
return { packs: [] };
147+
},
142148
});
143149

144150
// Sanity check the saved config file does not already exist
@@ -311,6 +317,9 @@ test("load non-empty input", async (t) => {
311317
multipleDeclaredLanguages: {},
312318
};
313319
},
320+
async packDownload(): Promise<PackDownloadOutput> {
321+
return { packs: [] };
322+
},
314323
});
315324

316325
// Just create a generic config object with non-default values for all fields
@@ -419,6 +428,9 @@ test("Default queries are used", async (t) => {
419428
multipleDeclaredLanguages: {},
420429
};
421430
},
431+
async packDownload(): Promise<PackDownloadOutput> {
432+
return { packs: [] };
433+
},
422434
});
423435

424436
// The important point of this config is that it doesn't specify
@@ -504,6 +516,9 @@ test("Queries can be specified in config file", async (t) => {
504516
resolveQueriesArgs.push({ queries, extraSearchPath });
505517
return queriesToResolvedQueryForm(queries);
506518
},
519+
async packDownload(): Promise<PackDownloadOutput> {
520+
return { packs: [] };
521+
},
507522
});
508523

509524
const languages = "javascript";
@@ -578,6 +593,9 @@ test("Queries from config file can be overridden in workflow file", async (t) =>
578593
resolveQueriesArgs.push({ queries, extraSearchPath });
579594
return queriesToResolvedQueryForm(queries);
580595
},
596+
async packDownload(): Promise<PackDownloadOutput> {
597+
return { packs: [] };
598+
},
581599
});
582600

583601
const languages = "javascript";
@@ -650,6 +668,9 @@ test("Queries in workflow file can be used in tandem with the 'disable default q
650668
resolveQueriesArgs.push({ queries, extraSearchPath });
651669
return queriesToResolvedQueryForm(queries);
652670
},
671+
async packDownload(): Promise<PackDownloadOutput> {
672+
return { packs: [] };
673+
},
653674
});
654675

655676
const languages = "javascript";
@@ -713,6 +734,9 @@ test("Multiple queries can be specified in workflow file, no config file require
713734
resolveQueriesArgs.push({ queries, extraSearchPath });
714735
return queriesToResolvedQueryForm(queries);
715736
},
737+
async packDownload(): Promise<PackDownloadOutput> {
738+
return { packs: [] };
739+
},
716740
});
717741

718742
const languages = "javascript";
@@ -797,6 +821,9 @@ test("Queries in workflow file can be added to the set of queries without overri
797821
resolveQueriesArgs.push({ queries, extraSearchPath });
798822
return queriesToResolvedQueryForm(queries);
799823
},
824+
async packDownload(): Promise<PackDownloadOutput> {
825+
return { packs: [] };
826+
},
800827
});
801828

802829
const languages = "javascript";
@@ -876,6 +903,9 @@ test("Invalid queries in workflow file handled correctly", async (t) => {
876903
multipleDeclaredLanguages: {},
877904
};
878905
},
906+
async packDownload(): Promise<PackDownloadOutput> {
907+
return { packs: [] };
908+
},
879909
});
880910

881911
try {
@@ -922,6 +952,9 @@ test("API client used when reading remote config", async (t) => {
922952
multipleDeclaredLanguages: {},
923953
};
924954
},
955+
async packDownload(): Promise<PackDownloadOutput> {
956+
return { packs: [] };
957+
},
925958
});
926959

927960
const inputFileContents = `
@@ -1051,6 +1084,9 @@ test("No detected languages", async (t) => {
10511084
async resolveLanguages() {
10521085
return {};
10531086
},
1087+
async packDownload(): Promise<PackDownloadOutput> {
1088+
return { packs: [] };
1089+
},
10541090
});
10551091

10561092
try {
@@ -1124,6 +1160,9 @@ test("Config specifies packages", async (t) => {
11241160
multipleDeclaredLanguages: {},
11251161
};
11261162
},
1163+
async packDownload(): Promise<PackDownloadOutput> {
1164+
return { packs: [] };
1165+
},
11271166
});
11281167

11291168
const inputFileContents = `
@@ -1175,6 +1214,9 @@ test("Config specifies packages for multiple languages", async (t) => {
11751214
multipleDeclaredLanguages: {},
11761215
};
11771216
},
1217+
async packDownload(): Promise<PackDownloadOutput> {
1218+
return { packs: [] };
1219+
},
11781220
});
11791221

11801222
const inputFileContents = `
@@ -1255,6 +1297,9 @@ function doInvalidInputTest(
12551297
multipleDeclaredLanguages: {},
12561298
};
12571299
},
1300+
async packDownload(): Promise<PackDownloadOutput> {
1301+
return { packs: [] };
1302+
},
12581303
});
12591304

12601305
const languages = "javascript";
@@ -1845,6 +1890,9 @@ const mlPoweredQueriesMacro = test.macro({
18451890
multipleDeclaredLanguages: {},
18461891
};
18471892
},
1893+
async packDownload(): Promise<PackDownloadOutput> {
1894+
return { packs: [] };
1895+
},
18481896
});
18491897

18501898
const { packs } = await configUtils.initConfig(

0 commit comments

Comments
 (0)