Skip to content

Commit a854253

Browse files
committed
ensure deprecation warning is only shown once per job
1 parent f72cffc commit a854253

File tree

6 files changed

+17
-4
lines changed

6 files changed

+17
-4
lines changed

lib/util.js

+5-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.test.js

+2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/util.test.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/util.test.ts

+2
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,8 @@ for (const [
433433
.stub(api, "getGitHubVersion")
434434
.resolves(githubVersion);
435435

436+
// call checkActionVersion twice and assert below that warning is reported only once
437+
util.checkActionVersion(version, await api.getGitHubVersion());
436438
util.checkActionVersion(version, await api.getGitHubVersion());
437439

438440
if (shouldReportWarning) {

src/util.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -956,7 +956,10 @@ export function checkActionVersion(
956956
version: string,
957957
githubVersion: GitHubVersion,
958958
) {
959-
if (!semver.satisfies(version, ">=3")) {
959+
if (
960+
!semver.satisfies(version, ">=3") && // do not warn if the customer is already running v3
961+
!process.env.CODEQL_V2_DEPRECATION_WARNING // do not warn if we have already warned
962+
) {
960963
// Only log a warning for versions of GHES that are compatible with CodeQL Action version 3.
961964
//
962965
// GHES 3.11 shipped without the v3 tag, but it also shipped without this warning message code.
@@ -976,6 +979,8 @@ export function checkActionVersion(
976979
"more information, see " +
977980
"https://github.blog/changelog/2024-01-12-code-scanning-deprecation-of-codeql-action-v2/",
978981
);
982+
// set CODEQL_V2_DEPRECATION_WARNING env var to prevent the warning from being logged multiple times
983+
core.exportVariable("CODEQL_V2_DEPRECATION_WARNING", "true");
979984
}
980985
}
981986
}

0 commit comments

Comments
 (0)