Skip to content

Commit 31042e9

Browse files
committed
Rename function calls to make destructive operation clearer
1 parent 5da2098 commit 31042e9

File tree

5 files changed

+34
-20
lines changed

5 files changed

+34
-20
lines changed

lib/analyze-action.js

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

src/analyze-action.ts

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
isCodeQualityEnabled,
2626
isCodeScanningEnabled,
2727
} from "./config-utils";
28-
import { uploadDatabases } from "./database-upload";
28+
import { cleanupAndUploadDatabases } from "./database-upload";
2929
import {
3030
DependencyCacheUploadStatusReport,
3131
uploadDependencyCaches,
@@ -35,7 +35,7 @@ import { EnvVar } from "./environment";
3535
import { Feature, Features } from "./feature-flags";
3636
import { KnownLanguage } from "./languages";
3737
import { getActionsLogger, Logger } from "./logging";
38-
import { uploadOverlayBaseDatabaseToCache } from "./overlay-database-utils";
38+
import { cleanupAndUploadOverlayBaseDatabaseToCache } from "./overlay-database-utils";
3939
import { getRepositoryNwo } from "./repository";
4040
import * as statusReport from "./status-report";
4141
import {
@@ -417,12 +417,20 @@ async function run() {
417417
}
418418

419419
// Possibly upload the overlay-base database to actions cache.
420-
// If databases are to be uploaded, they will first be cleaned up at the overlay level.
421-
await uploadOverlayBaseDatabaseToCache(codeql, config, logger);
420+
// Note: Take care with the ordering of this call since databases may be cleaned up
421+
// at the `overlay` level.
422+
await cleanupAndUploadOverlayBaseDatabaseToCache(codeql, config, logger);
422423

423424
// Possibly upload the database bundles for remote queries.
424-
// If databases are to be uploaded, they will first be cleaned up at the clear level.
425-
await uploadDatabases(repositoryNwo, codeql, config, apiDetails, logger);
425+
// Note: Take care with the ordering of this call since databases may be cleaned up
426+
// at the `overlay` or `clear` level.
427+
await cleanupAndUploadDatabases(
428+
repositoryNwo,
429+
codeql,
430+
config,
431+
apiDetails,
432+
logger,
433+
);
426434

427435
// Possibly upload the TRAP caches for later re-use
428436
const trapCacheUploadStartTime = performance.now();

src/database-upload.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { GitHubApiDetails } from "./api-client";
1010
import * as apiClient from "./api-client";
1111
import { createStubCodeQL } from "./codeql";
1212
import { Config } from "./config-utils";
13-
import { uploadDatabases } from "./database-upload";
13+
import { cleanupAndUploadDatabases } from "./database-upload";
1414
import * as gitUtils from "./git-utils";
1515
import { KnownLanguage } from "./languages";
1616
import { RepositoryNwo } from "./repository";
@@ -91,7 +91,7 @@ test("Abort database upload if 'upload-database' input set to false", async (t)
9191
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(true);
9292

9393
const loggedMessages = [];
94-
await uploadDatabases(
94+
await cleanupAndUploadDatabases(
9595
testRepoName,
9696
getCodeQL(),
9797
getTestConfig(tmpDir),
@@ -121,7 +121,7 @@ test("Abort database upload if 'analysis-kinds: code-scanning' is not enabled",
121121
await mockHttpRequests(201);
122122

123123
const loggedMessages = [];
124-
await uploadDatabases(
124+
await cleanupAndUploadDatabases(
125125
testRepoName,
126126
getCodeQL(),
127127
{
@@ -155,7 +155,7 @@ test("Abort database upload if running against GHES", async (t) => {
155155
config.gitHubVersion = { type: GitHubVariant.GHES, version: "3.0" };
156156

157157
const loggedMessages = [];
158-
await uploadDatabases(
158+
await cleanupAndUploadDatabases(
159159
testRepoName,
160160
getCodeQL(),
161161
config,
@@ -183,7 +183,7 @@ test("Abort database upload if not analyzing default branch", async (t) => {
183183
sinon.stub(gitUtils, "isAnalyzingDefaultBranch").resolves(false);
184184

185185
const loggedMessages = [];
186-
await uploadDatabases(
186+
await cleanupAndUploadDatabases(
187187
testRepoName,
188188
getCodeQL(),
189189
getTestConfig(tmpDir),
@@ -212,7 +212,7 @@ test("Don't crash if uploading a database fails", async (t) => {
212212
await mockHttpRequests(500);
213213

214214
const loggedMessages = [] as LoggedMessage[];
215-
await uploadDatabases(
215+
await cleanupAndUploadDatabases(
216216
testRepoName,
217217
getCodeQL(),
218218
getTestConfig(tmpDir),
@@ -243,7 +243,7 @@ test("Successfully uploading a database to github.com", async (t) => {
243243
await mockHttpRequests(201);
244244

245245
const loggedMessages = [] as LoggedMessage[];
246-
await uploadDatabases(
246+
await cleanupAndUploadDatabases(
247247
testRepoName,
248248
getCodeQL(),
249249
getTestConfig(tmpDir),
@@ -272,7 +272,7 @@ test("Successfully uploading a database to GHEC-DR", async (t) => {
272272
const databaseUploadSpy = await mockHttpRequests(201);
273273

274274
const loggedMessages = [] as LoggedMessage[];
275-
await uploadDatabases(
275+
await cleanupAndUploadDatabases(
276276
testRepoName,
277277
getCodeQL(),
278278
getTestConfig(tmpDir),

src/database-upload.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { RepositoryNwo } from "./repository";
1111
import * as util from "./util";
1212
import { bundleDb, parseGitHubUrl } from "./util";
1313

14-
export async function uploadDatabases(
14+
export async function cleanupAndUploadDatabases(
1515
repositoryNwo: RepositoryNwo,
1616
codeql: CodeQL,
1717
config: Config,

src/overlay-database-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ export function checkOverlayBaseDatabase(
204204
* @returns A promise that resolves to true if the upload was performed and
205205
* successfully completed, or false otherwise
206206
*/
207-
export async function uploadOverlayBaseDatabaseToCache(
207+
export async function cleanupAndUploadOverlayBaseDatabaseToCache(
208208
codeql: CodeQL,
209209
config: Config,
210210
logger: Logger,

0 commit comments

Comments
 (0)