Merge pull request #3109 from github/cklin/init-save-updated-config

init-action: save updated config
This commit is contained in:
Chuan-kai Lin
2025-09-11 14:18:59 -07:00
committed by GitHub
4 changed files with 13 additions and 7 deletions
+1 -1
View File
@@ -87687,7 +87687,6 @@ async function initConfig(inputs) {
exclude: { tags: "exclude-from-incremental" }
});
}
await saveConfig(config, logger);
return config;
}
function parseRegistries(registriesInput) {
@@ -90701,6 +90700,7 @@ exec ${goBinaryPath} "$@"`
} finally {
logUnwrittenDiagnostics();
}
await saveConfig(config, logger);
await sendCompletedStatusReport(
startedAt,
config,
+5 -2
View File
@@ -229,7 +229,7 @@ test("load code quality config", async (t) => {
});
});
test("loading config saves config", async (t) => {
test("loading a saved config produces the same config", async (t) => {
return await withTmpDir(async (tempDir) => {
const logger = getRunnerLogger(true);
@@ -259,6 +259,7 @@ test("loading config saves config", async (t) => {
logger,
}),
);
await configUtils.saveConfig(config1, logger);
// The saved config file should now exist
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tempDir)));
@@ -300,7 +301,7 @@ test("loading config with version mismatch throws", async (t) => {
.stub(actionsUtil, "getActionVersion")
.returns("does-not-exist");
await configUtils.initConfig(
const config = await configUtils.initConfig(
createTestInitConfigInputs({
languagesInput: "javascript,python",
tempDir,
@@ -309,6 +310,8 @@ test("loading config with version mismatch throws", async (t) => {
logger,
}),
);
// initConfig does not save the config, so we do it here.
await configUtils.saveConfig(config, logger);
// Restore `getActionVersion`.
getActionVersionStub.restore();
+1 -4
View File
@@ -1189,9 +1189,6 @@ export async function initConfig(inputs: InitConfigInputs): Promise<Config> {
exclude: { tags: "exclude-from-incremental" },
});
}
// Save the config so we can easily access it again in the future
await saveConfig(config, logger);
return config;
}
@@ -1289,7 +1286,7 @@ export function getPathToParsedConfigFile(tempDir: string): string {
/**
* Store the given config to the path returned from getPathToParsedConfigFile.
*/
async function saveConfig(config: Config, logger: Logger) {
export async function saveConfig(config: Config, logger: Logger) {
const configString = JSON.stringify(config);
const configFile = getPathToParsedConfigFile(config.tempDir);
fs.mkdirSync(path.dirname(configFile), { recursive: true });
+6
View File
@@ -680,6 +680,12 @@ async function run() {
} finally {
logUnwrittenDiagnostics();
}
// We save the config here instead of at the end of `initConfig` because we
// may have updated the config returned from `initConfig`, e.g. to revert to
// `OverlayDatabaseMode.None` if we failed to download an overlay-base
// database.
await configUtils.saveConfig(config, logger);
await sendCompletedStatusReport(
startedAt,
config,