Compare commits

...

2 Commits

Author SHA1 Message Date
Michael B. Gale
456086d251 Adjust retry configuration and add comment 2025-09-23 12:59:21 +01:00
Michael B. Gale
d71accc5fa Configure the API client to retry more often when in test mode 2025-09-23 10:18:39 +01:00
13 changed files with 84 additions and 11 deletions

View File

@@ -117076,6 +117076,9 @@ function getCachedCodeQlVersion() {
async function codeQlVersionAtLeast(codeql, requiredVersion) {
return semver.gte((await codeql.getVersion()).version, requiredVersion);
}
function isInTestMode() {
return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true";
}
function wrapError(error2) {
return error2 instanceof Error ? error2 : new Error(String(error2));
}
@@ -117195,6 +117198,9 @@ var githubUtils = __toESM(require_utils4());
var retry = __toESM(require_dist_node15());
var import_console_log_level = __toESM(require_console_log_level());
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -117202,7 +117208,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

6
lib/analyze-action.js generated
View File

@@ -90177,6 +90177,9 @@ function parseRepositoryNwo(input) {
// src/api-client.ts
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -90184,7 +90187,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

View File

@@ -77902,6 +77902,9 @@ function parseRepositoryNwo(input) {
// src/api-client.ts
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -77909,7 +77912,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

View File

@@ -128396,6 +128396,9 @@ function parseRepositoryNwo(input) {
// src/api-client.ts
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -128403,7 +128406,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

6
lib/init-action.js generated
View File

@@ -86029,6 +86029,9 @@ function parseRepositoryNwo(input) {
// src/api-client.ts
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -86036,7 +86039,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

View File

@@ -77910,6 +77910,9 @@ function parseRepositoryNwo(input) {
// src/api-client.ts
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -77917,7 +77920,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

View File

@@ -117042,6 +117042,9 @@ var ConfigurationError = class extends Error {
super(message);
}
};
function isInTestMode() {
return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true";
}
function getErrorMessage(error2) {
return error2 instanceof Error ? error2.message : String(error2);
}
@@ -117078,6 +117081,9 @@ var githubUtils = __toESM(require_utils4());
var retry = __toESM(require_dist_node15());
var import_console_log_level = __toESM(require_console_log_level());
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -117085,7 +117091,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

View File

@@ -49321,6 +49321,9 @@ async function delay(milliseconds, opts) {
}
});
}
function isInTestMode() {
return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true";
}
function getErrorMessage(error2) {
return error2 instanceof Error ? error2.message : String(error2);
}
@@ -49370,6 +49373,9 @@ var core6 = __toESM(require_core());
var githubUtils = __toESM(require_utils4());
var retry = __toESM(require_dist_node15());
var import_console_log_level = __toESM(require_console_log_level());
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -49377,7 +49383,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

6
lib/upload-lib.js generated
View File

@@ -88523,6 +88523,9 @@ function parseRepositoryNwo(input) {
// src/api-client.ts
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -88530,7 +88533,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

View File

@@ -117042,6 +117042,9 @@ var ConfigurationError = class extends Error {
super(message);
}
};
function isInTestMode() {
return process.env["CODEQL_ACTION_TEST_MODE" /* TEST_MODE */] === "true";
}
function getErrorMessage(error2) {
return error2 instanceof Error ? error2.message : String(error2);
}
@@ -117082,6 +117085,9 @@ var githubUtils = __toESM(require_utils4());
var retry = __toESM(require_dist_node15());
var import_console_log_level = __toESM(require_console_log_level());
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -117089,7 +117095,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

View File

@@ -88775,6 +88775,9 @@ function parseRepositoryNwo(input) {
// src/api-client.ts
var GITHUB_ENTERPRISE_VERSION_HEADER = "x-github-enterprise-version";
function getRetryConfig() {
return isInTestMode() ? { retries: 10, retryAfterBaseValue: 1e4 } : { retries: 3, retryAfterBaseValue: 1e3 };
}
function createApiClientWithDetails(apiDetails, { allowExternal = false } = {}) {
const auth = allowExternal && apiDetails.externalRepoAuth || apiDetails.auth;
const retryingOctokit = githubUtils.GitHub.plugin(retry.retry);
@@ -88782,7 +88785,8 @@ function createApiClientWithDetails(apiDetails, { allowExternal = false } = {})
githubUtils.getOctokitOptions(auth, {
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: (0, import_console_log_level.default)({ level: "debug" })
log: (0, import_console_log_level.default)({ level: "debug" }),
retry: getRetryConfig()
})
);
}

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,20 @@ export interface GitHubApiExternalRepoDetails {
apiURL: string | undefined;
}
export function getRetryConfig(): {
retries: number;
retryAfterBaseValue?: number;
} {
// If we are in test mode, increase the allowed number of retries to 10
// and the base backoff from 1s to 10s. `plugin-retry` will wait
// `(failedAttempts ^ 2) * retryAfterBaseValue`-long (in ms) after
// each failed attempt.
// If we are not in test mode, we use the default configuration.
return isInTestMode()
? { retries: 10, retryAfterBaseValue: 10_000 }
: { retries: 3, retryAfterBaseValue: 1_000 };
}
function createApiClientWithDetails(
apiDetails: GitHubApiCombinedDetails,
{ allowExternal = false } = {},
@@ -50,6 +65,7 @@ function createApiClientWithDetails(
baseUrl: apiDetails.apiURL,
userAgent: `CodeQL-Action/${getActionVersion()}`,
log: consoleLogLevel({ level: "debug" }),
retry: getRetryConfig(),
}),
);
}