mirror of
https://github.com/github/codeql-action.git
synced 2026-04-02 01:32:17 +00:00
ensure deprecation warning is only shown once per job
This commit is contained in:
6
lib/util.js
generated
6
lib/util.js
generated
@@ -755,7 +755,9 @@ exports.checkDiskUsage = checkDiskUsage;
|
||||
* to upgrade to v3.
|
||||
*/
|
||||
function checkActionVersion(version, githubVersion) {
|
||||
if (!semver.satisfies(version, ">=3")) {
|
||||
if (!semver.satisfies(version, ">=3") && // do not warn if the customer is already running v3
|
||||
!process.env.CODEQL_V2_DEPRECATION_WARNING // do not warn if we have already warned
|
||||
) {
|
||||
// Only log a warning for versions of GHES that are compatible with CodeQL Action version 3.
|
||||
//
|
||||
// GHES 3.11 shipped without the v3 tag, but it also shipped without this warning message code.
|
||||
@@ -768,6 +770,8 @@ function checkActionVersion(version, githubVersion) {
|
||||
core.warning("CodeQL Action v2 will be deprecated on December 5th, 2024. Please upgrade to v3. For " +
|
||||
"more information, see " +
|
||||
"https://github.blog/changelog/2024-01-12-code-scanning-deprecation-of-codeql-action-v2/");
|
||||
// set CODEQL_V2_DEPRECATION_WARNING env var to prevent the warning from being logged multiple times
|
||||
core.exportVariable("CODEQL_V2_DEPRECATION_WARNING", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
2
lib/util.test.js
generated
2
lib/util.test.js
generated
@@ -342,6 +342,8 @@ for (const [version, githubVersion, shouldReportWarning,] of CHECK_ACTION_VERSIO
|
||||
const versionStub = sinon
|
||||
.stub(api, "getGitHubVersion")
|
||||
.resolves(githubVersion);
|
||||
// call checkActionVersion twice and assert below that warning is reported only once
|
||||
util.checkActionVersion(version, await api.getGitHubVersion());
|
||||
util.checkActionVersion(version, await api.getGitHubVersion());
|
||||
if (shouldReportWarning) {
|
||||
t.true(warningSpy.calledOnceWithExactly(sinon.match("CodeQL Action v2 will be deprecated")));
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -433,6 +433,8 @@ for (const [
|
||||
.stub(api, "getGitHubVersion")
|
||||
.resolves(githubVersion);
|
||||
|
||||
// call checkActionVersion twice and assert below that warning is reported only once
|
||||
util.checkActionVersion(version, await api.getGitHubVersion());
|
||||
util.checkActionVersion(version, await api.getGitHubVersion());
|
||||
|
||||
if (shouldReportWarning) {
|
||||
|
||||
@@ -956,7 +956,10 @@ export function checkActionVersion(
|
||||
version: string,
|
||||
githubVersion: GitHubVersion,
|
||||
) {
|
||||
if (!semver.satisfies(version, ">=3")) {
|
||||
if (
|
||||
!semver.satisfies(version, ">=3") && // do not warn if the customer is already running v3
|
||||
!process.env.CODEQL_V2_DEPRECATION_WARNING // do not warn if we have already warned
|
||||
) {
|
||||
// Only log a warning for versions of GHES that are compatible with CodeQL Action version 3.
|
||||
//
|
||||
// GHES 3.11 shipped without the v3 tag, but it also shipped without this warning message code.
|
||||
@@ -976,6 +979,8 @@ export function checkActionVersion(
|
||||
"more information, see " +
|
||||
"https://github.blog/changelog/2024-01-12-code-scanning-deprecation-of-codeql-action-v2/",
|
||||
);
|
||||
// set CODEQL_V2_DEPRECATION_WARNING env var to prevent the warning from being logged multiple times
|
||||
core.exportVariable("CODEQL_V2_DEPRECATION_WARNING", "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user