Extract query-filters test into a composite action

Removes duplicated yaml.

Also add some better typings.
This commit is contained in:
Andrew Eisenberg 2022-06-15 16:23:23 -07:00
parent 428caf0cf5
commit 59ca9b59cb
4 changed files with 86 additions and 58 deletions

View file

@ -402,9 +402,9 @@ export async function runQueries(
}
// combine the list of packs into a query suite in order to run them all simultaneously.
const querySuite = packs
.map(convertPackToQuerySuiteEntry)
.concat(queryFilters as any[]);
const querySuite = (
packs.map(convertPackToQuerySuiteEntry) as configUtils.QuerySuiteEntry[]
).concat(queryFilters);
const querySuitePath = `${databasePath}-queries-${type}.qls`;
fs.writeFileSync(querySuitePath, yaml.dump(querySuite));
@ -424,7 +424,9 @@ export async function runQueries(
}
}
export function convertPackToQuerySuiteEntry(packStr: string) {
export function convertPackToQuerySuiteEntry(
packStr: string
): configUtils.QuerySuitePackEntry {
const pack = configUtils.parsePacksSpecification(packStr);
return {
qlpack: !pack.path ? pack.name : undefined,

View file

@ -65,6 +65,22 @@ interface IncludeQueryFilter {
include: Record<string, string[] | string>;
}
export type QuerySuitePackEntry = {
version?: string;
} & (
| {
qlpack: string;
}
| {
from?: string;
query?: string;
queries?: string;
apply?: string;
}
);
export type QuerySuiteEntry = QuerySuitePackEntry | QueryFilter;
/**
* Lists of query files for each language.
* Will only contain .ql files and not other kinds of files,