Skip to content

Commit 249458a

Browse files
authored
Merge pull request #3296 from github/mbg/dependency-caching/skip-uploads-for-exact-matches
Skip uploading dependency caches if we know they exist
2 parents 70434f6 + 1ed85b4 commit 249458a

File tree

8 files changed

+329
-56
lines changed

8 files changed

+329
-56
lines changed

lib/analyze-action.js

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

lib/init-action.js

Lines changed: 19 additions & 7 deletions
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: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -200,12 +200,9 @@ test("load code quality config", async (t) => {
200200
);
201201

202202
// And the config we expect it to result in
203-
const expectedConfig: configUtils.Config = {
204-
version: actionsUtil.getActionVersion(),
203+
const expectedConfig = createTestConfig({
205204
analysisKinds: [AnalysisKind.CodeQuality],
206205
languages: [KnownLanguage.actions],
207-
buildMode: undefined,
208-
originalUserInput: {},
209206
// This gets set because we only have `AnalysisKind.CodeQuality`
210207
computedConfig: {
211208
"disable-default-queries": true,
@@ -219,14 +216,7 @@ test("load code quality config", async (t) => {
219216
debugMode: false,
220217
debugArtifactName: "",
221218
debugDatabaseName: "",
222-
trapCaches: {},
223-
trapCacheDownloadTime: 0,
224-
dependencyCachingEnabled: CachingKind.None,
225-
extraQueryExclusions: [],
226-
overlayDatabaseMode: OverlayDatabaseMode.None,
227-
useOverlayDatabaseCaching: false,
228-
repositoryProperties: {},
229-
};
219+
});
230220

231221
t.deepEqual(config, expectedConfig);
232222
});
@@ -507,9 +497,7 @@ test("load non-empty input", async (t) => {
507497
};
508498

509499
// And the config we expect it to parse to
510-
const expectedConfig: configUtils.Config = {
511-
version: actionsUtil.getActionVersion(),
512-
analysisKinds: [AnalysisKind.CodeScanning],
500+
const expectedConfig = createTestConfig({
513501
languages: [KnownLanguage.javascript],
514502
buildMode: BuildMode.None,
515503
originalUserInput: userConfig,
@@ -521,14 +509,7 @@ test("load non-empty input", async (t) => {
521509
debugMode: false,
522510
debugArtifactName: "my-artifact",
523511
debugDatabaseName: "my-db",
524-
trapCaches: {},
525-
trapCacheDownloadTime: 0,
526-
dependencyCachingEnabled: CachingKind.None,
527-
extraQueryExclusions: [],
528-
overlayDatabaseMode: OverlayDatabaseMode.None,
529-
useOverlayDatabaseCaching: false,
530-
repositoryProperties: {},
531-
};
512+
});
532513

533514
const languagesInput = "javascript";
534515
const configFilePath = createConfigFile(inputFileContents, tempDir);

src/config-utils.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,9 @@ export interface Config {
148148
/** A value indicating how dependency caching should be used. */
149149
dependencyCachingEnabled: CachingKind;
150150

151+
/** The keys of caches that we restored, if any. */
152+
dependencyCachingRestoredKeys: string[];
153+
151154
/**
152155
* Extra query exclusions to append to the config.
153156
*/
@@ -496,6 +499,7 @@ export async function initActionState(
496499
trapCaches,
497500
trapCacheDownloadTime,
498501
dependencyCachingEnabled: getCachingKind(dependencyCachingEnabled),
502+
dependencyCachingRestoredKeys: [],
499503
extraQueryExclusions: [],
500504
overlayDatabaseMode: OverlayDatabaseMode.None,
501505
useOverlayDatabaseCaching: false,

0 commit comments

Comments
 (0)