Skip to content

Commit 5c30ae4

Browse files
committed
Stop saving config in initConfig()
1 parent 4e2e64a commit 5c30ae4

File tree

4 files changed

+9
-10
lines changed

4 files changed

+9
-10
lines changed

lib/init-action.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config-utils.test.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ test("load code quality config", async (t) => {
229229
});
230230
});
231231

232-
test("loading config saves config", async (t) => {
232+
test("loading a saved config produces the same config", async (t) => {
233233
return await withTmpDir(async (tempDir) => {
234234
const logger = getRunnerLogger(true);
235235

@@ -259,6 +259,7 @@ test("loading config saves config", async (t) => {
259259
logger,
260260
}),
261261
);
262+
await configUtils.saveConfig(config1, logger);
262263

263264
// The saved config file should now exist
264265
t.true(fs.existsSync(configUtils.getPathToParsedConfigFile(tempDir)));
@@ -300,7 +301,7 @@ test("loading config with version mismatch throws", async (t) => {
300301
.stub(actionsUtil, "getActionVersion")
301302
.returns("does-not-exist");
302303

303-
await configUtils.initConfig(
304+
const config = await configUtils.initConfig(
304305
createTestInitConfigInputs({
305306
languagesInput: "javascript,python",
306307
tempDir,
@@ -309,6 +310,8 @@ test("loading config with version mismatch throws", async (t) => {
309310
logger,
310311
}),
311312
);
313+
// initConfig does not save the config, so we do it here.
314+
await configUtils.saveConfig(config, logger);
312315

313316
// Restore `getActionVersion`.
314317
getActionVersionStub.restore();

src/config-utils.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,6 @@ export async function initConfig(inputs: InitConfigInputs): Promise<Config> {
11891189
exclude: { tags: "exclude-from-incremental" },
11901190
});
11911191
}
1192-
1193-
// Save the config so we can easily access it again in the future
1194-
await saveConfig(config, logger);
11951192
return config;
11961193
}
11971194

src/init-action.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -681,10 +681,10 @@ async function run() {
681681
logUnwrittenDiagnostics();
682682
}
683683

684-
// We may have updated the config returned from `initConfig`, e.g. to revert
685-
// to `OverlayDatabaseMode.None` if we failed to download an overlay-base
686-
// database. So we save the config again, to ensure that the `analyze` step
687-
// reads the correct config.
684+
// We save the config here instead of at the end of `initConfig` because we
685+
// may have updated the config returned from `initConfig`, e.g. to revert to
686+
// `OverlayDatabaseMode.None` if we failed to download an overlay-base
687+
// database.
688688
await configUtils.saveConfig(config, logger);
689689
await sendCompletedStatusReport(
690690
startedAt,

0 commit comments

Comments
 (0)