From 9e044c5432c180c4286c40cccdc369aac7a2fed2 Mon Sep 17 00:00:00 2001 From: Andrew Eisenberg Date: Tue, 4 Oct 2022 11:43:24 -0700 Subject: [PATCH 1/4] Convert "Invalid source root" errors to UserErrors --- lib/init.js | 46 +++++++++++++++++++++++++++-------------- lib/init.js.map | 2 +- src/init.ts | 55 +++++++++++++++++++++++++++++++++---------------- 3 files changed, 69 insertions(+), 34 deletions(-) diff --git a/lib/init.js b/lib/init.js index 0a8d6f64dd..443084377c 100644 --- a/lib/init.js +++ b/lib/init.js @@ -47,7 +47,6 @@ async function initConfig(languagesInput, queriesInput, packsInput, registriesIn } exports.initConfig = initConfig; async function runInit(codeql, config, sourceRoot, processName, processLevel, featureFlags, logger) { - var _a, _b; fs.mkdirSync(config.dbLocation, { recursive: true }); try { if (await (0, util_1.codeQlVersionAbove)(codeql, codeql_1.CODEQL_VERSION_NEW_TRACING)) { @@ -62,24 +61,41 @@ async function runInit(codeql, config, sourceRoot, processName, processLevel, fe } } catch (e) { - // Handle the situation where init is called twice - // for the same database in the same job. - if (e instanceof Error && - ((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("Refusing to create databases")) && - e.message.includes("exists and is not an empty directory.")) { - throw new util.UserError(`Is the "init" action called twice in the same job? ${e.message}`); - } - else if (e instanceof Error && - ((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("is not compatible with this CodeQL CLI"))) { - throw new util.UserError(e.message); - } - else { - throw e; - } + throw processError(e); } return await (0, tracer_config_1.getCombinedTracerConfig)(config, codeql, await util.isGoExtractionReconciliationEnabled(featureFlags), logger); } exports.runInit = runInit; +/** + * Possibly convert this error into a UserError in order to avoid + * counting this error towards our internal error budget. + * + * @param e The error to possibly convert to a UserError. + * + * @returns A UserError if the error is a known error that can be + * attributed to the user, otherwise the original error. + */ +function processError(e) { + var _a, _b, _c, _d; + if (!(e instanceof Error)) { + return e; + } + if ( + // Init action called twice + ((_a = e.message) === null || _a === void 0 ? void 0 : _a.includes("Refusing to create databases")) && + ((_b = e.message) === null || _b === void 0 ? void 0 : _b.includes("exists and is not an empty directory."))) { + return new util.UserError(`Is the "init" action called twice in the same job? ${e.message}`); + } + if ( + // Version of CodeQL CLI is incompatible with this version of the CodeQL Action + ((_c = e.message) === null || _c === void 0 ? void 0 : _c.includes("is not compatible with this CodeQL CLI")) || + ( + // Expected source location for database creation does not exist + (_d = e.message) === null || _d === void 0 ? void 0 : _d.includes("Invalid source root"))) { + return new util.UserError(e.message); + } + return e; +} // Runs a powershell script to inject the tracer into a parent process // so it can tracer future processes, hopefully including the build process. // If processName is given then injects into the nearest parent process with diff --git a/lib/init.js.map b/lib/init.js.map index 86234bcba8..ecc28112d5 100644 --- a/lib/init.js.map +++ b/lib/init.js.map @@ -1 +1 @@ -{"version":3,"file":"init.js","sourceRoot":"","sources":["../src/init.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAyB;AACzB,2CAA6B;AAE7B,yEAA2D;AAC3D,kEAAoD;AAEpD,gEAAkD;AAElD,qCAA2E;AAC3E,4DAA8C;AAI9C,mDAAwE;AACxE,6CAA+B;AAC/B,iCAA4C;AAErC,KAAK,UAAU,UAAU,CAC9B,SAA6B,EAC7B,UAA4B,EAC5B,OAAe,EACf,OAA2B,EAC3B,YAA0B,EAC1B,MAAc;IAEd,MAAM,CAAC,UAAU,CAAC,oBAAoB,CAAC,CAAC;IACxC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,GAAG,MAAM,IAAA,oBAAW,EAChD,SAAS,EACT,UAAU,EACV,OAAO,EACP,OAAO,EACP,YAAY,EACZ,MAAM,EACN,IAAI,CACL,CAAC;IACF,MAAM,MAAM,CAAC,YAAY,EAAE,CAAC;IAC5B,MAAM,CAAC,QAAQ,EAAE,CAAC;IAClB,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAC;AAClC,CAAC;AArBD,gCAqBC;AAEM,KAAK,UAAU,UAAU,CAC9B,cAAkC,EAClC,YAAgC,EAChC,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AAC;aAC/B,CAAC,CAAC,IAAI,EAAE,CAAC;SACX;KACF;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,QAAQ,EAAE,CAAC;QAClB,MAAM,CAAC,OAAO,CACZ,gFAAgF,CAAC,IAAI;YACnF,qGAAqG;YACrG,oGAAoG;YACpG,iDAAiD,CACpD,CAAC;QACF,OAAO;KACR;IACD,MAAM,CAAC,QAAQ,EAAE,CAAC;AACpB,CAAC;AAzCD,8CAyCC"} \ No newline at end of file diff --git a/src/init.ts b/src/init.ts index ff8bdc615e..26895843f4 100644 --- a/src/init.ts +++ b/src/init.ts @@ -117,24 +117,7 @@ export async function runInit( } } } catch (e) { - // Handle the situation where init is called twice - // for the same database in the same job. - if ( - e instanceof Error && - e.message?.includes("Refusing to create databases") && - e.message.includes("exists and is not an empty directory.") - ) { - throw new util.UserError( - `Is the "init" action called twice in the same job? ${e.message}` - ); - } else if ( - e instanceof Error && - e.message?.includes("is not compatible with this CodeQL CLI") - ) { - throw new util.UserError(e.message); - } else { - throw e; - } + throw processError(e); } return await getCombinedTracerConfig( config, @@ -144,6 +127,42 @@ export async function runInit( ); } +/** + * Possibly convert this error into a UserError in order to avoid + * counting this error towards our internal error budget. + * + * @param e The error to possibly convert to a UserError. + * + * @returns A UserError if the error is a known error that can be + * attributed to the user, otherwise the original error. + */ +function processError(e: any): Error { + if (!(e instanceof Error)) { + return e; + } + + if ( + // Init action called twice + e.message?.includes("Refusing to create databases") && + e.message?.includes("exists and is not an empty directory.") + ) { + return new util.UserError( + `Is the "init" action called twice in the same job? ${e.message}` + ); + } + + if ( + // Version of CodeQL CLI is incompatible with this version of the CodeQL Action + e.message?.includes("is not compatible with this CodeQL CLI") || + // Expected source location for database creation does not exist + e.message?.includes("Invalid source root") + ) { + return new util.UserError(e.message); + } + + return e; +} + // Runs a powershell script to inject the tracer into a parent process // so it can tracer future processes, hopefully including the build process. // If processName is given then injects into the nearest parent process with From e4cc4a2fefdb78070c63fafe3eab2dfcf82620f3 Mon Sep 17 00:00:00 2001 From: Angela P Wen Date: Thu, 6 Oct 2022 15:18:52 -0700 Subject: [PATCH 2/4] Add changelog note for Go extraction reconciliation (#1286) * Add changelog note for Go extraction reconciliation * Update CHANGELOG.md Co-authored-by: Henry Mercer * Update CHANGELOG.md Co-authored-by: Andrew Eisenberg * Tweaks from PR review Co-authored-by: Henry Mercer Co-authored-by: Andrew Eisenberg --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd7092482c..17b3ea2b42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## [UNRELEASED] -No user facing changes. +- We are rolling out a feature of the CodeQL Action in October 2022 that changes the way that Go code is analyzed to be more consistent with other compiled languages like C/C++, C#, and Java. You do not need to alter your code scanning workflows. If you encounter any problems, please [file an issue](https://github.com/github/codeql-action/issues) or open a private ticket with GitHub Support and request an escalation to engineering. ## 2.1.26 - 29 Sep 2022 From 3d392940475e4c472e143ff2fd41aaffb1178094 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 7 Oct 2022 02:22:33 +0000 Subject: [PATCH 3/4] Mergeback v2.1.27 refs/heads/releases/v2 into main (#1289) * Merge main into releases/v2 (#1287) * Update changelog and version after v2.1.26 * Update checked-in dependencies * Don't check for Go logs on failure (#1279) * Update supported GitHub Enterprise Server versions. (#1275) Co-authored-by: GitHub * TRAP Caching: Add timeouts to upload/download operations * Add logging statements declaring state of the cli_config_file_enabled It's possible to determine this otherwise, but this makes it easier to spot. * Avoid using single value as array The user config parser in the CLI doesn't yet support it. * Extract logging statements to separate function * Correctly report CodeQL version when using cache (#1259) * Correctly report CodeQL version when using cache * Add JS generated files * Add test for return value of `setupCodeQL` * Fill in missing return value comment * Convert "Invalid source root" errors to UserErrors * Add changelog note for Go extraction reconciliation (#1286) * Add changelog note for Go extraction reconciliation * Update CHANGELOG.md Co-authored-by: Henry Mercer * Update CHANGELOG.md Co-authored-by: Andrew Eisenberg * Tweaks from PR review Co-authored-by: Henry Mercer Co-authored-by: Andrew Eisenberg * Update changelog for v2.1.27 Co-authored-by: github-actions[bot] Co-authored-by: Chuan-kai Lin Co-authored-by: Angela P Wen Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: GitHub Co-authored-by: Edoardo Pirovano Co-authored-by: Edoardo Pirovano <6748066+edoardopirovano@users.noreply.github.com> Co-authored-by: Andrew Eisenberg Co-authored-by: Henry Mercer * Update changelog and version after v2.1.27 * Update checked-in dependencies Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] Co-authored-by: Chuan-kai Lin Co-authored-by: Angela P Wen Co-authored-by: GitHub Co-authored-by: Edoardo Pirovano Co-authored-by: Edoardo Pirovano <6748066+edoardopirovano@users.noreply.github.com> Co-authored-by: Andrew Eisenberg Co-authored-by: Henry Mercer --- CHANGELOG.md | 4 ++++ node_modules/.package-lock.json | 2 +- package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 17b3ea2b42..54301fe299 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [UNRELEASED] +No user facing changes. + +## 2.1.27 - 06 Oct 2022 + - We are rolling out a feature of the CodeQL Action in October 2022 that changes the way that Go code is analyzed to be more consistent with other compiled languages like C/C++, C#, and Java. You do not need to alter your code scanning workflows. If you encounter any problems, please [file an issue](https://github.com/github/codeql-action/issues) or open a private ticket with GitHub Support and request an escalation to engineering. ## 2.1.26 - 29 Sep 2022 diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index b2764985e8..64e2840edc 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -1,6 +1,6 @@ { "name": "codeql", - "version": "2.1.27", + "version": "2.1.28", "lockfileVersion": 2, "requires": true, "packages": { diff --git a/package-lock.json b/package-lock.json index d8b156891e..605c03c462 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "codeql", - "version": "2.1.27", + "version": "2.1.28", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "codeql", - "version": "2.1.27", + "version": "2.1.28", "license": "MIT", "dependencies": { "@actions/artifact": "^1.0.0", diff --git a/package.json b/package.json index faa25a38ee..192715d85b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "codeql", - "version": "2.1.27", + "version": "2.1.28", "private": true, "description": "CodeQL action", "scripts": { From c6c7d293ca64d6a7e953b9680a26c5ffea86a392 Mon Sep 17 00:00:00 2001 From: Angela P Wen Date: Fri, 7 Oct 2022 12:05:42 -0700 Subject: [PATCH 4/4] Clarify merging with merge commit (#1291) * Clarify merging with merge commit * Add merge commit message to mergeback PRs --- .github/update-release-branch.py | 2 +- .github/workflows/post-release-mergeback.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/update-release-branch.py b/.github/update-release-branch.py index 9d20e38ebf..b547b1736f 100644 --- a/.github/update-release-branch.py +++ b/.github/update-release-branch.py @@ -104,7 +104,7 @@ def open_pr( body.append(' - [ ] Wait for the "Update dependencies" workflow to push a commit updating the dependencies.') body.append(' - [ ] Mark the PR as ready for review to trigger the full set of PR checks.') - body.append(' - [ ] Approve and merge this PR.') + body.append(' - [ ] Approve and merge this PR. Make sure `Create a merge commit` is selected rather than `Squash and merge` or `Rebase and merge`.') if is_v2_release: body.append(' - [ ] Merge the mergeback PR that will automatically be created once this PR is merged.') diff --git a/.github/workflows/post-release-mergeback.yml b/.github/workflows/post-release-mergeback.yml index 7b8b8a7768..1ba81b2b2a 100644 --- a/.github/workflows/post-release-mergeback.yml +++ b/.github/workflows/post-release-mergeback.yml @@ -122,7 +122,7 @@ jobs: - [ ] Remove and re-add the "Update dependencies" label to the PR to trigger just this workflow. - [ ] Wait for the "Update dependencies" workflow to push a commit updating the dependencies. - [ ] Mark the PR as ready for review to trigger the full set of PR checks. - - [ ] Approve and merge the PR. + - [ ] Approve and merge the PR. Make sure `Create a merge commit` is selected rather than `Squash and merge` or `Rebase and merge`. EOF )