diff --git a/CHANGELOG.md b/CHANGELOG.md index d64c59b53e..f5d68e1ed5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th ## [UNRELEASED] +- Add support for SHA-256 Git object IDs. [#3893](https://github.com/github/codeql-action/pull/3893) - If multiple inputs are provided for the GitHub-internal `analysis-kinds` input, only `code-scanning` will be enabled. The `analysis-kinds` input is experimental, for GitHub-internal use only, and may change without notice at any time. [#3892](https://github.com/github/codeql-action/pull/3892) - Added an experimental change which, when running a Code Scanning analysis for a PR with [improved incremental analysis](https://github.com/github/roadmap/issues/1158) enabled, prefers CodeQL CLI versions that have a cached overlay-base database for the configured languages. This speeds up analysis for a repository when there is not yet a cached overlay-base database for the latest CLI version. We expect to roll this change out to everyone in May. [#3880](https://github.com/github/codeql-action/pull/3880) diff --git a/lib/analyze-action-post.js b/lib/analyze-action-post.js index b45e5efb76..71c6ec0570 100644 --- a/lib/analyze-action-post.js +++ b/lib/analyze-action-post.js @@ -127472,7 +127472,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/lib/analyze-action.js b/lib/analyze-action.js index f64c5af5c8..157b3da730 100644 --- a/lib/analyze-action.js +++ b/lib/analyze-action.js @@ -89364,7 +89364,7 @@ var determineBaseBranchHeadCommitOid = async function(checkoutPathOverride) { } } } - if (commitOid === mergeSha && headOid.length === 40 && baseOid.length === 40) { + if (commitOid === mergeSha && (headOid.length === 40 || headOid.length === 64) && (baseOid.length === 40 || baseOid.length === 64)) { return baseOid; } return void 0; @@ -89430,7 +89430,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/lib/autobuild-action.js b/lib/autobuild-action.js index 36123e11e0..39944b097e 100644 --- a/lib/autobuild-action.js +++ b/lib/autobuild-action.js @@ -86289,7 +86289,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/lib/init-action-post.js b/lib/init-action-post.js index af3ec7d6fe..88d13eab9c 100644 --- a/lib/init-action-post.js +++ b/lib/init-action-post.js @@ -130841,7 +130841,7 @@ var determineBaseBranchHeadCommitOid = async function(checkoutPathOverride) { } } } - if (commitOid === mergeSha && headOid.length === 40 && baseOid.length === 40) { + if (commitOid === mergeSha && (headOid.length === 40 || headOid.length === 64) && (baseOid.length === 40 || baseOid.length === 64)) { return baseOid; } return void 0; @@ -130907,7 +130907,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/lib/init-action.js b/lib/init-action.js index cd3134c64a..040611c087 100644 --- a/lib/init-action.js +++ b/lib/init-action.js @@ -86776,7 +86776,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/lib/resolve-environment-action.js b/lib/resolve-environment-action.js index 4cec1a83b6..bdecc4644e 100644 --- a/lib/resolve-environment-action.js +++ b/lib/resolve-environment-action.js @@ -86282,7 +86282,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/lib/setup-codeql-action.js b/lib/setup-codeql-action.js index 8da937c38b..91daf3720c 100644 --- a/lib/setup-codeql-action.js +++ b/lib/setup-codeql-action.js @@ -86242,7 +86242,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/lib/upload-lib.js b/lib/upload-lib.js index 1b398dc76e..fe48b6dc03 100644 --- a/lib/upload-lib.js +++ b/lib/upload-lib.js @@ -89032,7 +89032,7 @@ var determineBaseBranchHeadCommitOid = async function(checkoutPathOverride) { } } } - if (commitOid === mergeSha && headOid.length === 40 && baseOid.length === 40) { + if (commitOid === mergeSha && (headOid.length === 40 || headOid.length === 64) && (baseOid.length === 40 || baseOid.length === 64)) { return baseOid; } return void 0; @@ -89098,7 +89098,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/lib/upload-sarif-action.js b/lib/upload-sarif-action.js index 8d92da25a9..dab83e5181 100644 --- a/lib/upload-sarif-action.js +++ b/lib/upload-sarif-action.js @@ -89072,7 +89072,7 @@ var determineBaseBranchHeadCommitOid = async function(checkoutPathOverride) { } } } - if (commitOid === mergeSha && headOid.length === 40 && baseOid.length === 40) { + if (commitOid === mergeSha && (headOid.length === 40 || headOid.length === 64) && (baseOid.length === 40 || baseOid.length === 64)) { return baseOid; } return void 0; @@ -89138,7 +89138,7 @@ var getFileOidsUnderPath = async function(basePath) { "Cannot list Git OIDs of tracked files." ); const fileOidMap = {}; - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/src/diff-informed-analysis-utils.test.ts b/src/diff-informed-analysis-utils.test.ts index 0ea71db950..bbcf321ff5 100644 --- a/src/diff-informed-analysis-utils.test.ts +++ b/src/diff-informed-analysis-utils.test.ts @@ -73,10 +73,10 @@ const testShouldPerformDiffInformedAnalysis = makeMacro({ [Feature.DiffInformedQueries]: testCase.featureEnabled, }); - const getGitHubVersionStub = sinon + sinon .stub(apiClient, "getGitHubVersion") .resolves(testCase.gitHubVersion); - const getPullRequestBranchesStub = sinon + sinon .stub(actionsUtil, "getPullRequestBranches") .returns(testCase.pullRequestBranches); @@ -89,9 +89,6 @@ const testShouldPerformDiffInformedAnalysis = makeMacro({ t.is(result, expectedResult); delete process.env.CODEQL_ACTION_DIFF_INFORMED_QUERIES; - - getGitHubVersionStub.restore(); - getPullRequestBranchesStub.restore(); }); }, title: (title) => `shouldPerformDiffInformedAnalysis: ${title}`, diff --git a/src/git-utils.test.ts b/src/git-utils.test.ts index 8804e1f998..b77d40a7ec 100644 --- a/src/git-utils.test.ts +++ b/src/git-utils.test.ts @@ -33,7 +33,6 @@ test.serial( const actualRef = await gitUtils.getRef(); t.deepEqual(actualRef, expectedRef); - callback.restore(); }); }, ); @@ -54,7 +53,6 @@ test.serial( const actualRef = await gitUtils.getRef(); t.deepEqual(actualRef, expectedRef); - callback.restore(); }); }, ); @@ -73,7 +71,6 @@ test.serial( const actualRef = await gitUtils.getRef(); t.deepEqual(actualRef, "refs/pull/1/head"); - callback.restore(); }); }, ); @@ -100,8 +97,6 @@ test.serial( const actualRef = await gitUtils.getRef(); t.deepEqual(actualRef, "refs/pull/2/merge"); - callback.restore(); - getAdditionalInputStub.restore(); }); }, ); @@ -161,7 +156,6 @@ test.serial( "Both 'ref' and 'sha' are required if one of them is provided.", }, ); - getAdditionalInputStub.restore(); }); }, ); @@ -188,7 +182,6 @@ test.serial( "Both 'ref' and 'sha' are required if one of them is provided.", }, ); - getAdditionalInputStub.restore(); }); }, ); @@ -242,7 +235,6 @@ test.serial("isAnalyzingDefaultBranch()", async (t) => { process.env["GITHUB_EVENT_NAME"] = "schedule"; process.env["GITHUB_REF"] = "refs/heads/main"; t.deepEqual(await gitUtils.isAnalyzingDefaultBranch(), false); - getAdditionalInputStub.restore(); }); }); @@ -254,8 +246,6 @@ test.serial("determineBaseBranchHeadCommitOid non-pullrequest", async (t) => { const result = await gitUtils.determineBaseBranchHeadCommitOid(__dirname); t.deepEqual(result, undefined); t.deepEqual(0, infoStub.callCount); - - infoStub.restore(); }); test.serial( @@ -276,8 +266,6 @@ test.serial( "git call failed. Will calculate the base branch SHA on the server. Error: " + "The checkout path provided to the action does not appear to be a git repository.", ); - - infoStub.restore(); }, ); @@ -301,10 +289,27 @@ test.serial("determineBaseBranchHeadCommitOid other error", async (t) => { "The checkout path provided to the action does not appear to be a git repository.", ), ); - - infoStub.restore(); }); +test.serial( + "determineBaseBranchHeadCommitOid accepts SHA-256 OIDs", + async (t) => { + const mergeSha = "a".repeat(64); + const baseOid = "b".repeat(64); + const headOid = "c".repeat(64); + + process.env["GITHUB_EVENT_NAME"] = "pull_request"; + process.env["GITHUB_SHA"] = mergeSha; + + sinon + .stub(gitUtils as any, "runGitCommand") + .resolves(`commit ${mergeSha}\nparent ${baseOid}\nparent ${headOid}\n`); + + const result = await gitUtils.determineBaseBranchHeadCommitOid(__dirname); + t.deepEqual(result, baseOid); + }, +); + test.serial("decodeGitFilePath unquoted strings", async (t) => { t.deepEqual(gitUtils.decodeGitFilePath("foo"), "foo"); t.deepEqual(gitUtils.decodeGitFilePath("foo bar"), "foo bar"); @@ -436,6 +441,64 @@ test.serial("getFileOidsUnderPath handles quoted paths", async (t) => { }); }); +test.serial("getFileOidsUnderPath handles SHA-256 OIDs", async (t) => { + await withTmpDir(async (tmpDir) => { + const sha256OidA = + "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2c0d4b7e8f9a1234567890ab"; + const sha256OidB = + "aabbccddeeff00112233445566778899aabbccddeeff00112233445566778899"; + + sinon + .stub(gitUtils as any, "runGitCommand") + .callsFake(async (_cwd: any, args: any) => { + if (args[0] === "rev-parse") { + return `${tmpDir}\n`; + } + return ( + `100644 ${sha256OidA} 0\tlib/sha256-file-a.js\n` + + `100644 ${sha256OidB} 0\tsrc/sha256-file-b.ts` + ); + }); + + const result = await gitUtils.getFileOidsUnderPath("/fake/path"); + + t.deepEqual(result, { + "lib/sha256-file-a.js": sha256OidA, + "src/sha256-file-b.ts": sha256OidB, + }); + }); +}); + +test.serial( + "getFileOidsUnderPath rejects OIDs of unsupported length", + async (t) => { + await withTmpDir(async (tmpDir) => { + // 50-char OID: not a valid SHA-1 (40) or SHA-256 (64) length. The regex + // must not accept this even though every character is a valid hex digit. + const invalidLine = + "100644 30d998ded095371488be3a729eb61d86ed721a1830d998ded0 0\tlib/bad.js"; + sinon + .stub(gitUtils as any, "runGitCommand") + .callsFake(async (_cwd: any, args: any) => { + if (args[0] === "rev-parse") { + return `${tmpDir}\n`; + } + return invalidLine; + }); + + await t.throwsAsync( + async () => { + await gitUtils.getFileOidsUnderPath("/fake/path"); + }, + { + instanceOf: Error, + message: `Unexpected "git ls-files" output: ${invalidLine}`, + }, + ); + }); + }, +); + test.serial("getFileOidsUnderPath handles empty output", async (t) => { await withTmpDir(async (tmpDir) => { sinon diff --git a/src/git-utils.ts b/src/git-utils.ts index ec0478fa89..0f5bf52a47 100644 --- a/src/git-utils.ts +++ b/src/git-utils.ts @@ -163,11 +163,12 @@ export const determineBaseBranchHeadCommitOid = async function ( } } - // Let's confirm our assumptions: We had a merge commit and the parsed parent data looks correct + // Let's confirm our assumptions: We had a merge commit and the parsed parent + // data looks correct. OIDs are either 40 (SHA-1) or 64 (SHA-256) hex characters. if ( commitOid === mergeSha && - headOid.length === 40 && - baseOid.length === 40 + (headOid.length === 40 || headOid.length === 64) && + (baseOid.length === 40 || baseOid.length === 64) ) { return baseOid; } @@ -296,7 +297,8 @@ export const getFileOidsUnderPath = async function ( // 100644 4c51bc1d9e86cd86e01b0f340cb8ce095c33b283 0\tsrc/git-utils.test.ts // 100644 6b792ea543ce75d7a8a03df591e3c85311ecb64f 0\tsrc/git-utils.ts // The fields are: \t - const regex = /^[0-9]+ ([0-9a-f]{40}) [0-9]+\t(.+)$/; + // The OID is either 40 (SHA-1) or 64 (SHA-256) hex characters. + const regex = /^[0-9]+ ([0-9a-f]{40}|[0-9a-f]{64}) [0-9]+\t(.+)$/; for (const line of stdout.split("\n")) { if (line) { const match = line.match(regex); diff --git a/src/overlay/caching.test.ts b/src/overlay/caching.test.ts index 618a25451d..daf3483ed5 100644 --- a/src/overlay/caching.test.ts +++ b/src/overlay/caching.test.ts @@ -80,65 +80,46 @@ const testDownloadOverlayBaseDatabaseFromCache = makeMacro({ await fs.promises.writeFile(baseDatabaseOidsFile, JSON.stringify({})); } - const stubs: sinon.SinonStub[] = []; + sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/"); - const getAutomationIDStub = sinon - .stub(apiClient, "getAutomationID") - .resolves("test-automation-id/"); - stubs.push(getAutomationIDStub); - - const isInTestModeStub = sinon - .stub(utils, "isInTestMode") - .returns(testCase.isInTestMode); - stubs.push(isInTestModeStub); + sinon.stub(utils, "isInTestMode").returns(testCase.isInTestMode); if (testCase.restoreCacheResult instanceof Error) { - const restoreCacheStub = sinon + sinon .stub(actionsCache, "restoreCache") .rejects(testCase.restoreCacheResult); - stubs.push(restoreCacheStub); } else { - const restoreCacheStub = sinon + sinon .stub(actionsCache, "restoreCache") .resolves(testCase.restoreCacheResult); - stubs.push(restoreCacheStub); } - const tryGetFolderBytesStub = sinon + sinon .stub(utils, "tryGetFolderBytes") .resolves(testCase.tryGetFolderBytesSucceeds ? 1024 * 1024 : undefined); - stubs.push(tryGetFolderBytesStub); const codeql = mockCodeQLVersion(testCase.codeQLVersion); if (testCase.resolveDatabaseOutput instanceof Error) { - const resolveDatabaseStub = sinon + sinon .stub(codeql, "resolveDatabase") .rejects(testCase.resolveDatabaseOutput); - stubs.push(resolveDatabaseStub); } else { - const resolveDatabaseStub = sinon + sinon .stub(codeql, "resolveDatabase") .resolves(testCase.resolveDatabaseOutput); - stubs.push(resolveDatabaseStub); } - try { - const result = await downloadOverlayBaseDatabaseFromCache( - codeql, - config, - logger, - ); + const result = await downloadOverlayBaseDatabaseFromCache( + codeql, + config, + logger, + ); - if (expectDownloadSuccess) { - t.truthy(result); - } else { - t.is(result, undefined); - } - } finally { - for (const stub of stubs) { - stub.restore(); - } + if (expectDownloadSuccess) { + t.truthy(result); + } else { + t.is(result, undefined); } }); }, diff --git a/src/overlay/index.test.ts b/src/overlay/index.test.ts index 860f32c7ba..967ccf3a7d 100644 --- a/src/overlay/index.test.ts +++ b/src/overlay/index.test.ts @@ -50,31 +50,21 @@ test.serial( "modified.js": "ddd444", // Changed OID "added.js": "eee555", // New file }; - const getFileOidsStubForOverlay = sinon - .stub(gitUtils, "getFileOidsUnderPath") - .resolves(currentOids); + sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids); // Write the overlay changes file, which uses the mocked overlay OIDs // and the base database OIDs file const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json"); - const getTempDirStub = sinon - .stub(actionsUtil, "getTemporaryDirectory") - .returns(tempDir); - const getDiffRangesStub = sinon + sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir); + sinon .stub(actionsUtil, "getDiffRangesJsonFilePath") .returns(diffRangeFilePath); - const getGitRootStub = sinon - .stub(gitUtils, "getGitRoot") - .resolves(sourceRoot); + sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot); const changesFilePath = await writeOverlayChangesFile( config, sourceRoot, logger, ); - getFileOidsStubForOverlay.restore(); - getTempDirStub.restore(); - getDiffRangesStub.restore(); - getGitRootStub.restore(); const fileContent = await fs.promises.readFile(changesFilePath, "utf-8"); const parsedContent = JSON.parse(fileContent) as { changes: string[] }; @@ -128,20 +118,14 @@ test.serial( "modified.js": "ddd444", // Changed OID "reverted.js": "eee555", // Same OID as base -- not detected by OID comparison }; - const getFileOidsStubForOverlay = sinon - .stub(gitUtils, "getFileOidsUnderPath") - .resolves(currentOids); + sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids); const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json"); - const getTempDirStub = sinon - .stub(actionsUtil, "getTemporaryDirectory") - .returns(tempDir); - const getDiffRangesStub = sinon + sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir); + sinon .stub(actionsUtil, "getDiffRangesJsonFilePath") .returns(diffRangeFilePath); - const getGitRootStub = sinon - .stub(gitUtils, "getGitRoot") - .resolves(sourceRoot); + sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot); // Write a pr-diff-range.json file with diff ranges including // "reverted.js" (unchanged OIDs) and "modified.js" (already in OID changes) @@ -159,10 +143,6 @@ test.serial( sourceRoot, logger, ); - getFileOidsStubForOverlay.restore(); - getTempDirStub.restore(); - getDiffRangesStub.restore(); - getGitRootStub.restore(); const fileContent = await fs.promises.readFile(changesFilePath, "utf-8"); const parsedContent = JSON.parse(fileContent) as { changes: string[] }; @@ -208,20 +188,14 @@ test.serial( "unchanged.js": "aaa111", "modified.js": "ddd444", }; - const getFileOidsStubForOverlay = sinon - .stub(gitUtils, "getFileOidsUnderPath") - .resolves(currentOids); + sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids); const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json"); - const getTempDirStub = sinon - .stub(actionsUtil, "getTemporaryDirectory") - .returns(tempDir); - const getDiffRangesStub = sinon + sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir); + sinon .stub(actionsUtil, "getDiffRangesJsonFilePath") .returns(diffRangeFilePath); - const getGitRootStub = sinon - .stub(gitUtils, "getGitRoot") - .resolves(sourceRoot); + sinon.stub(gitUtils, "getGitRoot").resolves(sourceRoot); // No pr-diff-range.json file exists - should work the same as before const changesFilePath = await writeOverlayChangesFile( @@ -229,10 +203,6 @@ test.serial( sourceRoot, logger, ); - getFileOidsStubForOverlay.restore(); - getTempDirStub.restore(); - getDiffRangesStub.restore(); - getGitRootStub.restore(); const fileContent = await fs.promises.readFile(changesFilePath, "utf-8"); const parsedContent = JSON.parse(fileContent) as { changes: string[] }; @@ -281,21 +251,15 @@ test.serial( "app.js": "aaa111", "lib/util.js": "bbb222", }; - const getFileOidsStubForOverlay = sinon - .stub(gitUtils, "getFileOidsUnderPath") - .resolves(currentOids); + sinon.stub(gitUtils, "getFileOidsUnderPath").resolves(currentOids); const diffRangeFilePath = path.join(tempDir, "pr-diff-range.json"); - const getTempDirStub = sinon - .stub(actionsUtil, "getTemporaryDirectory") - .returns(tempDir); - const getDiffRangesStub = sinon + sinon.stub(actionsUtil, "getTemporaryDirectory").returns(tempDir); + sinon .stub(actionsUtil, "getDiffRangesJsonFilePath") .returns(diffRangeFilePath); // getGitRoot returns the repo root (parent of sourceRoot) - const getGitRootStub = sinon - .stub(gitUtils, "getGitRoot") - .resolves(repoRoot); + sinon.stub(gitUtils, "getGitRoot").resolves(repoRoot); // Diff ranges use repo-root-relative paths (as returned by the GitHub compare API) await fs.promises.writeFile( @@ -312,10 +276,6 @@ test.serial( sourceRoot, logger, ); - getFileOidsStubForOverlay.restore(); - getTempDirStub.restore(); - getDiffRangesStub.restore(); - getGitRootStub.restore(); const fileContent = await fs.promises.readFile(changesFilePath, "utf-8"); const parsedContent = JSON.parse(fileContent) as { changes: string[] }; diff --git a/src/util.test.ts b/src/util.test.ts index 63b9263e0d..cca457cbe6 100644 --- a/src/util.test.ts +++ b/src/util.test.ts @@ -418,9 +418,7 @@ for (const [ `checkActionVersion ${reportErrorDescription} for ${versionsDescription}`, async (t) => { const warningSpy = sinon.spy(core, "warning"); - const versionStub = sinon - .stub(api, "getGitHubVersion") - .resolves(githubVersion); + sinon.stub(api, "getGitHubVersion").resolves(githubVersion); // call checkActionVersion twice and assert below that warning is reported only once util.checkActionVersion(version, await api.getGitHubVersion()); @@ -437,7 +435,6 @@ for (const [ } else { t.false(warningSpy.called); } - versionStub.restore(); }, ); }