Skip to content

Commit

Permalink
ensure deprecation warning is only shown once per job
Browse files Browse the repository at this point in the history
  • Loading branch information
nickfyson committed Jan 19, 2024
1 parent f72cffc commit a854253
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
6 changes: 5 additions & 1 deletion lib/util.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/util.test.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/util.test.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/util.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 6 additions & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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");
}
}
}

0 comments on commit a854253

Please sign in to comment.