mirror of
https://github.com/github/codeql-action.git
synced 2026-10-31 09:59:43 +00:00
169 lines
5.1 KiB
TypeScript
169 lines
5.1 KiB
TypeScript
import type { AnalysisKind } from "../analyses";
|
|
import type { CachingKind } from "../caching-utils";
|
|
import type { RepositoryProperties } from "../feature-flags/properties";
|
|
import type { Language } from "../languages";
|
|
import type { OverlayDatabaseMode } from "../overlay/overlay-database-mode";
|
|
import type { BuildMode, GitHubVersion } from "../util";
|
|
|
|
import type { ExcludeQueryFilter, UserConfig } from "./db-config";
|
|
|
|
/**
|
|
* Format of the CodeQL Action configuration state that is persisted
|
|
* between steps of the CodeQL Action in a CodeQL workflow.
|
|
*/
|
|
export interface Config {
|
|
/**
|
|
* The version of the CodeQL Action that the configuration is for.
|
|
*/
|
|
version: string;
|
|
/**
|
|
* The path at which the repository being analysed is checked out at, if available.
|
|
* Persisted in the CodeQL Action configuration state, so that we can consult it in later workflow steps.
|
|
*/
|
|
repositoryRoot: string | undefined;
|
|
/**
|
|
* Set of analysis kinds that are enabled.
|
|
*/
|
|
analysisKinds: AnalysisKind[];
|
|
/**
|
|
* Set of languages to run analysis for.
|
|
*/
|
|
languages: Language[];
|
|
/**
|
|
* Build mode, if set. Currently only a single build mode is supported per job.
|
|
*/
|
|
buildMode: BuildMode | undefined;
|
|
/**
|
|
* A unaltered copy of the original user input.
|
|
* Mainly intended to be used for status reporting.
|
|
* If any field is useful for the actual processing
|
|
* of the action then consider pulling it out to a
|
|
* top-level field above.
|
|
*/
|
|
originalUserInput: UserConfig;
|
|
/**
|
|
* Directory to use for temporary files that should be
|
|
* deleted at the end of the job.
|
|
*/
|
|
tempDir: string;
|
|
/**
|
|
* Path of the CodeQL executable.
|
|
*/
|
|
codeQLCmd: string;
|
|
/**
|
|
* Version of GitHub we are talking to.
|
|
*/
|
|
gitHubVersion: GitHubVersion;
|
|
/**
|
|
* The location where CodeQL databases should be stored.
|
|
*/
|
|
dbLocation: string;
|
|
/**
|
|
* Specifies whether we are debugging mode and should try to produce extra
|
|
* output for debugging purposes when possible.
|
|
*/
|
|
debugMode: boolean;
|
|
/**
|
|
* Specifies the name of the debugging artifact if we are in debug mode.
|
|
*/
|
|
debugArtifactName: string;
|
|
/**
|
|
* Specifies the name of the database in the debugging artifact.
|
|
*/
|
|
debugDatabaseName: string;
|
|
/**
|
|
* The configuration we computed by combining `originalUserInput` with `augmentationProperties`,
|
|
* as well as adjustments made to it based on unsupported or required options.
|
|
*/
|
|
computedConfig: UserConfig;
|
|
|
|
/**
|
|
* Partial map from languages to locations of TRAP caches for that language.
|
|
* If a key is omitted, then TRAP caching should not be used for that language.
|
|
*/
|
|
trapCaches: { [language: Language]: string };
|
|
|
|
/**
|
|
* Time taken to download TRAP caches. Used for status reporting.
|
|
*/
|
|
trapCacheDownloadTime: number;
|
|
|
|
/** A value indicating how dependency caching should be used. */
|
|
dependencyCachingEnabled: CachingKind;
|
|
|
|
/** The keys of caches that we restored, if any. */
|
|
dependencyCachingRestoredKeys: string[];
|
|
|
|
/**
|
|
* Extra query exclusions to append to the config.
|
|
*/
|
|
extraQueryExclusions: ExcludeQueryFilter[];
|
|
|
|
/**
|
|
* The overlay database mode to use.
|
|
*/
|
|
overlayDatabaseMode: OverlayDatabaseMode;
|
|
|
|
/**
|
|
* Whether to use caching for overlay databases. If it is true, the action
|
|
* will upload the created overlay-base database to the actions cache, and
|
|
* download an overlay-base database from the actions cache before it creates
|
|
* a new overlay database. If it is false, the action assumes that the
|
|
* workflow will be responsible for managing database storage and retrieval.
|
|
*
|
|
* This property has no effect unless `overlayDatabaseMode` is `Overlay` or
|
|
* `OverlayBase`.
|
|
*/
|
|
useOverlayDatabaseCaching: boolean;
|
|
|
|
/**
|
|
* Whether the overlay database mode was set explicitly.
|
|
*/
|
|
overlayModeSetExplicitly: boolean;
|
|
|
|
/**
|
|
* A partial mapping from repository properties that affect us to their values.
|
|
*/
|
|
repositoryProperties: RepositoryProperties;
|
|
|
|
/**
|
|
* Whether to enable file coverage information.
|
|
*/
|
|
enableFileCoverageInformation: boolean;
|
|
}
|
|
|
|
/** Properties available in `Config`. */
|
|
export type ActionConfigProperties = keyof Config;
|
|
|
|
/**
|
|
* The CodeQL Action configuration state that is persisted
|
|
* between steps of the CodeQL Action in a CodeQL workflow.
|
|
*
|
|
* By default, this is equivalent to `Config`. By explicitly
|
|
* providing required property names for `T` this can be restricted
|
|
* to requiring only those. For example, in `ActionConfig<"codeQLCmd">`
|
|
* all properties except `codeqlCmd` are optional.
|
|
*/
|
|
export type ActionConfig<
|
|
T extends ActionConfigProperties = ActionConfigProperties,
|
|
> = Partial<Config> & Pick<Config, T>;
|
|
|
|
/** Helper function to check whether `config` has `key` to narrow the type of `config`. */
|
|
export function hasConfigKey<Key extends ActionConfigProperties>(
|
|
config: Partial<Config>,
|
|
key: Key,
|
|
): config is ActionConfig<Key> {
|
|
return config[key] !== undefined;
|
|
}
|
|
|
|
/** A minimal configuration that we can make available even when `init` aborts. */
|
|
export type AbortedInitConfig = ActionConfig<
|
|
| "version"
|
|
| "tempDir"
|
|
| "gitHubVersion"
|
|
| "debugMode"
|
|
| "languages"
|
|
| "analysisKinds"
|
|
| "codeQLCmd"
|
|
>;
|