Configure the API client to retry more often when in test mode

This commit is contained in:
Michael B. Gale
2025-09-23 10:18:39 +01:00
parent 7f44048739
commit d71accc5fa
13 changed files with 74 additions and 11 deletions

View File

@@ -36,6 +36,7 @@ test("getApiClient", async (t) => {
baseUrl: "http://api.github.localhost",
log: sinon.match.any,
userAgent: `CodeQL-Action/${actionsUtil.getActionVersion()}`,
retry: api.getRetryConfig(),
}),
);
});

View File

@@ -12,6 +12,7 @@ import {
GitHubVariant,
GitHubVersion,
isHTTPError,
isInTestMode,
parseGitHubUrl,
parseMatrixInput,
} from "./util";
@@ -38,6 +39,10 @@ export interface GitHubApiExternalRepoDetails {
apiURL: string | undefined;
}
export function getRetryConfig(): { retries: number } {
return isInTestMode() ? { retries: 10 } : { retries: 3 };
}
function createApiClientWithDetails(
apiDetails: GitHubApiCombinedDetails,
{ allowExternal = false } = {},
@@ -50,6 +55,7 @@ function createApiClientWithDetails(
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: consoleLogLevel({ level: "debug" }),
retry: getRetryConfig(),
}),
);
}