Add environment variable for enabling Go extraction reconcilation

This will enable us to test this behavior in PR checks.
Also simplify and add some more detailed documentation.
This commit is contained in:
Henry Mercer 2022-08-30 18:05:09 +01:00
parent 8dc468564f
commit fff56ee004
3 changed files with 46 additions and 19 deletions

29
lib/analyze-action.js generated
View file

@ -119,13 +119,28 @@ async function run() {
const repositoryNwo = (0, repository_1.parseRepositoryNwo)(util.getRequiredEnvParam("GITHUB_REPOSITORY"));
const gitHubVersion = await (0, api_client_1.getGitHubVersionActionsOnly)();
const featureFlags = new feature_flags_1.GitHubFeatureFlags(gitHubVersion, apiDetails, repositoryNwo, logger);
if (await featureFlags.getValue(feature_flags_1.FeatureFlag.GolangExtractionReconciliationEnabled)) {
// Run autobuilder for Go, unless it's already been run or user built manually
if (languages_1.Language.go in config.languages &&
process.env["CODEQL_ACTION_DID_AUTOBUILD_GOLANG"] !== "true" &&
!doesGoExtractionOutputExist(config)) {
await (0, autobuild_1.runAutobuild)(languages_1.Language.go, config, logger);
}
// When Go extraction reconciliation is enabled, either via the feature flag
// or an environment variable, we will attempt to autobuild Go to preserve
// compatibility for users who have set up Go using a legacy scanning style
// CodeQL workflow, i.e. one without an autobuild step or manual build
// steps.
//
// - We detect whether an autobuild step is present by checking the
// `CODEQL_ACTION_DID_AUTOBUILD_GOLANG` environment variable, which is set
// when the autobuilder is invoked.
// - We approximate whether manual build steps are present by looking at
// whether any extraction output already exists for Go.
if (
// Only proceed if the beta Go extraction reconciliation behavior is
// enabled.
(process.env["CODEQL_ACTION_RECONCILE_GO_EXTRACTION"] === "true" ||
(await featureFlags.getValue(feature_flags_1.FeatureFlag.GolangExtractionReconciliationEnabled))) &&
languages_1.Language.go in config.languages &&
// This captures whether the autobuilder has already been invoked
process.env["CODEQL_ACTION_DID_AUTOBUILD_GOLANG"] !== "true" &&
// This captures whether a user has added manual build steps for Go
!doesGoExtractionOutputExist(config)) {
await (0, autobuild_1.runAutobuild)(languages_1.Language.go, config, logger);
}
dbCreationTimings = await (0, analyze_1.runFinalize)(outputDir, threads, memory, config, logger, featureFlags);
if (actionsUtil.getRequiredInput("skip-queries") !== "true") {

File diff suppressed because one or more lines are too long