ensure deprecation warning is only shown once per job
This commit is contained in:
parent
f72cffc780
commit
a854253aca
6 changed files with 17 additions and 4 deletions
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
Loading…
Add table
Add a link
Reference in a new issue