Skip to content

Commit 308d941

Browse files
committed
Only warn for missing config if init was successful
1 parent 26f5c5e commit 308d941

6 files changed

Lines changed: 30 additions & 13 deletions

File tree

‎lib/entry-points.js‎

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/codeql.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -928,12 +928,17 @@ async function getCodeQLForCmd(
928928
getGeneratedCodeScanningConfigPath(config);
929929

930930
if (!fs.existsSync(configPath)) {
931-
logger.warning(
932-
[
933-
`Expected a configuration file at '${configPath}', which does not exist.`,
934-
"Continuing with diagnostics export anyway, without a configuration file.",
935-
].join(" "),
936-
);
931+
// Warn if there is no configuration file, even though `config` claims that `init`
932+
// was successful. This shouldn't be happening.
933+
if (config.successfullyInitialised) {
934+
logger.warning(
935+
[
936+
`Expected a configuration file at '${configPath}', which does not exist.`,
937+
"Continuing with diagnostics export anyway, without a configuration file.",
938+
].join(" "),
939+
);
940+
}
941+
937942
configPath = undefined;
938943
}
939944

‎src/config-utils.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,8 @@ export async function initActionState(
465465
overlayModeSetExplicitly: false,
466466
repositoryProperties,
467467
enableFileCoverageInformation,
468+
// We don't set this to `true` until `init` is successful.
469+
successfullyInitialised: false,
468470
};
469471
}
470472

‎src/config/action-config.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ export interface Config {
130130
* Whether to enable file coverage information.
131131
*/
132132
enableFileCoverageInformation: boolean;
133+
134+
/** Whether the analysis was successfully initialised using the configuration. */
135+
successfullyInitialised: boolean;
133136
}
134137

135138
/** Properties available in `Config`. */

‎src/init-action.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,6 +775,7 @@ async function run(
775775
// may have updated the config returned from `initConfig`, e.g. to revert to
776776
// `OverlayDatabaseMode.None` if we failed to download an overlay-base
777777
// database.
778+
config.successfullyInitialised = true;
778779
await configUtils.saveConfig(config, logger);
779780

780781
core.setOutput("codeql-path", config.codeQLCmd);

‎src/testing-utils.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,7 @@ export function createTestConfig(overrides: Partial<Config>): Config {
10311031
overlayModeSetExplicitly: false,
10321032
repositoryProperties: {},
10331033
enableFileCoverageInformation: true,
1034+
successfullyInitialised: false,
10341035
} satisfies Config,
10351036
overrides,
10361037
);

0 commit comments

Comments
 (0)