mirror of
https://github.com/github/codeql-action.git
synced 2026-05-02 11:50:08 +00:00
Load repository properties and store them in the Config
This commit is contained in:
Generated
+53
-1
@@ -87493,6 +87493,7 @@ async function initActionState({
|
||||
sourceRoot,
|
||||
githubVersion,
|
||||
features,
|
||||
repositoryProperties,
|
||||
logger
|
||||
}, userConfig) {
|
||||
const analysisKinds = await parseAnalysisKinds(analysisKindsInput);
|
||||
@@ -87547,7 +87548,8 @@ async function initActionState({
|
||||
dependencyCachingEnabled: getCachingKind(dependencyCachingEnabled),
|
||||
extraQueryExclusions: [],
|
||||
overlayDatabaseMode: "none" /* None */,
|
||||
useOverlayDatabaseCaching: false
|
||||
useOverlayDatabaseCaching: false,
|
||||
repositoryProperties
|
||||
};
|
||||
}
|
||||
async function downloadCacheWithTime(trapCachingEnabled, codeQL, languages, logger) {
|
||||
@@ -88109,6 +88111,51 @@ function flushDiagnostics(config) {
|
||||
unwrittenDiagnostics = [];
|
||||
}
|
||||
|
||||
// src/feature-flags/properties.ts
|
||||
var RepositoryPropertyName = /* @__PURE__ */ ((RepositoryPropertyName2) => {
|
||||
return RepositoryPropertyName2;
|
||||
})(RepositoryPropertyName || {});
|
||||
async function loadPropertiesFromApi(logger, repositoryNwo) {
|
||||
try {
|
||||
const response = await getApiClient().request(
|
||||
"GET /repos/:owner/:repo/properties/values",
|
||||
{
|
||||
owner: repositoryNwo.owner,
|
||||
repo: repositoryNwo.repo
|
||||
}
|
||||
);
|
||||
const remoteProperties = response.data;
|
||||
if (!Array.isArray(remoteProperties)) {
|
||||
throw new Error(
|
||||
`Expected repository properties API to return an array, but got: ${JSON.stringify(response.data)}`
|
||||
);
|
||||
}
|
||||
const knownProperties = new Set(Object.keys(RepositoryPropertyName));
|
||||
const properties = {};
|
||||
for (const property of remoteProperties) {
|
||||
if (property.property_name === void 0) {
|
||||
throw new Error(
|
||||
`Expected property object to have a 'property_name', but got: ${JSON.stringify(property)}`
|
||||
);
|
||||
}
|
||||
if (knownProperties.has(property.property_name)) {
|
||||
properties[property.property_name] = property.value;
|
||||
}
|
||||
}
|
||||
logger.debug("Loaded the following values for the repository properties:");
|
||||
for (const [property, value] of Object.entries(properties).sort(
|
||||
([nameA], [nameB]) => nameA.localeCompare(nameB)
|
||||
)) {
|
||||
logger.debug(` ${property}: ${value}`);
|
||||
}
|
||||
return properties;
|
||||
} catch (e) {
|
||||
throw new Error(
|
||||
`Encountered an error while trying to determine repository properties: ${e}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// src/init.ts
|
||||
var fs15 = __toESM(require("fs"));
|
||||
var path17 = __toESM(require("path"));
|
||||
@@ -90384,6 +90431,10 @@ async function run() {
|
||||
getTemporaryDirectory(),
|
||||
logger
|
||||
);
|
||||
const repositoryProperties = await loadPropertiesFromApi(
|
||||
logger,
|
||||
repositoryNwo
|
||||
);
|
||||
const jobRunUuid = v4_default();
|
||||
logger.info(`Job run UUID is ${jobRunUuid}.`);
|
||||
core13.exportVariable("JOB_RUN_UUID" /* JOB_RUN_UUID */, jobRunUuid);
|
||||
@@ -90483,6 +90534,7 @@ async function run() {
|
||||
githubVersion: gitHubVersion,
|
||||
apiDetails,
|
||||
features,
|
||||
repositoryProperties,
|
||||
logger
|
||||
});
|
||||
await checkInstallPython311(config.languages, codeql);
|
||||
|
||||
@@ -82,11 +82,11 @@ function createTestInitConfigInputs(
|
||||
externalRepoAuth: "token",
|
||||
url: "https://github.example.com",
|
||||
apiURL: undefined,
|
||||
registriesAuthTokens: undefined,
|
||||
},
|
||||
features: createFeatures([]),
|
||||
repositoryProperties: {},
|
||||
logger: getRunnerLogger(true),
|
||||
},
|
||||
} satisfies configUtils.InitConfigInputs,
|
||||
overrides,
|
||||
);
|
||||
}
|
||||
@@ -223,6 +223,7 @@ test("load code quality config", async (t) => {
|
||||
extraQueryExclusions: [],
|
||||
overlayDatabaseMode: OverlayDatabaseMode.None,
|
||||
useOverlayDatabaseCaching: false,
|
||||
repositoryProperties: {},
|
||||
};
|
||||
|
||||
t.deepEqual(config, expectedConfig);
|
||||
@@ -461,6 +462,7 @@ test("load non-empty input", async (t) => {
|
||||
extraQueryExclusions: [],
|
||||
overlayDatabaseMode: OverlayDatabaseMode.None,
|
||||
useOverlayDatabaseCaching: false,
|
||||
repositoryProperties: {},
|
||||
};
|
||||
|
||||
const languagesInput = "javascript";
|
||||
|
||||
@@ -25,6 +25,7 @@ import {
|
||||
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
|
||||
import * as errorMessages from "./error-messages";
|
||||
import { Feature, FeatureEnablement } from "./feature-flags";
|
||||
import { RepositoryProperties } from "./feature-flags/properties";
|
||||
import { getGitRoot, isAnalyzingDefaultBranch } from "./git-utils";
|
||||
import { KnownLanguage, Language } from "./languages";
|
||||
import { Logger } from "./logging";
|
||||
@@ -167,6 +168,11 @@ export interface Config {
|
||||
* `OverlayBase`.
|
||||
*/
|
||||
useOverlayDatabaseCaching: boolean;
|
||||
|
||||
/**
|
||||
* A partial mapping from repository properties that affect us to their values.
|
||||
*/
|
||||
repositoryProperties: RepositoryProperties;
|
||||
}
|
||||
|
||||
export async function getSupportedLanguageMap(
|
||||
@@ -389,6 +395,7 @@ export interface InitConfigInputs {
|
||||
githubVersion: GitHubVersion;
|
||||
apiDetails: api.GitHubApiCombinedDetails;
|
||||
features: FeatureEnablement;
|
||||
repositoryProperties: RepositoryProperties;
|
||||
logger: Logger;
|
||||
}
|
||||
|
||||
@@ -416,6 +423,7 @@ export async function initActionState(
|
||||
sourceRoot,
|
||||
githubVersion,
|
||||
features,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
}: InitConfigInputs,
|
||||
userConfig: UserConfig,
|
||||
@@ -488,6 +496,7 @@ export async function initActionState(
|
||||
extraQueryExclusions: [],
|
||||
overlayDatabaseMode: OverlayDatabaseMode.None,
|
||||
useOverlayDatabaseCaching: false,
|
||||
repositoryProperties,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ import {
|
||||
} from "./diagnostics";
|
||||
import { EnvVar } from "./environment";
|
||||
import { Feature, Features } from "./feature-flags";
|
||||
import { loadPropertiesFromApi } from "./feature-flags/properties";
|
||||
import {
|
||||
checkInstallPython311,
|
||||
checkPacksForOverlayCompatibility,
|
||||
@@ -196,6 +197,12 @@ async function run() {
|
||||
logger,
|
||||
);
|
||||
|
||||
// Fetch the values of known repository properties that affect us.
|
||||
const repositoryProperties = await loadPropertiesFromApi(
|
||||
logger,
|
||||
repositoryNwo,
|
||||
);
|
||||
|
||||
const jobRunUuid = uuidV4();
|
||||
logger.info(`Job run UUID is ${jobRunUuid}.`);
|
||||
core.exportVariable(EnvVar.JOB_RUN_UUID, jobRunUuid);
|
||||
@@ -317,6 +324,7 @@ async function run() {
|
||||
githubVersion: gitHubVersion,
|
||||
apiDetails,
|
||||
features,
|
||||
repositoryProperties,
|
||||
logger,
|
||||
});
|
||||
|
||||
|
||||
@@ -378,6 +378,7 @@ export function createTestConfig(overrides: Partial<Config>): Config {
|
||||
extraQueryExclusions: [],
|
||||
overlayDatabaseMode: OverlayDatabaseMode.None,
|
||||
useOverlayDatabaseCaching: false,
|
||||
repositoryProperties: {},
|
||||
} satisfies Config,
|
||||
overrides,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user