mirror of
https://github.com/github/codeql-action.git
synced 2025-12-28 10:10:17 +08:00
Read and parse quality-queries input
This commit is contained in:
@@ -47,6 +47,7 @@ function createTestInitConfigInputs(
|
||||
{
|
||||
languagesInput: undefined,
|
||||
queriesInput: undefined,
|
||||
qualityQueriesInput: undefined,
|
||||
packsInput: undefined,
|
||||
configFile: undefined,
|
||||
dbLocation: undefined,
|
||||
@@ -806,6 +807,7 @@ const calculateAugmentationMacro = test.macro({
|
||||
_title: string,
|
||||
rawPacksInput: string | undefined,
|
||||
rawQueriesInput: string | undefined,
|
||||
rawQualityQueriesInput: string | undefined,
|
||||
languages: Language[],
|
||||
expectedAugmentationProperties: configUtils.AugmentationProperties,
|
||||
) => {
|
||||
@@ -815,6 +817,7 @@ const calculateAugmentationMacro = test.macro({
|
||||
createFeatures([]),
|
||||
rawPacksInput,
|
||||
rawQueriesInput,
|
||||
rawQualityQueriesInput,
|
||||
languages,
|
||||
mockLogger,
|
||||
);
|
||||
@@ -828,10 +831,12 @@ test(
|
||||
"All empty",
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
[Language.javascript],
|
||||
{
|
||||
queriesInputCombines: false,
|
||||
queriesInput: undefined,
|
||||
qualityQueriesInput: undefined,
|
||||
packsInputCombines: false,
|
||||
packsInput: undefined,
|
||||
defaultQueryFilters: [],
|
||||
@@ -843,10 +848,12 @@ test(
|
||||
"With queries",
|
||||
undefined,
|
||||
" a, b , c, d",
|
||||
undefined,
|
||||
[Language.javascript],
|
||||
{
|
||||
queriesInputCombines: false,
|
||||
queriesInput: [{ uses: "a" }, { uses: "b" }, { uses: "c" }, { uses: "d" }],
|
||||
qualityQueriesInput: undefined,
|
||||
packsInputCombines: false,
|
||||
packsInput: undefined,
|
||||
defaultQueryFilters: [],
|
||||
@@ -858,10 +865,34 @@ test(
|
||||
"With queries combining",
|
||||
undefined,
|
||||
" + a, b , c, d ",
|
||||
undefined,
|
||||
[Language.javascript],
|
||||
{
|
||||
queriesInputCombines: true,
|
||||
queriesInput: [{ uses: "a" }, { uses: "b" }, { uses: "c" }, { uses: "d" }],
|
||||
qualityQueriesInput: undefined,
|
||||
packsInputCombines: false,
|
||||
packsInput: undefined,
|
||||
defaultQueryFilters: [],
|
||||
} as configUtils.AugmentationProperties,
|
||||
);
|
||||
|
||||
test(
|
||||
calculateAugmentationMacro,
|
||||
"With quality queries",
|
||||
undefined,
|
||||
undefined,
|
||||
" a, b , c, d",
|
||||
[Language.javascript],
|
||||
{
|
||||
queriesInputCombines: false,
|
||||
queriesInput: undefined,
|
||||
qualityQueriesInput: [
|
||||
{ uses: "a" },
|
||||
{ uses: "b" },
|
||||
{ uses: "c" },
|
||||
{ uses: "d" },
|
||||
],
|
||||
packsInputCombines: false,
|
||||
packsInput: undefined,
|
||||
defaultQueryFilters: [],
|
||||
@@ -873,10 +904,12 @@ test(
|
||||
"With packs",
|
||||
" codeql/a , codeql/b , codeql/c , codeql/d ",
|
||||
undefined,
|
||||
undefined,
|
||||
[Language.javascript],
|
||||
{
|
||||
queriesInputCombines: false,
|
||||
queriesInput: undefined,
|
||||
qualityQueriesInput: undefined,
|
||||
packsInputCombines: false,
|
||||
packsInput: ["codeql/a", "codeql/b", "codeql/c", "codeql/d"],
|
||||
defaultQueryFilters: [],
|
||||
@@ -888,10 +921,12 @@ test(
|
||||
"With packs combining",
|
||||
" + codeql/a, codeql/b, codeql/c, codeql/d",
|
||||
undefined,
|
||||
undefined,
|
||||
[Language.javascript],
|
||||
{
|
||||
queriesInputCombines: false,
|
||||
queriesInput: undefined,
|
||||
qualityQueriesInput: undefined,
|
||||
packsInputCombines: true,
|
||||
packsInput: ["codeql/a", "codeql/b", "codeql/c", "codeql/d"],
|
||||
defaultQueryFilters: [],
|
||||
@@ -904,6 +939,7 @@ const calculateAugmentationErrorMacro = test.macro({
|
||||
_title: string,
|
||||
rawPacksInput: string | undefined,
|
||||
rawQueriesInput: string | undefined,
|
||||
rawQualityQueriesInput: string | undefined,
|
||||
languages: Language[],
|
||||
expectedError: RegExp | string,
|
||||
) => {
|
||||
@@ -914,6 +950,7 @@ const calculateAugmentationErrorMacro = test.macro({
|
||||
createFeatures([]),
|
||||
rawPacksInput,
|
||||
rawQueriesInput,
|
||||
rawQualityQueriesInput,
|
||||
languages,
|
||||
mockLogger,
|
||||
),
|
||||
@@ -928,6 +965,7 @@ test(
|
||||
"Plus (+) with nothing else (queries)",
|
||||
undefined,
|
||||
" + ",
|
||||
undefined,
|
||||
[Language.javascript],
|
||||
/The workflow property "queries" is invalid/,
|
||||
);
|
||||
@@ -937,6 +975,7 @@ test(
|
||||
"Plus (+) with nothing else (packs)",
|
||||
" + ",
|
||||
undefined,
|
||||
undefined,
|
||||
[Language.javascript],
|
||||
/The workflow property "packs" is invalid/,
|
||||
);
|
||||
@@ -946,6 +985,7 @@ test(
|
||||
"Packs input with multiple languages",
|
||||
" + a/b, c/d ",
|
||||
undefined,
|
||||
undefined,
|
||||
[Language.javascript, Language.java],
|
||||
/Cannot specify a 'packs' input in a multi-language analysis/,
|
||||
);
|
||||
@@ -955,6 +995,7 @@ test(
|
||||
"Packs input with no languages",
|
||||
" + a/b, c/d ",
|
||||
undefined,
|
||||
undefined,
|
||||
[],
|
||||
/No languages specified/,
|
||||
);
|
||||
@@ -964,6 +1005,7 @@ test(
|
||||
"Invalid packs",
|
||||
" a-pack-without-a-scope ",
|
||||
undefined,
|
||||
undefined,
|
||||
[Language.javascript],
|
||||
/"a-pack-without-a-scope" is not a valid pack/,
|
||||
);
|
||||
|
||||
@@ -170,6 +170,11 @@ export interface AugmentationProperties {
|
||||
*/
|
||||
queriesInput?: Array<{ uses: string }>;
|
||||
|
||||
/**
|
||||
* The quality queries input from the `with` block of the action declaration.
|
||||
*/
|
||||
qualityQueriesInput?: Array<{ uses: string }>;
|
||||
|
||||
/**
|
||||
* Whether or not the packs input combines with the packs in the config.
|
||||
*/
|
||||
@@ -195,6 +200,7 @@ export const defaultAugmentationProperties: AugmentationProperties = {
|
||||
packsInputCombines: false,
|
||||
packsInput: undefined,
|
||||
queriesInput: undefined,
|
||||
qualityQueriesInput: undefined,
|
||||
defaultQueryFilters: [],
|
||||
};
|
||||
export type Packs = Partial<Record<Language, string[]>>;
|
||||
@@ -405,6 +411,7 @@ export async function getRawLanguages(
|
||||
export interface InitConfigInputs {
|
||||
languagesInput: string | undefined;
|
||||
queriesInput: string | undefined;
|
||||
qualityQueriesInput: string | undefined;
|
||||
packsInput: string | undefined;
|
||||
configFile: string | undefined;
|
||||
dbLocation: string | undefined;
|
||||
@@ -440,6 +447,7 @@ type LoadConfigInputs = Omit<InitConfigInputs, "configInput"> & {
|
||||
export async function getDefaultConfig({
|
||||
languagesInput,
|
||||
queriesInput,
|
||||
qualityQueriesInput,
|
||||
packsInput,
|
||||
buildModeInput,
|
||||
dbLocation,
|
||||
@@ -474,6 +482,7 @@ export async function getDefaultConfig({
|
||||
features,
|
||||
packsInput,
|
||||
queriesInput,
|
||||
qualityQueriesInput,
|
||||
languages,
|
||||
logger,
|
||||
);
|
||||
@@ -528,6 +537,7 @@ async function downloadCacheWithTime(
|
||||
async function loadConfig({
|
||||
languagesInput,
|
||||
queriesInput,
|
||||
qualityQueriesInput,
|
||||
packsInput,
|
||||
buildModeInput,
|
||||
configFile,
|
||||
@@ -583,6 +593,7 @@ async function loadConfig({
|
||||
features,
|
||||
packsInput,
|
||||
queriesInput,
|
||||
qualityQueriesInput,
|
||||
languages,
|
||||
logger,
|
||||
);
|
||||
@@ -639,6 +650,7 @@ export async function calculateAugmentation(
|
||||
features: FeatureEnablement,
|
||||
rawPacksInput: string | undefined,
|
||||
rawQueriesInput: string | undefined,
|
||||
rawQualityQueriesInput: string | undefined,
|
||||
languages: Language[],
|
||||
logger: Logger,
|
||||
): Promise<AugmentationProperties> {
|
||||
@@ -654,6 +666,11 @@ export async function calculateAugmentation(
|
||||
queriesInputCombines,
|
||||
);
|
||||
|
||||
const qualityQueriesInput = parseQueriesFromInput(
|
||||
rawQualityQueriesInput,
|
||||
false,
|
||||
);
|
||||
|
||||
const defaultQueryFilters: QueryFilter[] = [];
|
||||
if (await shouldPerformDiffInformedAnalysis(codeql, features, logger)) {
|
||||
defaultQueryFilters.push({ exclude: { tags: "exclude-from-incremental" } });
|
||||
@@ -664,6 +681,7 @@ export async function calculateAugmentation(
|
||||
packsInput: packsInput?.[languages[0]],
|
||||
queriesInput,
|
||||
queriesInputCombines,
|
||||
qualityQueriesInput,
|
||||
defaultQueryFilters,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -342,6 +342,7 @@ async function run() {
|
||||
config = await initConfig({
|
||||
languagesInput: getOptionalInput("languages"),
|
||||
queriesInput: getOptionalInput("queries"),
|
||||
qualityQueriesInput: getOptionalInput("quality-queries"),
|
||||
packsInput: getOptionalInput("packs"),
|
||||
buildModeInput: getOptionalInput("build-mode"),
|
||||
configFile,
|
||||
|
||||
Reference in New Issue
Block a user