Compare commits

..

29 Commits

Author SHA1 Message Date
Paolo Tranquilli 68bde559de Merge pull request #3885 from github/update-v4.35.4-803d9e8c3
Merge main into releases/v4
2026-05-07 17:52:37 +02:00
github-actions[bot] 9739ad2d18 Update changelog for v4.35.4 2026-05-07 15:21:52 +00:00
Michael B. Gale 803d9e8c3c Merge pull request #3883 from github/mbg/test/macro-wrapper
Add more strongly typed wrapper around `test.macro`
2026-05-07 14:46:34 +00:00
Michael B. Gale 0fd9c7d135 Merge pull request #3882 from github/dependabot/github_actions/dot-github/workflows/actions-minor-4a0b9de8bd
Bump ruby/setup-ruby from 1.305.0 to 1.306.0 in /.github/workflows in the actions-minor group across 1 directory
2026-05-07 14:17:36 +00:00
Michael B. Gale 922d6fb888 Use makeMacro instead of test.macro 2026-05-07 14:59:42 +01:00
Michael B. Gale df77e87896 Update test macro snippet 2026-05-07 14:59:42 +01:00
Michael B. Gale 6e3f985e4f Add wrapper for test.macro 2026-05-07 14:59:42 +01:00
Paolo Tranquilli e7a347dfb1 Merge pull request #3881 from github/update-bundle/codeql-bundle-v2.25.4
Update default bundle to 2.25.4
2026-05-07 13:41:36 +00:00
github-actions[bot] 17eabb2500 Rebuild 2026-05-07 13:23:54 +00:00
dependabot[bot] aaef09c48d Bump ruby/setup-ruby
Bumps the actions-minor group with 1 update in the /.github/workflows directory: [ruby/setup-ruby](https://github.com/ruby/setup-ruby).


Updates `ruby/setup-ruby` from 1.305.0 to 1.306.0
- [Release notes](https://github.com/ruby/setup-ruby/releases)
- [Changelog](https://github.com/ruby/setup-ruby/blob/master/release.rb)
- [Commits](https://github.com/ruby/setup-ruby/compare/0cb964fd540e0a24c900370abf38a33466142735...c4e5b1316158f92e3d49443a9d58b31d25ac0f8f)

---
updated-dependencies:
- dependency-name: ruby/setup-ruby
  dependency-version: 1.306.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: actions-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2026-05-07 13:21:45 +00:00
github-actions[bot] ae1b9155d3 Add changelog note 2026-05-07 12:49:22 +00:00
github-actions[bot] 9f82f88f07 Update default bundle to codeql-bundle-v2.25.4 2026-05-07 12:49:13 +00:00
Paolo Tranquilli bc0b696b41 Merge pull request #3785 from github/mbg/dep/update-undici
Bump `undici` to at least `6.24.0`
2026-05-06 15:24:07 +00:00
Michael B. Gale f9bb0e001c Merge branch 'main' into mbg/dep/update-undici 2026-05-06 14:16:25 +01:00
Henry Mercer 4b7faf0b3d Merge pull request #3809 from github/henrymercer/determine-overlay-version
Overlay: Determine which versions of CodeQL are compatible with cached base DBs
2026-05-06 12:30:56 +00:00
Henry Mercer 09a1d9ec2a Add note about cache eviction 2026-05-05 18:54:16 +01:00
Henry Mercer f64a4491cf Add links to API docs 2026-05-05 18:48:09 +01:00
Henry Mercer 7fc86e0c37 Update type import syntax 2026-05-05 18:43:10 +01:00
Henry Mercer 5997e25ad9 Update listActionsCaches doc 2026-05-05 18:43:01 +01:00
Henry Mercer 7587714d0a Revert "Mitigate caches being evicted before they can be downloaded"
This reverts commit 1279e8d41c.
2026-05-05 18:37:17 +01:00
Michael B. Gale a723e99345 Merge pull request #3868 from github/mergeback/v4.35.3-to-main-e46ed2cb
Mergeback v4.35.3 refs/heads/releases/v4 into main
2026-05-01 14:34:01 +00:00
github-actions[bot] fbba1e03be Rebuild 2026-05-01 14:09:49 +00:00
github-actions[bot] 933238e8d5 Update changelog and version after v4.35.3 2026-05-01 14:06:46 +00:00
Óscar San José 8f02cfa11d Update from main and Rebuild 2026-04-27 19:30:21 +02:00
Henry Mercer 1279e8d41c Mitigate caches being evicted before they can be downloaded 2026-04-22 00:04:57 +01:00
Henry Mercer af1f613989 Use type-only imports 2026-04-21 23:49:37 +01:00
Henry Mercer 5026833be5 Document exclusion of nightlies 2026-04-21 23:35:29 +01:00
Henry Mercer 201ddc275d Retrieve CodeQL versions associated with cached overlay base DBs 2026-04-21 22:18:59 +01:00
Michael B. Gale 4ea3a4b4af Bump undici to at least 6.24.0 2026-03-27 17:32:08 +00:00
43 changed files with 5602 additions and 290690 deletions
+1 -1
View File
@@ -16,5 +16,5 @@ inputs:
Comma separated list of query ids that should NOT be included in this SARIF file. Comma separated list of query ids that should NOT be included in this SARIF file.
runs: runs:
using: node20 using: node24
main: index.js main: index.js
@@ -1,6 +1,6 @@
name: Verify that the best-effort debug artifact scan completed name: Verify that the best-effort debug artifact scan completed
description: Verifies that the best-effort debug artifact scan completed successfully during tests description: Verifies that the best-effort debug artifact scan completed successfully during tests
runs: runs:
using: node20 using: node24
main: index.js main: index.js
post: post.js post: post.js
+1 -1
View File
@@ -59,7 +59,7 @@ jobs:
use-all-platform-bundle: 'false' use-all-platform-bundle: 'false'
setup-kotlin: 'true' setup-kotlin: 'true'
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@0cb964fd540e0a24c900370abf38a33466142735 # v1.305.0 uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
with: with:
ruby-version: 2.6 ruby-version: 2.6
- name: Install Code Scanning integration - name: Install Code Scanning integration
+1 -1
View File
@@ -19,7 +19,7 @@
"scope": "javascript, typescript", "scope": "javascript, typescript",
"prefix": "testMacro", "prefix": "testMacro",
"body": [ "body": [
"const ${1:nameMacro} = test.macro({", "const ${1:nameMacro} = makeMacro({",
" exec: async (t: ExecutionContext<unknown>) => {},", " exec: async (t: ExecutionContext<unknown>) => {},",
"", "",
" title: (providedTitle = \"\") => `${2:common title} - \\${providedTitle}`,", " title: (providedTitle = \"\") => `${2:common title} - \\${providedTitle}`,",
+42 -30
View File
@@ -2,7 +2,11 @@
See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs. See the [releases page](https://github.com/github/codeql-action/releases) for the relevant changes to the CodeQL CLI and language packs.
## 3.35.3 - 01 May 2026 ## 4.35.4 - 07 May 2026
- Update default CodeQL bundle version to [2.25.4](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.4). [#3881](https://github.com/github/codeql-action/pull/3881)
## 4.35.3 - 01 May 2026
- _Upcoming breaking change_: Add a deprecation warning for customers using CodeQL version 2.19.3 and earlier. These versions of CodeQL were discontinued on 9 April 2026 alongside GitHub Enterprise Server 3.15, and will be unsupported by the next minor release of the CodeQL Action. [#3837](https://github.com/github/codeql-action/pull/3837) - _Upcoming breaking change_: Add a deprecation warning for customers using CodeQL version 2.19.3 and earlier. These versions of CodeQL were discontinued on 9 April 2026 alongside GitHub Enterprise Server 3.15, and will be unsupported by the next minor release of the CodeQL Action. [#3837](https://github.com/github/codeql-action/pull/3837)
- Configurations for private registries that use Cloudsmith or GCP OIDC are now accepted. [#3850](https://github.com/github/codeql-action/pull/3850) - Configurations for private registries that use Cloudsmith or GCP OIDC are now accepted. [#3850](https://github.com/github/codeql-action/pull/3850)
@@ -10,7 +14,7 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
- Fixed a bug where two diagnostics produced within the same millisecond could overwrite each other on disk, causing one of them to be lost. [#3852](https://github.com/github/codeql-action/pull/3852) - Fixed a bug where two diagnostics produced within the same millisecond could overwrite each other on disk, causing one of them to be lost. [#3852](https://github.com/github/codeql-action/pull/3852)
- Update default CodeQL bundle version to [2.25.3](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.3). [#3865](https://github.com/github/codeql-action/pull/3865) - Update default CodeQL bundle version to [2.25.3](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.3). [#3865](https://github.com/github/codeql-action/pull/3865)
## 3.35.2 - 15 Apr 2026 ## 4.35.2 - 15 Apr 2026
- The undocumented TRAP cache cleanup feature that could be enabled using the `CODEQL_ACTION_CLEANUP_TRAP_CACHES` environment variable is deprecated and will be removed in May 2026. If you are affected by this, we recommend disabling TRAP caching by passing the `trap-caching: false` input to the `init` Action. [#3795](https://github.com/github/codeql-action/pull/3795) - The undocumented TRAP cache cleanup feature that could be enabled using the `CODEQL_ACTION_CLEANUP_TRAP_CACHES` environment variable is deprecated and will be removed in May 2026. If you are affected by this, we recommend disabling TRAP caching by passing the `trap-caching: false` input to the `init` Action. [#3795](https://github.com/github/codeql-action/pull/3795)
- The Git version 2.36.0 requirement for improved incremental analysis now only applies to repositories that contain submodules. [#3789](https://github.com/github/codeql-action/pull/3789) - The Git version 2.36.0 requirement for improved incremental analysis now only applies to repositories that contain submodules. [#3789](https://github.com/github/codeql-action/pull/3789)
@@ -18,28 +22,29 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
- Fixed a bug in the validation of OIDC configurations for private registries that was added in CodeQL Action 4.33.0 / 3.33.0. [#3807](https://github.com/github/codeql-action/pull/3807) - Fixed a bug in the validation of OIDC configurations for private registries that was added in CodeQL Action 4.33.0 / 3.33.0. [#3807](https://github.com/github/codeql-action/pull/3807)
- Update default CodeQL bundle version to [2.25.2](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.2). [#3823](https://github.com/github/codeql-action/pull/3823) - Update default CodeQL bundle version to [2.25.2](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.2). [#3823](https://github.com/github/codeql-action/pull/3823)
## 3.35.1 - 27 Mar 2026 ## 4.35.1 - 27 Mar 2026
- Fix incorrect minimum required Git version for [improved incremental analysis](https://github.com/github/roadmap/issues/1158): it should have been 2.36.0, not 2.11.0. [#3781](https://github.com/github/codeql-action/pull/3781) - Fix incorrect minimum required Git version for [improved incremental analysis](https://github.com/github/roadmap/issues/1158): it should have been 2.36.0, not 2.11.0. [#3781](https://github.com/github/codeql-action/pull/3781)
## 3.35.0 - 27 Mar 2026 ## 4.35.0 - 27 Mar 2026
- Reduced the minimum Git version required for [improved incremental analysis](https://github.com/github/roadmap/issues/1158) from 2.38.0 to 2.11.0. [#3767](https://github.com/github/codeql-action/pull/3767) - Reduced the minimum Git version required for [improved incremental analysis](https://github.com/github/roadmap/issues/1158) from 2.38.0 to 2.11.0. [#3767](https://github.com/github/codeql-action/pull/3767)
- Update default CodeQL bundle version to [2.25.1](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.1). [#3773](https://github.com/github/codeql-action/pull/3773) - Update default CodeQL bundle version to [2.25.1](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.1). [#3773](https://github.com/github/codeql-action/pull/3773)
## 3.34.1 - 20 Mar 2026 ## 4.34.1 - 20 Mar 2026
- Downgrade default CodeQL bundle version to [2.24.3](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.3) due to issues with a small percentage of Actions and JavaScript analyses. [#3762](https://github.com/github/codeql-action/pull/3762) - Downgrade default CodeQL bundle version to [2.24.3](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.3) due to issues with a small percentage of Actions and JavaScript analyses. [#3762](https://github.com/github/codeql-action/pull/3762)
## 3.34.0 - 20 Mar 2026 ## 4.34.0 - 20 Mar 2026
- Added an experimental change which disables TRAP caching when [improved incremental analysis](https://github.com/github/roadmap/issues/1158) is enabled, since improved incremental analysis supersedes TRAP caching. This will improve performance and reduce Actions cache usage. We expect to roll this change out to everyone in March. [#3569](https://github.com/github/codeql-action/pull/3569) - Added an experimental change which disables TRAP caching when [improved incremental analysis](https://github.com/github/roadmap/issues/1158) is enabled, since improved incremental analysis supersedes TRAP caching. This will improve performance and reduce Actions cache usage. We expect to roll this change out to everyone in March. [#3569](https://github.com/github/codeql-action/pull/3569)
- We are rolling out improved incremental analysis to C/C++ analyses that use build mode `none`. We expect this rollout to be complete by the end of April 2026. [#3584](https://github.com/github/codeql-action/pull/3584) - We are rolling out improved incremental analysis to C/C++ analyses that use build mode `none`. We expect this rollout to be complete by the end of April 2026. [#3584](https://github.com/github/codeql-action/pull/3584)
- Update default CodeQL bundle version to [2.25.0](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.0). [#3585](https://github.com/github/codeql-action/pull/3585) - Update default CodeQL bundle version to [2.25.0](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.25.0). [#3585](https://github.com/github/codeql-action/pull/3585)
## 3.33.0 - 16 Mar 2026 ## 4.33.0 - 16 Mar 2026
- Upcoming change: Starting April 2026, the CodeQL Action will skip collecting file coverage information on pull requests to improve analysis performance. File coverage information will still be computed on non-PR analyses. Pull request analyses will log a warning about this upcoming change. [#3562](https://github.com/github/codeql-action/pull/3562) - Upcoming change: Starting April 2026, the CodeQL Action will skip collecting file coverage information on pull requests to improve analysis performance. File coverage information will still be computed on non-PR analyses. Pull request analyses will log a warning about this upcoming change. [#3562](https://github.com/github/codeql-action/pull/3562)
To opt out of this change: To opt out of this change:
- **Repositories owned by an organization:** Create a custom repository property with the name `github-codeql-file-coverage-on-prs` and the type "True/false", then set this property to `true` in the repository's settings. For more information, see [Managing custom properties for repositories in your organization](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization). Alternatively, if you are using an advanced setup workflow, you can set the `CODEQL_ACTION_FILE_COVERAGE_ON_PRS` environment variable to `true` in your workflow. - **Repositories owned by an organization:** Create a custom repository property with the name `github-codeql-file-coverage-on-prs` and the type "True/false", then set this property to `true` in the repository's settings. For more information, see [Managing custom properties for repositories in your organization](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization). Alternatively, if you are using an advanced setup workflow, you can set the `CODEQL_ACTION_FILE_COVERAGE_ON_PRS` environment variable to `true` in your workflow.
- **User-owned repositories using default setup:** Switch to an advanced setup workflow and set the `CODEQL_ACTION_FILE_COVERAGE_ON_PRS` environment variable to `true` in your workflow. - **User-owned repositories using default setup:** Switch to an advanced setup workflow and set the `CODEQL_ACTION_FILE_COVERAGE_ON_PRS` environment variable to `true` in your workflow.
@@ -50,11 +55,11 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
- Fixed the retry mechanism for database uploads. Previously this would fail with the error "Response body object should not be disturbed or locked". [#3564](https://github.com/github/codeql-action/pull/3564) - Fixed the retry mechanism for database uploads. Previously this would fail with the error "Response body object should not be disturbed or locked". [#3564](https://github.com/github/codeql-action/pull/3564)
- A warning is now emitted if the CodeQL Action detects a repository property whose name suggests that it relates to the CodeQL Action, but which is not one of the properties recognised by the current version of the CodeQL Action. [#3570](https://github.com/github/codeql-action/pull/3570) - A warning is now emitted if the CodeQL Action detects a repository property whose name suggests that it relates to the CodeQL Action, but which is not one of the properties recognised by the current version of the CodeQL Action. [#3570](https://github.com/github/codeql-action/pull/3570)
## 3.32.6 - 05 Mar 2026 ## 4.32.6 - 05 Mar 2026
- Update default CodeQL bundle version to [2.24.3](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.3). [#3548](https://github.com/github/codeql-action/pull/3548) - Update default CodeQL bundle version to [2.24.3](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.3). [#3548](https://github.com/github/codeql-action/pull/3548)
## 3.32.5 - 02 Mar 2026 ## 4.32.5 - 02 Mar 2026
- Repositories owned by an organization can now set up the `github-codeql-disable-overlay` custom repository property to disable [improved incremental analysis for CodeQL](https://github.com/github/roadmap/issues/1158). First, create a custom repository property with the name `github-codeql-disable-overlay` and the type "True/false" in the organization's settings. Then in the repository's settings, set this property to `true` to disable improved incremental analysis. For more information, see [Managing custom properties for repositories in your organization](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization). This feature is not yet available on GitHub Enterprise Server. [#3507](https://github.com/github/codeql-action/pull/3507) - Repositories owned by an organization can now set up the `github-codeql-disable-overlay` custom repository property to disable [improved incremental analysis for CodeQL](https://github.com/github/roadmap/issues/1158). First, create a custom repository property with the name `github-codeql-disable-overlay` and the type "True/false" in the organization's settings. Then in the repository's settings, set this property to `true` to disable improved incremental analysis. For more information, see [Managing custom properties for repositories in your organization](https://docs.github.com/en/organizations/managing-organization-settings/managing-custom-properties-for-repositories-in-your-organization). This feature is not yet available on GitHub Enterprise Server. [#3507](https://github.com/github/codeql-action/pull/3507)
- Added an experimental change so that when [improved incremental analysis](https://github.com/github/roadmap/issues/1158) fails on a runner — potentially due to insufficient disk space — the failure is recorded in the Actions cache so that subsequent runs will automatically skip improved incremental analysis until something changes (e.g. a larger runner is provisioned or a new CodeQL version is released). We expect to roll this change out to everyone in March. [#3487](https://github.com/github/codeql-action/pull/3487) - Added an experimental change so that when [improved incremental analysis](https://github.com/github/roadmap/issues/1158) fails on a runner — potentially due to insufficient disk space — the failure is recorded in the Actions cache so that subsequent runs will automatically skip improved incremental analysis until something changes (e.g. a larger runner is provisioned or a new CodeQL version is released). We expect to roll this change out to everyone in March. [#3487](https://github.com/github/codeql-action/pull/3487)
@@ -64,7 +69,7 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
- Added an experimental change which allows the `start-proxy` action to resolve the CodeQL CLI version from feature flags instead of using the linked CLI bundle version. We expect to roll this change out to everyone in March. [#3512](https://github.com/github/codeql-action/pull/3512) - Added an experimental change which allows the `start-proxy` action to resolve the CodeQL CLI version from feature flags instead of using the linked CLI bundle version. We expect to roll this change out to everyone in March. [#3512](https://github.com/github/codeql-action/pull/3512)
- The previously experimental changes from versions 4.32.3, 4.32.4, 3.32.3 and 3.32.4 are now enabled by default. [#3503](https://github.com/github/codeql-action/pull/3503), [#3504](https://github.com/github/codeql-action/pull/3504) - The previously experimental changes from versions 4.32.3, 4.32.4, 3.32.3 and 3.32.4 are now enabled by default. [#3503](https://github.com/github/codeql-action/pull/3503), [#3504](https://github.com/github/codeql-action/pull/3504)
## 3.32.4 - 20 Feb 2026 ## 4.32.4 - 20 Feb 2026
- Update default CodeQL bundle version to [2.24.2](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.2). [#3493](https://github.com/github/codeql-action/pull/3493) - Update default CodeQL bundle version to [2.24.2](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.2). [#3493](https://github.com/github/codeql-action/pull/3493)
- Added an experimental change which improves how certificates are generated for the authentication proxy that is used by the CodeQL Action in Default Setup when [private package registries are configured](https://docs.github.com/en/code-security/how-tos/secure-at-scale/configure-organization-security/manage-usage-and-access/giving-org-access-private-registries). This is expected to generate more widely compatible certificates and should have no impact on analyses which are working correctly already. We expect to roll this change out to everyone in February. [#3473](https://github.com/github/codeql-action/pull/3473) - Added an experimental change which improves how certificates are generated for the authentication proxy that is used by the CodeQL Action in Default Setup when [private package registries are configured](https://docs.github.com/en/code-security/how-tos/secure-at-scale/configure-organization-security/manage-usage-and-access/giving-org-access-private-registries). This is expected to generate more widely compatible certificates and should have no impact on analyses which are working correctly already. We expect to roll this change out to everyone in February. [#3473](https://github.com/github/codeql-action/pull/3473)
@@ -72,88 +77,88 @@ See the [releases page](https://github.com/github/codeql-action/releases) for th
- Added a setting which allows the CodeQL Action to enable network debugging for Java programs. This will help GitHub staff support customers with troubleshooting issues in GitHub-managed CodeQL workflows, such as Default Setup. This setting can only be enabled by GitHub staff. [#3485](https://github.com/github/codeql-action/pull/3485) - Added a setting which allows the CodeQL Action to enable network debugging for Java programs. This will help GitHub staff support customers with troubleshooting issues in GitHub-managed CodeQL workflows, such as Default Setup. This setting can only be enabled by GitHub staff. [#3485](https://github.com/github/codeql-action/pull/3485)
- Added a setting which enables GitHub-managed workflows, such as Default Setup, to use a [nightly CodeQL CLI release](https://github.com/dsp-testing/codeql-cli-nightlies) instead of the latest, stable release that is used by default. This will help GitHub staff support customers whose analyses for a given repository or organization require early access to a change in an upcoming CodeQL CLI release. This setting can only be enabled by GitHub staff. [#3484](https://github.com/github/codeql-action/pull/3484) - Added a setting which enables GitHub-managed workflows, such as Default Setup, to use a [nightly CodeQL CLI release](https://github.com/dsp-testing/codeql-cli-nightlies) instead of the latest, stable release that is used by default. This will help GitHub staff support customers whose analyses for a given repository or organization require early access to a change in an upcoming CodeQL CLI release. This setting can only be enabled by GitHub staff. [#3484](https://github.com/github/codeql-action/pull/3484)
## 3.32.3 - 13 Feb 2026 ## 4.32.3 - 13 Feb 2026
- Added experimental support for testing connections to [private package registries](https://docs.github.com/en/code-security/how-tos/secure-at-scale/configure-organization-security/manage-usage-and-access/giving-org-access-private-registries). This feature is not currently enabled for any analysis. In the future, it may be enabled by default for Default Setup. [#3466](https://github.com/github/codeql-action/pull/3466) - Added experimental support for testing connections to [private package registries](https://docs.github.com/en/code-security/how-tos/secure-at-scale/configure-organization-security/manage-usage-and-access/giving-org-access-private-registries). This feature is not currently enabled for any analysis. In the future, it may be enabled by default for Default Setup. [#3466](https://github.com/github/codeql-action/pull/3466)
## 3.32.2 - 05 Feb 2026 ## 4.32.2 - 05 Feb 2026
- Update default CodeQL bundle version to [2.24.1](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.1). [#3460](https://github.com/github/codeql-action/pull/3460) - Update default CodeQL bundle version to [2.24.1](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.1). [#3460](https://github.com/github/codeql-action/pull/3460)
## 3.32.1 - 02 Feb 2026 ## 4.32.1 - 02 Feb 2026
- A warning is now shown in Default Setup workflow logs if a [private package registry is configured](https://docs.github.com/en/code-security/how-tos/secure-at-scale/configure-organization-security/manage-usage-and-access/giving-org-access-private-registries) using a GitHub Personal Access Token (PAT), but no username is configured. [#3422](https://github.com/github/codeql-action/pull/3422) - A warning is now shown in Default Setup workflow logs if a [private package registry is configured](https://docs.github.com/en/code-security/how-tos/secure-at-scale/configure-organization-security/manage-usage-and-access/giving-org-access-private-registries) using a GitHub Personal Access Token (PAT), but no username is configured. [#3422](https://github.com/github/codeql-action/pull/3422)
- Fixed a bug which caused the CodeQL Action to fail when repository properties cannot successfully be retrieved. [#3421](https://github.com/github/codeql-action/pull/3421) - Fixed a bug which caused the CodeQL Action to fail when repository properties cannot successfully be retrieved. [#3421](https://github.com/github/codeql-action/pull/3421)
## 3.32.0 - 26 Jan 2026 ## 4.32.0 - 26 Jan 2026
- Update default CodeQL bundle version to [2.24.0](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.0). [#3425](https://github.com/github/codeql-action/pull/3425) - Update default CodeQL bundle version to [2.24.0](https://github.com/github/codeql-action/releases/tag/codeql-bundle-v2.24.0). [#3425](https://github.com/github/codeql-action/pull/3425)
## 3.31.11 - 23 Jan 2026 ## 4.31.11 - 23 Jan 2026
- When running a Default Setup workflow with [Actions debugging enabled](https://docs.github.com/en/actions/how-tos/monitor-workflows/enable-debug-logging), the CodeQL Action will now use more unique names when uploading logs from the Dependabot authentication proxy as workflow artifacts. This ensures that the artifact names do not clash between multiple jobs in a build matrix. [#3409](https://github.com/github/codeql-action/pull/3409) - When running a Default Setup workflow with [Actions debugging enabled](https://docs.github.com/en/actions/how-tos/monitor-workflows/enable-debug-logging), the CodeQL Action will now use more unique names when uploading logs from the Dependabot authentication proxy as workflow artifacts. This ensures that the artifact names do not clash between multiple jobs in a build matrix. [#3409](https://github.com/github/codeql-action/pull/3409)
- Improved error handling throughout the CodeQL Action. [#3415](https://github.com/github/codeql-action/pull/3415) - Improved error handling throughout the CodeQL Action. [#3415](https://github.com/github/codeql-action/pull/3415)
- Added experimental support for automatically excluding [generated files](https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github) from the analysis. This feature is not currently enabled for any analysis. In the future, it may be enabled by default for some GitHub-managed analyses. [#3318](https://github.com/github/codeql-action/pull/3318) - Added experimental support for automatically excluding [generated files](https://docs.github.com/en/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github) from the analysis. This feature is not currently enabled for any analysis. In the future, it may be enabled by default for some GitHub-managed analyses. [#3318](https://github.com/github/codeql-action/pull/3318)
- The changelog extracts that are included with releases of the CodeQL Action are now shorter to avoid duplicated information from appearing in Dependabot PRs. [#3403](https://github.com/github/codeql-action/pull/3403) - The changelog extracts that are included with releases of the CodeQL Action are now shorter to avoid duplicated information from appearing in Dependabot PRs. [#3403](https://github.com/github/codeql-action/pull/3403)
## 3.31.10 - 12 Jan 2026 ## 4.31.10 - 12 Jan 2026
- Update default CodeQL bundle version to 2.23.9. [#3393](https://github.com/github/codeql-action/pull/3393) - Update default CodeQL bundle version to 2.23.9. [#3393](https://github.com/github/codeql-action/pull/3393)
## 3.31.9 - 16 Dec 2025 ## 4.31.9 - 16 Dec 2025
No user facing changes. No user facing changes.
## 3.31.8 - 11 Dec 2025 ## 4.31.8 - 11 Dec 2025
- Update default CodeQL bundle version to 2.23.8. [#3354](https://github.com/github/codeql-action/pull/3354) - Update default CodeQL bundle version to 2.23.8. [#3354](https://github.com/github/codeql-action/pull/3354)
## 3.31.7 - 05 Dec 2025 ## 4.31.7 - 05 Dec 2025
- Update default CodeQL bundle version to 2.23.7. [#3343](https://github.com/github/codeql-action/pull/3343) - Update default CodeQL bundle version to 2.23.7. [#3343](https://github.com/github/codeql-action/pull/3343)
## 3.31.6 - 01 Dec 2025 ## 4.31.6 - 01 Dec 2025
No user facing changes. No user facing changes.
## 3.31.5 - 24 Nov 2025 ## 4.31.5 - 24 Nov 2025
- Update default CodeQL bundle version to 2.23.6. [#3321](https://github.com/github/codeql-action/pull/3321) - Update default CodeQL bundle version to 2.23.6. [#3321](https://github.com/github/codeql-action/pull/3321)
## 3.31.4 - 18 Nov 2025 ## 4.31.4 - 18 Nov 2025
No user facing changes. No user facing changes.
## 3.31.3 - 13 Nov 2025 ## 4.31.3 - 13 Nov 2025
- CodeQL Action v3 will be deprecated in December 2026. The Action now logs a warning for customers who are running v3 but could be running v4. For more information, see [Upcoming deprecation of CodeQL Action v3](https://github.blog/changelog/2025-10-28-upcoming-deprecation-of-codeql-action-v3/). - CodeQL Action v3 will be deprecated in December 2026. The Action now logs a warning for customers who are running v3 but could be running v4. For more information, see [Upcoming deprecation of CodeQL Action v3](https://github.blog/changelog/2025-10-28-upcoming-deprecation-of-codeql-action-v3/).
- Update default CodeQL bundle version to 2.23.5. [#3288](https://github.com/github/codeql-action/pull/3288) - Update default CodeQL bundle version to 2.23.5. [#3288](https://github.com/github/codeql-action/pull/3288)
## 3.31.2 - 30 Oct 2025 ## 4.31.2 - 30 Oct 2025
No user facing changes. No user facing changes.
## 3.31.1 - 30 Oct 2025 ## 4.31.1 - 30 Oct 2025
- The `add-snippets` input has been removed from the `analyze` action. This input has been deprecated since CodeQL Action 3.26.4 in August 2024 when this removal was announced. - The `add-snippets` input has been removed from the `analyze` action. This input has been deprecated since CodeQL Action 3.26.4 in August 2024 when this removal was announced.
## 3.31.0 - 24 Oct 2025 ## 4.31.0 - 24 Oct 2025
- Bump minimum CodeQL bundle version to 2.17.6. [#3223](https://github.com/github/codeql-action/pull/3223) - Bump minimum CodeQL bundle version to 2.17.6. [#3223](https://github.com/github/codeql-action/pull/3223)
- When SARIF files are uploaded by the `analyze` or `upload-sarif` actions, the CodeQL Action automatically performs post-processing steps to prepare the data for the upload. Previously, these post-processing steps were only performed before an upload took place. We are now changing this so that the post-processing steps will always be performed, even when the SARIF files are not uploaded. This does not change anything for the `upload-sarif` action. For `analyze`, this may affect Advanced Setup for CodeQL users who specify a value other than `always` for the `upload` input. [#3222](https://github.com/github/codeql-action/pull/3222) - When SARIF files are uploaded by the `analyze` or `upload-sarif` actions, the CodeQL Action automatically performs post-processing steps to prepare the data for the upload. Previously, these post-processing steps were only performed before an upload took place. We are now changing this so that the post-processing steps will always be performed, even when the SARIF files are not uploaded. This does not change anything for the `upload-sarif` action. For `analyze`, this may affect Advanced Setup for CodeQL users who specify a value other than `always` for the `upload` input. [#3222](https://github.com/github/codeql-action/pull/3222)
## 3.30.9 - 17 Oct 2025 ## 4.30.9 - 17 Oct 2025
- Update default CodeQL bundle version to 2.23.3. [#3205](https://github.com/github/codeql-action/pull/3205) - Update default CodeQL bundle version to 2.23.3. [#3205](https://github.com/github/codeql-action/pull/3205)
- Experimental: A new `setup-codeql` action has been added which is similar to `init`, except it only installs the CodeQL CLI and does not initialize a database. Do not use this in production as it is part of an internal experiment and subject to change at any time. [#3204](https://github.com/github/codeql-action/pull/3204) - Experimental: A new `setup-codeql` action has been added which is similar to `init`, except it only installs the CodeQL CLI and does not initialize a database. Do not use this in production as it is part of an internal experiment and subject to change at any time. [#3204](https://github.com/github/codeql-action/pull/3204)
## 3.30.8 - 10 Oct 2025 ## 4.30.8 - 10 Oct 2025
No user facing changes. No user facing changes.
## 3.30.7 - 06 Oct 2025 ## 4.30.7 - 06 Oct 2025
No user facing changes. - [v4+ only] The CodeQL Action now runs on Node.js v24. [#3169](https://github.com/github/codeql-action/pull/3169)
## 3.30.6 - 02 Oct 2025 ## 3.30.6 - 02 Oct 2025
@@ -389,13 +394,17 @@ No user facing changes.
## 3.26.12 - 07 Oct 2024 ## 3.26.12 - 07 Oct 2024
- _Upcoming breaking change_: Add a deprecation warning for customers using CodeQL version 2.14.5 and earlier. These versions of CodeQL were discontinued on 24 September 2024 alongside GitHub Enterprise Server 3.10, and will be unsupported by CodeQL Action versions 3.27.0 and later and versions 2.27.0 and later. [#2520](https://github.com/github/codeql-action/pull/2520) - _Upcoming breaking change_: Add a deprecation warning for customers using CodeQL version 2.14.5 and earlier. These versions of CodeQL were discontinued on 24 September 2024 alongside GitHub Enterprise Server 3.10, and will be unsupported by CodeQL Action versions 3.27.0 and later and versions 2.27.0 and later. [#2520](https://github.com/github/codeql-action/pull/2520)
- If you are using one of these versions, please update to CodeQL CLI version 2.14.6 or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version. - If you are using one of these versions, please update to CodeQL CLI version 2.14.6 or later. For instance, if you have specified a custom version of the CLI using the 'tools' input to the 'init' Action, you can remove this input to use the default version.
- Alternatively, if you want to continue using a version of the CodeQL CLI between 2.13.5 and 2.14.5, you can replace `github/codeql-action/*@v3` by `github/codeql-action/*@v3.26.11` and `github/codeql-action/*@v2` by `github/codeql-action/*@v2.26.11` in your code scanning workflow to ensure you continue using this version of the CodeQL Action. - Alternatively, if you want to continue using a version of the CodeQL CLI between 2.13.5 and 2.14.5, you can replace `github/codeql-action/*@v3` by `github/codeql-action/*@v3.26.11` and `github/codeql-action/*@v2` by `github/codeql-action/*@v2.26.11` in your code scanning workflow to ensure you continue using this version of the CodeQL Action.
## 3.26.11 - 03 Oct 2024 ## 3.26.11 - 03 Oct 2024
- _Upcoming breaking change_: Add support for using `actions/download-artifact@v4` to programmatically consume CodeQL Action debug artifacts. - _Upcoming breaking change_: Add support for using `actions/download-artifact@v4` to programmatically consume CodeQL Action debug artifacts.
Starting November 30, 2024, GitHub.com customers will [no longer be able to use `actions/download-artifact@v3`](https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/). Therefore, to avoid breakage, customers who programmatically download the CodeQL Action debug artifacts should set the `CODEQL_ACTION_ARTIFACT_V4_UPGRADE` environment variable to `true` and bump `actions/download-artifact@v3` to `actions/download-artifact@v4` in their workflows. The CodeQL Action will enable this behavior by default in early November and workflows that have not yet bumped `actions/download-artifact@v3` to `actions/download-artifact@v4` will begin failing then. Starting November 30, 2024, GitHub.com customers will [no longer be able to use `actions/download-artifact@v3`](https://github.blog/changelog/2024-04-16-deprecation-notice-v3-of-the-artifact-actions/). Therefore, to avoid breakage, customers who programmatically download the CodeQL Action debug artifacts should set the `CODEQL_ACTION_ARTIFACT_V4_UPGRADE` environment variable to `true` and bump `actions/download-artifact@v3` to `actions/download-artifact@v4` in their workflows. The CodeQL Action will enable this behavior by default in early November and workflows that have not yet bumped `actions/download-artifact@v3` to `actions/download-artifact@v4` will begin failing then.
This change is currently unavailable for GitHub Enterprise Server customers, as `actions/upload-artifact@v4` and `actions/download-artifact@v4` are not yet compatible with GHES. This change is currently unavailable for GitHub Enterprise Server customers, as `actions/upload-artifact@v4` and `actions/download-artifact@v4` are not yet compatible with GHES.
- Update default CodeQL bundle version to 2.19.1. [#2519](https://github.com/github/codeql-action/pull/2519) - Update default CodeQL bundle version to 2.19.1. [#2519](https://github.com/github/codeql-action/pull/2519)
@@ -518,9 +527,12 @@ No user facing changes.
## 3.25.0 - 15 Apr 2024 ## 3.25.0 - 15 Apr 2024
- The deprecated feature for extracting dependencies for a Python analysis has been removed. [#2224](https://github.com/github/codeql-action/pull/2224) - The deprecated feature for extracting dependencies for a Python analysis has been removed. [#2224](https://github.com/github/codeql-action/pull/2224)
As a result, the following inputs and environment variables are now ignored: As a result, the following inputs and environment variables are now ignored:
- The `setup-python-dependencies` input to the `init` Action - The `setup-python-dependencies` input to the `init` Action
- The `CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION` environment variable - The `CODEQL_ACTION_DISABLE_PYTHON_DEPENDENCY_INSTALLATION` environment variable
We recommend removing any references to these from your workflows. For more information, see the release notes for CodeQL Action v3.23.0 and v2.23.0. We recommend removing any references to these from your workflows. For more information, see the release notes for CodeQL Action v3.23.0 and v2.23.0.
- Automatically overwrite an existing database if found on the filesystem. [#2229](https://github.com/github/codeql-action/pull/2229) - Automatically overwrite an existing database if found on the filesystem. [#2229](https://github.com/github/codeql-action/pull/2229)
- Bump the minimum CodeQL bundle version to 2.12.6. [#2232](https://github.com/github/codeql-action/pull/2232) - Bump the minimum CodeQL bundle version to 2.12.6. [#2232](https://github.com/github/codeql-action/pull/2232)
+1 -1
View File
@@ -94,6 +94,6 @@ outputs:
sarif-id: sarif-id:
description: The ID of the uploaded SARIF file. description: The ID of the uploaded SARIF file.
runs: runs:
using: node20 using: node24
main: "../lib/analyze-action.js" main: "../lib/analyze-action.js"
post: "../lib/analyze-action-post.js" post: "../lib/analyze-action-post.js"
+1 -1
View File
@@ -15,5 +15,5 @@ inputs:
$GITHUB_WORKSPACE as its working directory. $GITHUB_WORKSPACE as its working directory.
required: false required: false
runs: runs:
using: node20 using: node24
main: '../lib/autobuild-action.js' main: '../lib/autobuild-action.js'
+1 -1
View File
@@ -170,6 +170,6 @@ outputs:
codeql-version: codeql-version:
description: The version of the CodeQL binary used for analysis description: The version of the CodeQL binary used for analysis
runs: runs:
using: node20 using: node24
main: '../lib/init-action.js' main: '../lib/init-action.js'
post: '../lib/init-action-post.js' post: '../lib/init-action-post.js'
+482 -35422
View File
File diff suppressed because one or more lines are too long
+421 -18598
View File
File diff suppressed because one or more lines are too long
+373 -18554
View File
File diff suppressed because one or more lines are too long
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"bundleVersion": "codeql-bundle-v2.25.3", "bundleVersion": "codeql-bundle-v2.25.4",
"cliVersion": "2.25.3", "cliVersion": "2.25.4",
"priorBundleVersion": "codeql-bundle-v2.25.2", "priorBundleVersion": "codeql-bundle-v2.25.3",
"priorCliVersion": "2.25.2" "priorCliVersion": "2.25.3"
} }
+486 -35426
View File
File diff suppressed because one or more lines are too long
+422 -18599
View File
File diff suppressed because one or more lines are too long
+371 -18552
View File
File diff suppressed because one or more lines are too long
+373 -18554
View File
File diff suppressed because one or more lines are too long
+482 -35422
View File
File diff suppressed because one or more lines are too long
+406 -18587
View File
File diff suppressed because one or more lines are too long
+373 -18554
View File
File diff suppressed because one or more lines are too long
+482 -35422
View File
File diff suppressed because one or more lines are too long
+373 -18554
View File
File diff suppressed because one or more lines are too long
+7 -35
View File
@@ -1,12 +1,12 @@
{ {
"name": "codeql", "name": "codeql",
"version": "4.35.3", "version": "4.35.4",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "codeql", "name": "codeql",
"version": "4.35.3", "version": "4.35.4",
"license": "MIT", "license": "MIT",
"workspaces": [ "workspaces": [
"pr-checks" "pr-checks"
@@ -410,15 +410,6 @@
"undici": "^6.23.0" "undici": "^6.23.0"
} }
}, },
"node_modules/@actions/github/node_modules/undici": {
"version": "6.23.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz",
"integrity": "sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/@actions/glob": { "node_modules/@actions/glob": {
"version": "0.5.1", "version": "0.5.1",
"resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.1.tgz", "resolved": "https://registry.npmjs.org/@actions/glob/-/glob-0.5.1.tgz",
@@ -439,15 +430,6 @@
"undici": "^6.23.0" "undici": "^6.23.0"
} }
}, },
"node_modules/@actions/http-client/node_modules/undici": {
"version": "6.23.0",
"resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz",
"integrity": "sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==",
"license": "MIT",
"engines": {
"node": ">=18.17"
}
},
"node_modules/@actions/io": { "node_modules/@actions/io": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/@actions/io/-/io-2.0.0.tgz", "resolved": "https://registry.npmjs.org/@actions/io/-/io-2.0.0.tgz",
@@ -1494,14 +1476,6 @@
"node": "^18.18.0 || ^20.9.0 || >=21.1.0" "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
} }
}, },
"node_modules/@fastify/busboy": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz",
"integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==",
"engines": {
"node": ">=14"
}
},
"node_modules/@github/browserslist-config": { "node_modules/@github/browserslist-config": {
"version": "1.0.0", "version": "1.0.0",
"dev": true, "dev": true,
@@ -9854,14 +9828,12 @@
} }
}, },
"node_modules/undici": { "node_modules/undici": {
"version": "5.29.0", "version": "6.24.1",
"resolved": "https://registry.npmjs.org/undici/-/undici-5.29.0.tgz", "resolved": "https://registry.npmjs.org/undici/-/undici-6.24.1.tgz",
"integrity": "sha512-raqeBD6NQK4SkWhQzeYKd1KmIG6dllBOTt55Rmkt4HtI9mwdWtJljnrXjAFUBLTSN67HWrOIZ3EPF4kjUw80Bg==", "integrity": "sha512-sC+b0tB1whOCzbtlx20fx3WgCXwkW627p4EA9uM+/tNNPkSS+eSEld6pAs9nDv7WbY1UUljBMYPtu9BCOrCWKA==",
"dependencies": { "license": "MIT",
"@fastify/busboy": "^2.0.0"
},
"engines": { "engines": {
"node": ">=14.0" "node": ">=18.17"
} }
}, },
"node_modules/undici-types": { "node_modules/undici-types": {
+3 -2
View File
@@ -1,6 +1,6 @@
{ {
"name": "codeql", "name": "codeql",
"version": "3.35.3", "version": "4.35.4",
"private": true, "private": true,
"description": "CodeQL action", "description": "CodeQL action",
"scripts": { "scripts": {
@@ -90,6 +90,7 @@
"semver": ">=6.3.1" "semver": ">=6.3.1"
}, },
"brace-expansion@2.0.1": "2.0.2", "brace-expansion@2.0.1": "2.0.2",
"glob": "^11.1.0" "glob": "^11.1.0",
"undici": "^6.24.0"
} }
} }
+1 -1
View File
@@ -5,7 +5,7 @@ versions:
- default - default
steps: steps:
- name: Set up Ruby - name: Set up Ruby
uses: ruby/setup-ruby@0cb964fd540e0a24c900370abf38a33466142735 # v1.305.0 uses: ruby/setup-ruby@c4e5b1316158f92e3d49443a9d58b31d25ac0f8f # v1.306.0
with: with:
ruby-version: 2.6 ruby-version: 2.6
- name: Install Code Scanning integration - name: Install Code Scanning integration
+1 -1
View File
@@ -21,5 +21,5 @@ outputs:
environment: environment:
description: The inferred build environment configuration. description: The inferred build environment configuration.
runs: runs:
using: node20 using: node24
main: '../lib/resolve-environment-action.js' main: '../lib/resolve-environment-action.js'
+1 -1
View File
@@ -35,5 +35,5 @@ outputs:
codeql-version: codeql-version:
description: The version of the CodeQL binary that was installed. description: The version of the CodeQL binary that was installed.
runs: runs:
using: node20 using: node24
main: '../lib/setup-codeql-action.js' main: '../lib/setup-codeql-action.js'
+22 -5
View File
@@ -128,6 +128,8 @@ export async function getGitHubVersionFromApi(
// Doesn't strictly have to be the meta endpoint as we're only // Doesn't strictly have to be the meta endpoint as we're only
// using the response headers which are available on every request. // using the response headers which are available on every request.
//
// See https://docs.github.com/en/rest/meta/meta#get-github-meta-information.
// eslint-disable-next-line @typescript-eslint/no-unsafe-call // eslint-disable-next-line @typescript-eslint/no-unsafe-call
const response = await apiClient.rest.meta.get(); const response = await apiClient.rest.meta.get();
@@ -164,6 +166,9 @@ export async function getGitHubVersion(): Promise<GitHubVersion> {
/** /**
* Get the path of the currently executing workflow relative to the repository root. * Get the path of the currently executing workflow relative to the repository root.
*
* See https://docs.github.com/en/rest/actions/workflow-runs#get-a-workflow-run
* and https://docs.github.com/en/rest/actions/workflows#get-a-workflow.
*/ */
export async function getWorkflowRelativePath(): Promise<string> { export async function getWorkflowRelativePath(): Promise<string> {
const repo_nwo = getRepositoryNwo(); const repo_nwo = getRepositoryNwo();
@@ -252,9 +257,13 @@ export interface ActionsCacheItem {
size_in_bytes?: number; size_in_bytes?: number;
} }
/** List all Actions cache entries matching the provided key and ref. */ /**
* List all Actions cache entries starting with the provided key prefix and matching the provided ref.
*
* See https://docs.github.com/en/rest/actions/cache#list-github-actions-caches-for-a-repository.
*/
export async function listActionsCaches( export async function listActionsCaches(
key: string, keyPrefix: string,
ref?: string, ref?: string,
): Promise<ActionsCacheItem[]> { ): Promise<ActionsCacheItem[]> {
const repositoryNwo = getRepositoryNwo(); const repositoryNwo = getRepositoryNwo();
@@ -264,13 +273,17 @@ export async function listActionsCaches(
{ {
owner: repositoryNwo.owner, owner: repositoryNwo.owner,
repo: repositoryNwo.repo, repo: repositoryNwo.repo,
key, key: keyPrefix,
ref, ref,
}, },
); );
} }
/** Delete an Actions cache item by its ID. */ /**
* Delete an Actions cache item by its ID.
*
* See https://docs.github.com/en/rest/actions/cache#delete-a-github-actions-cache-for-a-repository-using-a-cache-id.
*/
export async function deleteActionsCache(id: number) { export async function deleteActionsCache(id: number) {
const repositoryNwo = getRepositoryNwo(); const repositoryNwo = getRepositoryNwo();
@@ -281,7 +294,11 @@ export async function deleteActionsCache(id: number) {
}); });
} }
/** Retrieve all custom repository properties. */ /**
* Retrieve all custom repository properties.
*
* See https://docs.github.com/en/rest/repos/custom-properties#get-all-custom-property-values-for-a-repository.
*/
export async function getRepositoryProperties(repositoryNwo: RepositoryNwo) { export async function getRepositoryProperties(repositoryNwo: RepositoryNwo) {
return getApiClient().request("GET /repos/:owner/:repo/properties/values", { return getApiClient().request("GET /repos/:owner/:repo/properties/values", {
owner: repositoryNwo.owner, owner: repositoryNwo.owner,
+14 -25
View File
@@ -33,6 +33,7 @@ import {
mockBundleDownloadApi, mockBundleDownloadApi,
makeVersionInfo, makeVersionInfo,
createTestConfig, createTestConfig,
makeMacro,
} from "./testing-utils"; } from "./testing-utils";
import { ToolsDownloadStatusReport } from "./tools-download"; import { ToolsDownloadStatusReport } from "./tools-download";
import * as util from "./util"; import * as util from "./util";
@@ -540,7 +541,7 @@ test.serial("getExtraOptions throws for bad content", (t) => {
}); });
// Test macro for ensuring different variants of injected augmented configurations // Test macro for ensuring different variants of injected augmented configurations
const injectedConfigMacro = test.macro({ const injectedConfigMacro = makeMacro({
exec: async ( exec: async (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
augmentationProperties: AugmentationProperties, augmentationProperties: AugmentationProperties,
@@ -590,9 +591,8 @@ const injectedConfigMacro = test.macro({
`databaseInitCluster() injected config: ${providedTitle}`, `databaseInitCluster() injected config: ${providedTitle}`,
}); });
test.serial( injectedConfigMacro.serial(
"basic", "basic",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
}, },
@@ -600,9 +600,8 @@ test.serial(
{}, {},
); );
test.serial( injectedConfigMacro.serial(
"injected packs from input", "injected packs from input",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
packsInput: ["xxx", "yyy"], packsInput: ["xxx", "yyy"],
@@ -613,9 +612,8 @@ test.serial(
}, },
); );
test.serial( injectedConfigMacro.serial(
"injected packs from input with existing packs combines", "injected packs from input with existing packs combines",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
packsInputCombines: true, packsInputCombines: true,
@@ -635,9 +633,8 @@ test.serial(
}, },
); );
test.serial( injectedConfigMacro.serial(
"injected packs from input with existing packs overrides", "injected packs from input with existing packs overrides",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
packsInput: ["xxx", "yyy"], packsInput: ["xxx", "yyy"],
@@ -655,9 +652,8 @@ test.serial(
); );
// similar, but with queries // similar, but with queries
test.serial( injectedConfigMacro.serial(
"injected queries from input", "injected queries from input",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }], queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
@@ -675,9 +671,8 @@ test.serial(
}, },
); );
test.serial( injectedConfigMacro.serial(
"injected queries from input overrides", "injected queries from input overrides",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
queriesInput: [{ uses: "xxx" }, { uses: "yyy" }], queriesInput: [{ uses: "xxx" }, { uses: "yyy" }],
@@ -699,9 +694,8 @@ test.serial(
}, },
); );
test.serial( injectedConfigMacro.serial(
"injected queries from input combines", "injected queries from input combines",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
queriesInputCombines: true, queriesInputCombines: true,
@@ -727,9 +721,8 @@ test.serial(
}, },
); );
test.serial( injectedConfigMacro.serial(
"injected queries from input combines 2", "injected queries from input combines 2",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
queriesInputCombines: true, queriesInputCombines: true,
@@ -749,9 +742,8 @@ test.serial(
}, },
); );
test.serial( injectedConfigMacro.serial(
"injected queries and packs, but empty", "injected queries and packs, but empty",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
queriesInputCombines: true, queriesInputCombines: true,
@@ -768,9 +760,8 @@ test.serial(
{}, {},
); );
test.serial( injectedConfigMacro.serial(
"repo property queries have the highest precedence", "repo property queries have the highest precedence",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
queriesInputCombines: true, queriesInputCombines: true,
@@ -790,9 +781,8 @@ test.serial(
}, },
); );
test.serial( injectedConfigMacro.serial(
"repo property queries combines with queries input", "repo property queries combines with queries input",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
queriesInputCombines: false, queriesInputCombines: false,
@@ -817,9 +807,8 @@ test.serial(
}, },
); );
test.serial( injectedConfigMacro.serial(
"repo property queries combines everything else", "repo property queries combines everything else",
injectedConfigMacro,
{ {
...defaultAugmentationProperties, ...defaultAugmentationProperties,
queriesInputCombines: true, queriesInputCombines: true,
+60 -117
View File
@@ -34,6 +34,7 @@ import {
LoggedMessage, LoggedMessage,
mockCodeQLVersion, mockCodeQLVersion,
createTestConfig, createTestConfig,
makeMacro,
} from "./testing-utils"; } from "./testing-utils";
import { import {
GitHubVariant, GitHubVariant,
@@ -1034,10 +1035,9 @@ const defaultOverlayDatabaseModeTestSetup: OverlayDatabaseModeTestSetup = {
repositoryProperties: {}, repositoryProperties: {},
}; };
const checkOverlayEnablementMacro = test.macro({ const checkOverlayEnablementMacro = makeMacro({
exec: async ( exec: async (
t: ExecutionContext, t: ExecutionContext,
_title: string,
setupOverrides: Partial<OverlayDatabaseModeTestSetup>, setupOverrides: Partial<OverlayDatabaseModeTestSetup>,
expected: expected:
| { | {
@@ -1131,11 +1131,10 @@ const checkOverlayEnablementMacro = test.macro({
} }
}); });
}, },
title: (_, title) => `checkOverlayEnablement: ${title}`, title: (title) => `checkOverlayEnablement: ${title}`,
}); });
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Environment variable override - Overlay", "Environment variable override - Overlay",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1146,8 +1145,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Environment variable override - OverlayBase", "Environment variable override - OverlayBase",
{ {
overlayDatabaseEnvVar: "overlay-base", overlayDatabaseEnvVar: "overlay-base",
@@ -1158,8 +1156,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Environment variable override - None", "Environment variable override - None",
{ {
overlayDatabaseEnvVar: "none", overlayDatabaseEnvVar: "none",
@@ -1169,8 +1166,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Ignore invalid environment variable", "Ignore invalid environment variable",
{ {
overlayDatabaseEnvVar: "invalid-mode", overlayDatabaseEnvVar: "invalid-mode",
@@ -1180,8 +1176,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Ignore feature flag when analyzing non-default branch", "Ignore feature flag when analyzing non-default branch",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1192,8 +1187,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay-base database on default branch when feature enabled", "Overlay-base database on default branch when feature enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1206,8 +1200,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay-base database on default branch when feature enabled with custom analysis", "Overlay-base database on default branch when feature enabled with custom analysis",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1223,8 +1216,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay-base database on default branch when code-scanning feature enabled", "Overlay-base database on default branch when code-scanning feature enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1240,8 +1232,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch if runner disk space is too low", "No overlay-base database on default branch if runner disk space is too low",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1260,8 +1251,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch if we can't determine runner disk space", "No overlay-base database on default branch if we can't determine runner disk space",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1277,8 +1267,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay-base database on default branch if runner disk space is too low and skip resource checks flag is enabled", "Overlay-base database on default branch if runner disk space is too low and skip resource checks flag is enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1299,8 +1288,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch if runner disk space is below v2 limit and v2 resource checks enabled", "No overlay-base database on default branch if runner disk space is below v2 limit and v2 resource checks enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1320,8 +1308,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks enabled", "Overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1342,8 +1329,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks not enabled", "No overlay-base database on default branch if runner disk space is between v2 and v1 limits and v2 resource checks not enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1362,8 +1348,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch if memory flag is too low", "No overlay-base database on default branch if memory flag is too low",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1379,8 +1364,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay-base database on default branch if memory flag is too low but CodeQL >= 2.24.3", "Overlay-base database on default branch if memory flag is too low but CodeQL >= 2.24.3",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1398,8 +1382,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay-base database on default branch if memory flag is too low and skip resource checks flag is enabled", "Overlay-base database on default branch if memory flag is too low and skip resource checks flag is enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1417,8 +1400,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch when cached status indicates previous failure", "No overlay-base database on default branch when cached status indicates previous failure",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1435,8 +1417,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR when cached status indicates previous failure", "No overlay analysis on PR when cached status indicates previous failure",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1453,8 +1434,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch when code-scanning feature enabled with disable-default-queries", "No overlay-base database on default branch when code-scanning feature enabled with disable-default-queries",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1472,8 +1452,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch when code-scanning feature enabled with packs", "No overlay-base database on default branch when code-scanning feature enabled with packs",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1491,8 +1470,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch when code-scanning feature enabled with queries", "No overlay-base database on default branch when code-scanning feature enabled with queries",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1510,8 +1488,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch when code-scanning feature enabled with query-filters", "No overlay-base database on default branch when code-scanning feature enabled with query-filters",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1529,8 +1506,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch when only language-specific feature enabled", "No overlay-base database on default branch when only language-specific feature enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1542,8 +1518,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch when only code-scanning feature enabled", "No overlay-base database on default branch when only code-scanning feature enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1555,8 +1530,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay-base database on default branch when language-specific feature disabled", "No overlay-base database on default branch when language-specific feature disabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1568,8 +1542,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay analysis on PR when feature enabled", "Overlay analysis on PR when feature enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1582,8 +1555,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay analysis on PR when feature enabled with custom analysis", "Overlay analysis on PR when feature enabled with custom analysis",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1599,8 +1571,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay analysis on PR when code-scanning feature enabled", "Overlay analysis on PR when code-scanning feature enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1616,8 +1587,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR if runner disk space is too low", "No overlay analysis on PR if runner disk space is too low",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1636,8 +1606,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay analysis on PR if runner disk space is too low and skip resource checks flag is enabled", "Overlay analysis on PR if runner disk space is too low and skip resource checks flag is enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1658,8 +1627,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR if we can't determine runner disk space", "No overlay analysis on PR if we can't determine runner disk space",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1675,8 +1643,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR if memory flag is too low", "No overlay analysis on PR if memory flag is too low",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1692,8 +1659,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay analysis on PR if memory flag is too low but CodeQL >= 2.24.3", "Overlay analysis on PR if memory flag is too low but CodeQL >= 2.24.3",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1711,8 +1677,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay analysis on PR if memory flag is too low and skip resource checks flag is enabled", "Overlay analysis on PR if memory flag is too low and skip resource checks flag is enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1730,8 +1695,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR when code-scanning feature enabled with disable-default-queries", "No overlay analysis on PR when code-scanning feature enabled with disable-default-queries",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1749,8 +1713,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR when code-scanning feature enabled with packs", "No overlay analysis on PR when code-scanning feature enabled with packs",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1768,8 +1731,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR when code-scanning feature enabled with queries", "No overlay analysis on PR when code-scanning feature enabled with queries",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1787,8 +1749,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR when code-scanning feature enabled with query-filters", "No overlay analysis on PR when code-scanning feature enabled with query-filters",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1806,8 +1767,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR when only language-specific feature enabled", "No overlay analysis on PR when only language-specific feature enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1819,8 +1779,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR when only code-scanning feature enabled", "No overlay analysis on PR when only code-scanning feature enabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1832,8 +1791,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis on PR when language-specific feature disabled", "No overlay analysis on PR when language-specific feature disabled",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1845,8 +1803,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay PR analysis by env", "Overlay PR analysis by env",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1857,8 +1814,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay PR analysis by env on a runner with low disk space", "Overlay PR analysis by env on a runner with low disk space",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1870,8 +1826,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay PR analysis by feature flag", "Overlay PR analysis by feature flag",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1884,8 +1839,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Fallback due to autobuild with traced language", "Fallback due to autobuild with traced language",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1897,8 +1851,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Fallback due to no build mode with traced language", "Fallback due to no build mode with traced language",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1910,8 +1863,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Fallback due to old CodeQL version", "Fallback due to old CodeQL version",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1922,8 +1874,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Fallback due to missing git root", "Fallback due to missing git root",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1934,8 +1885,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Fallback due to old git version with submodules", "Fallback due to old git version with submodules",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1947,8 +1897,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Fallback when git version cannot be determined and repo has submodules", "Fallback when git version cannot be determined and repo has submodules",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1960,8 +1909,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay enabled when git version cannot be determined and repo has no submodules", "Overlay enabled when git version cannot be determined and repo has no submodules",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -1974,8 +1922,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay when disabled via repository property", "No overlay when disabled via repository property",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -1990,8 +1937,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Overlay not disabled when repository property is false", "Overlay not disabled when repository property is false",
{ {
languages: [BuiltInLanguage.javascript], languages: [BuiltInLanguage.javascript],
@@ -2007,8 +1953,7 @@ test.serial(
}, },
); );
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"Environment variable override takes precedence over repository property", "Environment variable override takes precedence over repository property",
{ {
overlayDatabaseEnvVar: "overlay", overlayDatabaseEnvVar: "overlay",
@@ -2024,8 +1969,7 @@ test.serial(
// Exercise language-specific overlay analysis features code paths // Exercise language-specific overlay analysis features code paths
for (const language in BuiltInLanguage) { for (const language in BuiltInLanguage) {
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
`Check default overlay analysis feature for ${language}`, `Check default overlay analysis feature for ${language}`,
{ {
languages: [language], languages: [language],
@@ -2042,8 +1986,7 @@ for (const language in BuiltInLanguage) {
// overlay analysis enabled, even when the base overlay feature flag is on. // overlay analysis enabled, even when the base overlay feature flag is on.
// Using swift here as it doesn't currently have overlay support — update this if // Using swift here as it doesn't currently have overlay support — update this if
// swift gains overlay support. // swift gains overlay support.
test.serial( checkOverlayEnablementMacro.serial(
checkOverlayEnablementMacro,
"No overlay analysis for language without per-language overlay feature flag", "No overlay analysis for language without per-language overlay feature flag",
{ {
languages: [BuiltInLanguage.swift], languages: [BuiltInLanguage.swift],
+48 -65
View File
@@ -7,6 +7,7 @@ import {
checkExpectedLogMessages, checkExpectedLogMessages,
getRecordingLogger, getRecordingLogger,
LoggedMessage, LoggedMessage,
makeMacro,
} from "../testing-utils"; } from "../testing-utils";
import { ConfigurationError, prettyPrintPack } from "../util"; import { ConfigurationError, prettyPrintPack } from "../util";
@@ -15,7 +16,7 @@ import * as dbConfig from "./db-config";
/** /**
* Test macro for ensuring the packs block is valid * Test macro for ensuring the packs block is valid
*/ */
const parsePacksMacro = test.macro({ const parsePacksMacro = makeMacro({
exec: ( exec: (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
packsInput: string, packsInput: string,
@@ -33,7 +34,7 @@ const parsePacksMacro = test.macro({
/** /**
* Test macro for testing when the packs block is invalid * Test macro for testing when the packs block is invalid
*/ */
const parsePacksErrorMacro = test.macro({ const parsePacksErrorMacro = makeMacro({
exec: ( exec: (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
packsInput: string, packsInput: string,
@@ -49,34 +50,32 @@ const parsePacksErrorMacro = test.macro({
/** /**
* Test macro for testing when the packs block is invalid * Test macro for testing when the packs block is invalid
*/ */
const invalidPackNameMacro = test.macro({ const invalidPackNameMacro = makeMacro({
exec: (t: ExecutionContext, name: string) => exec: (t: ExecutionContext, arg: string) =>
parsePacksErrorMacro.exec( parsePacksErrorMacro.fn(
t, t,
name, arg,
[BuiltInLanguage.cpp], [BuiltInLanguage.cpp],
new RegExp(`^"${name}" is not a valid pack$`), new RegExp(`^"${arg}" is not a valid pack$`),
), ),
title: (_providedTitle: string | undefined, arg: string | undefined) => title: (_providedTitle: string | undefined, arg: string | undefined) =>
`Invalid pack string: ${arg}`, `Invalid pack string: ${arg}`,
}); });
test("no packs", parsePacksMacro, "", [], undefined); parsePacksMacro("no packs", "", [], undefined);
test("two packs", parsePacksMacro, "a/b,c/d@1.2.3", [BuiltInLanguage.cpp], { parsePacksMacro("two packs", "a/b,c/d@1.2.3", [BuiltInLanguage.cpp], {
[BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"], [BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"],
}); });
test( parsePacksMacro(
"two packs with spaces", "two packs with spaces",
parsePacksMacro,
" a/b , c/d@1.2.3 ", " a/b , c/d@1.2.3 ",
[BuiltInLanguage.cpp], [BuiltInLanguage.cpp],
{ {
[BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"], [BuiltInLanguage.cpp]: ["a/b", "c/d@1.2.3"],
}, },
); );
test( parsePacksErrorMacro(
"two packs with language", "two packs with language",
parsePacksErrorMacro,
"a/b,c/d@1.2.3", "a/b,c/d@1.2.3",
[BuiltInLanguage.cpp, BuiltInLanguage.java], [BuiltInLanguage.cpp, BuiltInLanguage.java],
new RegExp( new RegExp(
@@ -85,9 +84,8 @@ test(
), ),
); );
test( parsePacksMacro(
"packs with other valid names", "packs with other valid names",
parsePacksMacro,
[ [
// ranges are ok // ranges are ok
"c/d@1.0", "c/d@1.0",
@@ -123,23 +121,23 @@ test(
}, },
); );
test(invalidPackNameMacro, "c"); // all packs require at least a scope and a name invalidPackNameMacro.test("c"); // all packs require at least a scope and a name
test(invalidPackNameMacro, "c-/d"); invalidPackNameMacro.test("c-/d");
test(invalidPackNameMacro, "-c/d"); invalidPackNameMacro.test("-c/d");
test(invalidPackNameMacro, "c/d_d"); invalidPackNameMacro.test("c/d_d");
test(invalidPackNameMacro, "c/d@@"); invalidPackNameMacro.test("c/d@@");
test(invalidPackNameMacro, "c/d@1.0.0:"); invalidPackNameMacro.test("c/d@1.0.0:");
test(invalidPackNameMacro, "c/d:"); invalidPackNameMacro.test("c/d:");
test(invalidPackNameMacro, "c/d:/a"); invalidPackNameMacro.test("c/d:/a");
test(invalidPackNameMacro, "@1.0.0:a"); invalidPackNameMacro.test("@1.0.0:a");
test(invalidPackNameMacro, "c/d@../a"); invalidPackNameMacro.test("c/d@../a");
test(invalidPackNameMacro, "c/d@b/../a"); invalidPackNameMacro.test("c/d@b/../a");
test(invalidPackNameMacro, "c/d:z@1"); invalidPackNameMacro.test("c/d:z@1");
/** /**
* Test macro for pretty printing pack specs * Test macro for pretty printing pack specs
*/ */
const packSpecPrettyPrintingMacro = test.macro({ const packSpecPrettyPrintingMacro = makeMacro({
exec: (t: ExecutionContext, packStr: string, packObj: dbConfig.Pack) => { exec: (t: ExecutionContext, packStr: string, packObj: dbConfig.Pack) => {
const parsed = dbConfig.parsePacksSpecification(packStr); const parsed = dbConfig.parsePacksSpecification(packStr);
t.deepEqual(parsed, packObj, "parsed pack spec is correct"); t.deepEqual(parsed, packObj, "parsed pack spec is correct");
@@ -163,36 +161,35 @@ const packSpecPrettyPrintingMacro = test.macro({
) => `Prettyprint pack spec: '${packStr}'`, ) => `Prettyprint pack spec: '${packStr}'`,
}); });
test(packSpecPrettyPrintingMacro, "a/b", { packSpecPrettyPrintingMacro.test("a/b", {
name: "a/b", name: "a/b",
version: undefined, version: undefined,
path: undefined, path: undefined,
}); });
test(packSpecPrettyPrintingMacro, "a/b@~1.2.3", { packSpecPrettyPrintingMacro.test("a/b@~1.2.3", {
name: "a/b", name: "a/b",
version: "~1.2.3", version: "~1.2.3",
path: undefined, path: undefined,
}); });
test(packSpecPrettyPrintingMacro, "a/b@~1.2.3:abc/def", { packSpecPrettyPrintingMacro.test("a/b@~1.2.3:abc/def", {
name: "a/b", name: "a/b",
version: "~1.2.3", version: "~1.2.3",
path: "abc/def", path: "abc/def",
}); });
test(packSpecPrettyPrintingMacro, "a/b:abc/def", { packSpecPrettyPrintingMacro.test("a/b:abc/def", {
name: "a/b", name: "a/b",
version: undefined, version: undefined,
path: "abc/def", path: "abc/def",
}); });
test(packSpecPrettyPrintingMacro, " a/b:abc/def ", { packSpecPrettyPrintingMacro.test(" a/b:abc/def ", {
name: "a/b", name: "a/b",
version: undefined, version: undefined,
path: "abc/def", path: "abc/def",
}); });
const calculateAugmentationMacro = test.macro({ const calculateAugmentationMacro = makeMacro({
exec: async ( exec: async (
t: ExecutionContext, t: ExecutionContext,
_title: string,
rawPacksInput: string | undefined, rawPacksInput: string | undefined,
rawQueriesInput: string | undefined, rawQueriesInput: string | undefined,
languages: Language[], languages: Language[],
@@ -207,11 +204,10 @@ const calculateAugmentationMacro = test.macro({
); );
t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties); t.deepEqual(actualAugmentationProperties, expectedAugmentationProperties);
}, },
title: (_, title) => `Calculate Augmentation: ${title}`, title: (title) => `Calculate Augmentation: ${title}`,
}); });
test( calculateAugmentationMacro(
calculateAugmentationMacro,
"All empty", "All empty",
undefined, undefined,
undefined, undefined,
@@ -222,8 +218,7 @@ test(
}, },
); );
test( calculateAugmentationMacro(
calculateAugmentationMacro,
"With queries", "With queries",
undefined, undefined,
" a, b , c, d", " a, b , c, d",
@@ -235,8 +230,7 @@ test(
}, },
); );
test( calculateAugmentationMacro(
calculateAugmentationMacro,
"With queries combining", "With queries combining",
undefined, undefined,
" + a, b , c, d ", " + a, b , c, d ",
@@ -249,8 +243,7 @@ test(
}, },
); );
test( calculateAugmentationMacro(
calculateAugmentationMacro,
"With packs", "With packs",
" codeql/a , codeql/b , codeql/c , codeql/d ", " codeql/a , codeql/b , codeql/c , codeql/d ",
undefined, undefined,
@@ -262,8 +255,7 @@ test(
}, },
); );
test( calculateAugmentationMacro(
calculateAugmentationMacro,
"With packs combining", "With packs combining",
" + codeql/a, codeql/b, codeql/c, codeql/d", " + codeql/a, codeql/b, codeql/c, codeql/d",
undefined, undefined,
@@ -276,8 +268,7 @@ test(
}, },
); );
test( calculateAugmentationMacro(
calculateAugmentationMacro,
"With repo property queries", "With repo property queries",
undefined, undefined,
undefined, undefined,
@@ -294,8 +285,7 @@ test(
}, },
); );
test( calculateAugmentationMacro(
calculateAugmentationMacro,
"With repo property queries combining", "With repo property queries combining",
undefined, undefined,
undefined, undefined,
@@ -312,10 +302,9 @@ test(
}, },
); );
const calculateAugmentationErrorMacro = test.macro({ const calculateAugmentationErrorMacro = makeMacro({
exec: async ( exec: async (
t: ExecutionContext, t: ExecutionContext,
_title: string,
rawPacksInput: string | undefined, rawPacksInput: string | undefined,
rawQueriesInput: string | undefined, rawQueriesInput: string | undefined,
languages: Language[], languages: Language[],
@@ -333,11 +322,10 @@ const calculateAugmentationErrorMacro = test.macro({
{ message: expectedError }, { message: expectedError },
); );
}, },
title: (_, title) => `Calculate Augmentation Error: ${title}`, title: (title) => `Calculate Augmentation Error: ${title}`,
}); });
test( calculateAugmentationErrorMacro(
calculateAugmentationErrorMacro,
"Plus (+) with nothing else (queries)", "Plus (+) with nothing else (queries)",
undefined, undefined,
" + ", " + ",
@@ -346,8 +334,7 @@ test(
/The workflow property "queries" is invalid/, /The workflow property "queries" is invalid/,
); );
test( calculateAugmentationErrorMacro(
calculateAugmentationErrorMacro,
"Plus (+) with nothing else (packs)", "Plus (+) with nothing else (packs)",
" + ", " + ",
undefined, undefined,
@@ -356,8 +343,7 @@ test(
/The workflow property "packs" is invalid/, /The workflow property "packs" is invalid/,
); );
test( calculateAugmentationErrorMacro(
calculateAugmentationErrorMacro,
"Plus (+) with nothing else (repo property queries)", "Plus (+) with nothing else (repo property queries)",
undefined, undefined,
undefined, undefined,
@@ -368,8 +354,7 @@ test(
/The repository property "github-codeql-extra-queries" is invalid/, /The repository property "github-codeql-extra-queries" is invalid/,
); );
test( calculateAugmentationErrorMacro(
calculateAugmentationErrorMacro,
"Packs input with multiple languages", "Packs input with multiple languages",
" + a/b, c/d ", " + a/b, c/d ",
undefined, undefined,
@@ -378,8 +363,7 @@ test(
/Cannot specify a 'packs' input in a multi-language analysis/, /Cannot specify a 'packs' input in a multi-language analysis/,
); );
test( calculateAugmentationErrorMacro(
calculateAugmentationErrorMacro,
"Packs input with no languages", "Packs input with no languages",
" + a/b, c/d ", " + a/b, c/d ",
undefined, undefined,
@@ -388,8 +372,7 @@ test(
/No languages specified/, /No languages specified/,
); );
test( calculateAugmentationErrorMacro(
calculateAugmentationErrorMacro,
"Invalid packs", "Invalid packs",
" a-pack-without-a-scope ", " a-pack-without-a-scope ",
undefined, undefined,
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"bundleVersion": "codeql-bundle-v2.25.3", "bundleVersion": "codeql-bundle-v2.25.4",
"cliVersion": "2.25.3", "cliVersion": "2.25.4",
"priorBundleVersion": "codeql-bundle-v2.25.2", "priorBundleVersion": "codeql-bundle-v2.25.3",
"priorCliVersion": "2.25.2" "priorCliVersion": "2.25.3"
} }
+12 -21
View File
@@ -16,6 +16,7 @@ import {
mockCodeQLVersion, mockCodeQLVersion,
mockFeatureFlagApiEndpoint, mockFeatureFlagApiEndpoint,
setupActionsVars, setupActionsVars,
makeMacro,
} from "./testing-utils"; } from "./testing-utils";
import { GitHubVariant, withTmpDir } from "./util"; import { GitHubVariant, withTmpDir } from "./util";
import type { GitHubVersion } from "./util"; import type { GitHubVersion } from "./util";
@@ -42,10 +43,9 @@ const defaultTestCase: DiffInformedAnalysisTestCase = {
codeQLVersion: "2.21.0", codeQLVersion: "2.21.0",
}; };
const testShouldPerformDiffInformedAnalysis = test.macro({ const testShouldPerformDiffInformedAnalysis = makeMacro({
exec: async ( exec: async (
t: ExecutionContext, t: ExecutionContext,
_title: string,
partialTestCase: Partial<DiffInformedAnalysisTestCase>, partialTestCase: Partial<DiffInformedAnalysisTestCase>,
expectedResult: boolean, expectedResult: boolean,
) => { ) => {
@@ -94,18 +94,16 @@ const testShouldPerformDiffInformedAnalysis = test.macro({
getPullRequestBranchesStub.restore(); getPullRequestBranchesStub.restore();
}); });
}, },
title: (_, title) => `shouldPerformDiffInformedAnalysis: ${title}`, title: (title) => `shouldPerformDiffInformedAnalysis: ${title}`,
}); });
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns true in the default test case", "returns true in the default test case",
{}, {},
true, true,
); );
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns false when feature flag is disabled from the API", "returns false when feature flag is disabled from the API",
{ {
featureEnabled: false, featureEnabled: false,
@@ -113,8 +111,7 @@ test.serial(
false, false,
); );
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns false when CODEQL_ACTION_DIFF_INFORMED_QUERIES is set to false", "returns false when CODEQL_ACTION_DIFF_INFORMED_QUERIES is set to false",
{ {
featureEnabled: true, featureEnabled: true,
@@ -123,8 +120,7 @@ test.serial(
false, false,
); );
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns true when CODEQL_ACTION_DIFF_INFORMED_QUERIES is set to true", "returns true when CODEQL_ACTION_DIFF_INFORMED_QUERIES is set to true",
{ {
featureEnabled: false, featureEnabled: false,
@@ -133,8 +129,7 @@ test.serial(
true, true,
); );
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns false for CodeQL version 2.20.0", "returns false for CodeQL version 2.20.0",
{ {
codeQLVersion: "2.20.0", codeQLVersion: "2.20.0",
@@ -142,8 +137,7 @@ test.serial(
false, false,
); );
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns false for invalid GHES version", "returns false for invalid GHES version",
{ {
gitHubVersion: { gitHubVersion: {
@@ -154,8 +148,7 @@ test.serial(
false, false,
); );
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns false for GHES version 3.18.5", "returns false for GHES version 3.18.5",
{ {
gitHubVersion: { gitHubVersion: {
@@ -166,8 +159,7 @@ test.serial(
false, false,
); );
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns true for GHES version 3.19.0", "returns true for GHES version 3.19.0",
{ {
gitHubVersion: { gitHubVersion: {
@@ -178,8 +170,7 @@ test.serial(
true, true,
); );
test.serial( testShouldPerformDiffInformedAnalysis.serial(
testShouldPerformDiffInformedAnalysis,
"returns false when not a pull request", "returns false when not a pull request",
{ {
pullRequestBranches: undefined, pullRequestBranches: undefined,
+5 -7
View File
@@ -19,6 +19,7 @@ import {
createFeatures, createFeatures,
createTestConfig, createTestConfig,
DEFAULT_ACTIONS_VARS, DEFAULT_ACTIONS_VARS,
makeMacro,
makeVersionInfo, makeVersionInfo,
RecordingLogger, RecordingLogger,
setupActionsVars, setupActionsVars,
@@ -796,7 +797,7 @@ test.serial(
}, },
); );
const skippedUploadTest = test.macro({ const skippedUploadTest = makeMacro({
exec: async ( exec: async (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
config: Partial<configUtils.Config>, config: Partial<configUtils.Config>,
@@ -823,9 +824,8 @@ const skippedUploadTest = test.macro({
`tryUploadSarifIfRunFailed - skips upload ${providedTitle}`, `tryUploadSarifIfRunFailed - skips upload ${providedTitle}`,
}); });
test.serial( skippedUploadTest.serial(
"without CodeQL command", "without CodeQL command",
skippedUploadTest,
// No codeQLCmd // No codeQLCmd
{ {
analysisKinds: [AnalysisKind.RiskAssessment], analysisKinds: [AnalysisKind.RiskAssessment],
@@ -834,9 +834,8 @@ test.serial(
"CodeQL command not found", "CodeQL command not found",
); );
test.serial( skippedUploadTest.serial(
"if no language is configured", "if no language is configured",
skippedUploadTest,
// No explicit language configuration // No explicit language configuration
{ {
analysisKinds: [AnalysisKind.RiskAssessment], analysisKinds: [AnalysisKind.RiskAssessment],
@@ -845,9 +844,8 @@ test.serial(
"Unexpectedly, the configuration is not for a single language.", "Unexpectedly, the configuration is not for a single language.",
); );
test.serial( skippedUploadTest.serial(
"if multiple languages is configured", "if multiple languages is configured",
skippedUploadTest,
// Multiple explicit languages configured // Multiple explicit languages configured
{ {
analysisKinds: [AnalysisKind.RiskAssessment], analysisKinds: [AnalysisKind.RiskAssessment],
+15 -27
View File
@@ -22,6 +22,7 @@ import {
createTestConfig, createTestConfig,
getRecordingLogger, getRecordingLogger,
setupTests, setupTests,
makeMacro,
} from "./testing-utils"; } from "./testing-utils";
import { ConfigurationError, withTmpDir } from "./util"; import { ConfigurationError, withTmpDir } from "./util";
@@ -158,10 +159,9 @@ type PackInfo = {
qlpackFileName?: string; qlpackFileName?: string;
}; };
const testCheckPacksForOverlayCompatibility = test.macro({ const testCheckPacksForOverlayCompatibility = makeMacro({
exec: async ( exec: async (
t: ExecutionContext, t: ExecutionContext,
_title: string,
{ {
cliOverlayVersion, cliOverlayVersion,
languages, languages,
@@ -234,11 +234,10 @@ const testCheckPacksForOverlayCompatibility = test.macro({
); );
}); });
}, },
title: (_, title) => `checkPacksForOverlayCompatibility: ${title}`, title: (title) => `checkPacksForOverlayCompatibility: ${title}`,
}); });
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns false when CLI does not support overlay", "returns false when CLI does not support overlay",
{ {
cliOverlayVersion: undefined, cliOverlayVersion: undefined,
@@ -253,8 +252,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns true when there are no query packs", "returns true when there are no query packs",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -264,8 +262,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns true when query pack has not been compiled", "returns true when query pack has not been compiled",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -281,8 +278,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns true when query pack has expected overlay version", "returns true when query pack has expected overlay version",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -297,8 +293,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns true when query packs for all languages to analyze are compatible", "returns true when query packs for all languages to analyze are compatible",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -317,8 +312,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns true when query pack for a language not analyzed is incompatible", "returns true when query pack for a language not analyzed is incompatible",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -337,8 +331,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns false when query pack for a language to analyze is incompatible", "returns false when query pack for a language to analyze is incompatible",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -357,8 +350,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns false when query pack is missing .packinfo", "returns false when query pack is missing .packinfo",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -377,8 +369,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns false when query pack has different overlay version", "returns false when query pack has different overlay version",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -397,8 +388,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns false when query pack is missing overlayVersion in .packinfo", "returns false when query pack is missing overlayVersion in .packinfo",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -417,8 +407,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns false when .packinfo is not valid JSON", "returns false when .packinfo is not valid JSON",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
@@ -437,8 +426,7 @@ test(
}, },
); );
test( testCheckPacksForOverlayCompatibility(
testCheckPacksForOverlayCompatibility,
"returns true when query pack uses codeql-pack.yml filename", "returns true when query pack uses codeql-pack.yml filename",
{ {
cliOverlayVersion: 2, cliOverlayVersion: 2,
+147 -26
View File
@@ -7,12 +7,13 @@ import * as sinon from "sinon";
import * as actionsUtil from "../actions-util"; import * as actionsUtil from "../actions-util";
import * as apiClient from "../api-client"; import * as apiClient from "../api-client";
import { ResolveDatabaseOutput } from "../codeql"; import type { ResolveDatabaseOutput } from "../codeql";
import * as gitUtils from "../git-utils"; import * as gitUtils from "../git-utils";
import { BuiltInLanguage } from "../languages"; import { BuiltInLanguage } from "../languages";
import { getRunnerLogger } from "../logging"; import { getRunnerLogger } from "../logging";
import { import {
createTestConfig, createTestConfig,
makeMacro,
mockCodeQLVersion, mockCodeQLVersion,
setupTests, setupTests,
} from "../testing-utils"; } from "../testing-utils";
@@ -23,6 +24,7 @@ import {
downloadOverlayBaseDatabaseFromCache, downloadOverlayBaseDatabaseFromCache,
getCacheRestoreKeyPrefix, getCacheRestoreKeyPrefix,
getCacheSaveKey, getCacheSaveKey,
getCodeQlVersionsForOverlayBaseDatabases,
} from "./caching"; } from "./caching";
import { OverlayDatabaseMode } from "./overlay-database-mode"; import { OverlayDatabaseMode } from "./overlay-database-mode";
@@ -50,10 +52,9 @@ const defaultDownloadTestCase: DownloadOverlayBaseDatabaseTestCase = {
resolveDatabaseOutput: { overlayBaseSpecifier: "20250626:XXX" }, resolveDatabaseOutput: { overlayBaseSpecifier: "20250626:XXX" },
}; };
const testDownloadOverlayBaseDatabaseFromCache = test.macro({ const testDownloadOverlayBaseDatabaseFromCache = makeMacro({
exec: async ( exec: async (
t, t,
_title: string,
partialTestCase: Partial<DownloadOverlayBaseDatabaseTestCase>, partialTestCase: Partial<DownloadOverlayBaseDatabaseTestCase>,
expectDownloadSuccess: boolean, expectDownloadSuccess: boolean,
) => { ) => {
@@ -141,18 +142,16 @@ const testDownloadOverlayBaseDatabaseFromCache = test.macro({
} }
}); });
}, },
title: (_, title) => `downloadOverlayBaseDatabaseFromCache: ${title}`, title: (title) => `downloadOverlayBaseDatabaseFromCache: ${title}`,
}); });
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns stats when successful", "returns stats when successful",
{}, {},
true, true,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when mode is OverlayDatabaseMode.OverlayBase", "returns undefined when mode is OverlayDatabaseMode.OverlayBase",
{ {
overlayDatabaseMode: OverlayDatabaseMode.OverlayBase, overlayDatabaseMode: OverlayDatabaseMode.OverlayBase,
@@ -160,8 +159,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when mode is OverlayDatabaseMode.None", "returns undefined when mode is OverlayDatabaseMode.None",
{ {
overlayDatabaseMode: OverlayDatabaseMode.None, overlayDatabaseMode: OverlayDatabaseMode.None,
@@ -169,8 +167,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when caching is disabled", "returns undefined when caching is disabled",
{ {
useOverlayDatabaseCaching: false, useOverlayDatabaseCaching: false,
@@ -178,8 +175,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined in test mode", "returns undefined in test mode",
{ {
isInTestMode: true, isInTestMode: true,
@@ -187,8 +183,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when cache miss", "returns undefined when cache miss",
{ {
restoreCacheResult: undefined, restoreCacheResult: undefined,
@@ -196,8 +191,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when download fails", "returns undefined when download fails",
{ {
restoreCacheResult: new Error("Download failed"), restoreCacheResult: new Error("Download failed"),
@@ -205,8 +199,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when downloaded database is invalid", "returns undefined when downloaded database is invalid",
{ {
hasBaseDatabaseOidsFile: false, hasBaseDatabaseOidsFile: false,
@@ -214,8 +207,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when downloaded database doesn't have an overlayBaseSpecifier", "returns undefined when downloaded database doesn't have an overlayBaseSpecifier",
{ {
resolveDatabaseOutput: {}, resolveDatabaseOutput: {},
@@ -223,8 +215,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when resolving database metadata fails", "returns undefined when resolving database metadata fails",
{ {
resolveDatabaseOutput: new Error("Failed to resolve database metadata"), resolveDatabaseOutput: new Error("Failed to resolve database metadata"),
@@ -232,8 +223,7 @@ test.serial(
false, false,
); );
test.serial( testDownloadOverlayBaseDatabaseFromCache.serial(
testDownloadOverlayBaseDatabaseFromCache,
"returns undefined when filesystem error occurs", "returns undefined when filesystem error occurs",
{ {
tryGetFolderBytesSucceeds: false, tryGetFolderBytesSucceeds: false,
@@ -285,3 +275,134 @@ test.serial("overlay-base database cache keys remain stable", async (t) => {
`Expected save key "${saveKey}" to start with restore key prefix "${restoreKeyPrefix}"`, `Expected save key "${saveKey}" to start with restore key prefix "${restoreKeyPrefix}"`,
); );
}); });
test.serial(
"getCodeQlVersionsForOverlayBaseDatabases returns unique versions sorted latest first",
async (t) => {
const logger = getRunnerLogger(true);
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
sinon.stub(apiClient, "listActionsCaches").resolves([
{
key: "codeql-overlay-base-database-1-c5666c509a2d9895-javascript_python-2.23.0-abc123-1-1",
},
{
key: "codeql-overlay-base-database-1-c5666c509a2d9895-javascript_python-2.24.1-def456-2-1",
},
{
key: "codeql-overlay-base-database-1-c5666c509a2d9895-javascript_python-2.23.0-ghi789-3-1",
},
]);
const result = await getCodeQlVersionsForOverlayBaseDatabases(
["javascript", "python"],
logger,
);
t.deepEqual(result, ["2.24.1", "2.23.0"]);
},
);
test.serial(
"getCodeQlVersionsForOverlayBaseDatabases returns empty list when no caches exist",
async (t) => {
const logger = getRunnerLogger(true);
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
sinon.stub(apiClient, "listActionsCaches").resolves([]);
const result = await getCodeQlVersionsForOverlayBaseDatabases(
["python"],
logger,
);
t.deepEqual(result, []);
},
);
test.serial(
"getCodeQlVersionsForOverlayBaseDatabases returns empty list when cache keys are unparseable",
async (t) => {
const logger = getRunnerLogger(true);
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
sinon.stub(apiClient, "listActionsCaches").resolves([
{
key: "codeql-overlay-base-database-1-c5666c509a2d9895-python-malformed",
},
{ key: undefined },
]);
const result = await getCodeQlVersionsForOverlayBaseDatabases(
["python"],
logger,
);
t.deepEqual(result, []);
},
);
test.serial(
"getCodeQlVersionsForOverlayBaseDatabases returns the single version when only one cache exists",
async (t) => {
const logger = getRunnerLogger(true);
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
sinon.stub(apiClient, "listActionsCaches").resolves([
{
key: "codeql-overlay-base-database-1-c5666c509a2d9895-cpp-2.25.0-abc123-1-1",
},
]);
const result = await getCodeQlVersionsForOverlayBaseDatabases(
["cpp"],
logger,
);
t.deepEqual(result, ["2.25.0"]);
},
);
test.serial(
"getCodeQlVersionsForOverlayBaseDatabases resolves language aliases",
async (t) => {
const logger = getRunnerLogger(true);
// The alias `c++` should be resolved to "cpp" and match cache entries keyed with "cpp"
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
sinon.stub(apiClient, "listActionsCaches").resolves([
{
key: "codeql-overlay-base-database-1-c5666c509a2d9895-cpp-2.25.0-abc123-1-1",
},
]);
const result = await getCodeQlVersionsForOverlayBaseDatabases(
["c++"],
logger,
);
t.deepEqual(result, ["2.25.0"]);
},
);
test.serial(
"getCodeQlVersionsForOverlayBaseDatabases ignores nightly versions with build metadata",
async (t) => {
const logger = getRunnerLogger(true);
sinon.stub(apiClient, "getAutomationID").resolves("test-automation-id/");
sinon.stub(apiClient, "listActionsCaches").resolves([
{
key: "codeql-overlay-base-database-1-c5666c509a2d9895-python-2.25.0-abc123-1-1",
},
{
// Nightly release with semver build metadata; should be ignored.
key: "codeql-overlay-base-database-1-c5666c509a2d9895-python-2.26.0+202604211234-def456-2-1",
},
{
key: "codeql-overlay-base-database-1-c5666c509a2d9895-python-2.24.0-ghi789-3-1",
},
]);
const result = await getCodeQlVersionsForOverlayBaseDatabases(
["python"],
logger,
);
t.deepEqual(result, ["2.25.0", "2.24.0"]);
},
);
+104 -12
View File
@@ -1,18 +1,20 @@
import * as fs from "fs"; import * as fs from "fs";
import * as actionsCache from "@actions/cache"; import * as actionsCache from "@actions/cache";
import * as semver from "semver";
import { import {
getRequiredInput, getRequiredInput,
getWorkflowRunAttempt, getWorkflowRunAttempt,
getWorkflowRunID, getWorkflowRunID,
} from "../actions-util"; } from "../actions-util";
import { getAutomationID } from "../api-client"; import { getAutomationID, listActionsCaches } from "../api-client";
import { createCacheKeyHash } from "../caching-utils"; import { createCacheKeyHash } from "../caching-utils";
import { type CodeQL } from "../codeql"; import { type CodeQL } from "../codeql";
import { type Config } from "../config-utils"; import { type Config } from "../config-utils";
import { getCommitOid } from "../git-utils"; import { getCommitOid } from "../git-utils";
import { Logger, withGroupAsync } from "../logging"; import { type Language, parseBuiltInLanguage } from "../languages";
import { type Logger, withGroupAsync } from "../logging";
import { import {
CleanupLevel, CleanupLevel,
getBaseDatabaseOidsFilePath, getBaseDatabaseOidsFilePath,
@@ -404,7 +406,17 @@ export async function getCacheRestoreKeyPrefix(
config: Config, config: Config,
codeQlVersion: string, codeQlVersion: string,
): Promise<string> { ): Promise<string> {
const languages = [...config.languages].sort().join("_"); return `${await getCacheKeyPrefixBase(config.languages)}${codeQlVersion}-`;
}
/**
* Computes the cache key prefix for overlay-base databases, excluding the
* CodeQL version.
*/
async function getCacheKeyPrefixBase(
parsedLanguages: Language[],
): Promise<string> {
const languagesComponent = [...parsedLanguages].sort().join("_");
const cacheKeyComponents = { const cacheKeyComponents = {
automationID: await getAutomationID(), automationID: await getAutomationID(),
@@ -412,17 +424,97 @@ export async function getCacheRestoreKeyPrefix(
}; };
const componentsHash = createCacheKeyHash(cacheKeyComponents); const componentsHash = createCacheKeyHash(cacheKeyComponents);
// For a cached overlay-base database to be considered compatible for overlay
// analysis, all components in the cache restore key must match:
//
// CACHE_PREFIX: distinguishes overlay-base databases from other cache objects // CACHE_PREFIX: distinguishes overlay-base databases from other cache objects
// CACHE_VERSION: cache format version // CACHE_VERSION: cache format version
// componentsHash: hash of additional components (see above for details) // componentsHash: hash of additional components (see above for details)
// languages: the languages included in the overlay-base database // languagesComponent: the languages included in the overlay-base database
// codeQlVersion: CodeQL bundle version
// //
// Technically we can also include languages and codeQlVersion in the // Technically we can also include languages in the componentsHash, but
// componentsHash, but including them explicitly in the cache key makes it // including them explicitly in the cache key makes it easier to debug and
// easier to debug and understand the cache key structure. // understand the cache key structure.
return `${CACHE_PREFIX}-${CACHE_VERSION}-${componentsHash}-${languages}-${codeQlVersion}-`; return `${CACHE_PREFIX}-${CACHE_VERSION}-${componentsHash}-${languagesComponent}-`;
}
/**
* Searches the GitHub Actions cache for overlay-base databases matching the given languages, and
* returns all stable CodeQL versions found across matching cache entries.
*
* Note that we do not guarantee that the cache entry for these versions of CodeQL will still be
* present by the time we attempt to restore the cache. We could achieve that with a download retry
* loop, but we expect that if there is sufficient Actions cache contention that an overlay-base
* cache entry for a particular CodeQL version is evicted before we can use it, then it is likely
* that the same thing will happen to other overlay-base cache entries, and therefore we will not be
* able to use overlay.
*
* @returns Unique stable CodeQL versions found in cached overlay-base databases, sorted from latest to
* earliest, or undefined if one of the languages is not a built-in language.
*/
export async function getCodeQlVersionsForOverlayBaseDatabases(
rawLanguages: string[],
logger: Logger,
): Promise<string[] | undefined> {
const languages = rawLanguages.map(parseBuiltInLanguage);
if (languages.includes(undefined)) {
logger.warning(
"One or more provided languages are not recognized as built-in languages. " +
"Skipping searching for overlay-base databases in cache.",
);
return undefined;
}
const cacheKeyPrefix = await getCacheKeyPrefixBase(
languages.filter((l) => l !== undefined),
);
logger.debug(
`Searching for overlay-base databases in Actions cache with ` +
`prefix ${cacheKeyPrefix}`,
);
const caches = await listActionsCaches(cacheKeyPrefix);
if (caches.length === 0) {
logger.info("No overlay-base databases found in Actions cache.");
return [];
}
logger.info(
`Found ${caches.length} overlay-base ` +
`${caches.length === 1 ? "database" : "databases"} in the Actions cache.`,
);
// Parse CodeQL versions from cache keys, matching only stable releases.
//
// After the prefix, the remaining key format starts with `${codeQlVersion}-`. Nightlies will have
// a suffix like `+202604201548` that will break the match.
//
// Caveat: this relies on the fact that we haven't released any CodeQL bundles with the
// `x.y.z-<pre-release>` semver format which does not interact well with the current overlay base
// DB cache key format.
const versionRegex = /^([\d.]+)-/;
const versionSet = new Set<string>();
for (const cache of caches) {
if (!cache.key) continue;
const suffix = cache.key.substring(cacheKeyPrefix.length);
const match = suffix.match(versionRegex);
if (match && semver.valid(match[1])) {
versionSet.add(match[1]);
}
}
if (versionSet.size === 0) {
logger.info(
"Could not parse any CodeQL versions from overlay-base database " +
"cache keys.",
);
return [];
}
const versions = [...versionSet].sort(semver.rcompare);
logger.info(
`Found overlay databases for the following CodeQL versions in the Actions cache: ${versions.join(", ")}`,
);
return versions;
} }
+5 -7
View File
@@ -20,6 +20,7 @@ import {
createFeatures, createFeatures,
getRecordingLogger, getRecordingLogger,
initializeFeatures, initializeFeatures,
makeMacro,
mockBundleDownloadApi, mockBundleDownloadApi,
setupActionsVars, setupActionsVars,
setupTests, setupTests,
@@ -473,7 +474,7 @@ test.serial(
}, },
); );
const toolcacheInputFallbackMacro = test.macro({ const toolcacheInputFallbackMacro = makeMacro({
exec: async ( exec: async (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
featureList: Feature[], featureList: Feature[],
@@ -533,9 +534,8 @@ const toolcacheInputFallbackMacro = test.macro({
`getCodeQLSource falls back to downloading the CLI if ${providedTitle}`, `getCodeQLSource falls back to downloading the CLI if ${providedTitle}`,
}); });
test.serial( toolcacheInputFallbackMacro.serial(
"the toolcache doesn't have a CodeQL CLI when tools == toolcache", "the toolcache doesn't have a CodeQL CLI when tools == toolcache",
toolcacheInputFallbackMacro,
[Feature.AllowToolcacheInput], [Feature.AllowToolcacheInput],
{ GITHUB_EVENT_NAME: "dynamic" }, { GITHUB_EVENT_NAME: "dynamic" },
[], [],
@@ -545,9 +545,8 @@ test.serial(
], ],
); );
test.serial( toolcacheInputFallbackMacro.serial(
"the workflow trigger is not `dynamic`", "the workflow trigger is not `dynamic`",
toolcacheInputFallbackMacro,
[Feature.AllowToolcacheInput], [Feature.AllowToolcacheInput],
{ GITHUB_EVENT_NAME: "pull_request" }, { GITHUB_EVENT_NAME: "pull_request" },
[], [],
@@ -556,9 +555,8 @@ test.serial(
], ],
); );
test.serial( toolcacheInputFallbackMacro.serial(
"the feature flag is not enabled", "the feature flag is not enabled",
toolcacheInputFallbackMacro,
[], [],
{ GITHUB_EVENT_NAME: "dynamic" }, { GITHUB_EVENT_NAME: "dynamic" },
[], [],
+14 -23
View File
@@ -18,6 +18,7 @@ import {
assertNotLogged, assertNotLogged,
checkExpectedLogMessages, checkExpectedLogMessages,
createFeatures, createFeatures,
makeMacro,
makeTestToken, makeTestToken,
RecordingLogger, RecordingLogger,
setupTests, setupTests,
@@ -32,7 +33,7 @@ import {
setupTests(test); setupTests(test);
const sendFailedStatusReportTest = test.macro({ const sendFailedStatusReportTest = makeMacro({
exec: async ( exec: async (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
err: Error, err: Error,
@@ -88,16 +89,14 @@ const sendFailedStatusReportTest = test.macro({
title: (providedTitle = "") => `sendFailedStatusReport - ${providedTitle}`, title: (providedTitle = "") => `sendFailedStatusReport - ${providedTitle}`,
}); });
test.serial( sendFailedStatusReportTest.serial(
"reports generic error message for non-StartProxyError error", "reports generic error message for non-StartProxyError error",
sendFailedStatusReportTest,
new Error("Something went wrong today"), new Error("Something went wrong today"),
"Error from start-proxy Action omitted (Error).", "Error from start-proxy Action omitted (Error).",
); );
test.serial( sendFailedStatusReportTest.serial(
"reports generic error message for non-StartProxyError error with safe error message", "reports generic error message for non-StartProxyError error with safe error message",
sendFailedStatusReportTest,
new Error( new Error(
startProxyExports.getStartProxyErrorMessage( startProxyExports.getStartProxyErrorMessage(
startProxyExports.StartProxyErrorType.DownloadFailed, startProxyExports.StartProxyErrorType.DownloadFailed,
@@ -106,9 +105,8 @@ test.serial(
"Error from start-proxy Action omitted (Error).", "Error from start-proxy Action omitted (Error).",
); );
test.serial( sendFailedStatusReportTest.serial(
"reports generic error message for ConfigurationError error", "reports generic error message for ConfigurationError error",
sendFailedStatusReportTest,
new ConfigurationError("Something went wrong today"), new ConfigurationError("Something went wrong today"),
"Error from start-proxy Action omitted (ConfigurationError).", "Error from start-proxy Action omitted (ConfigurationError).",
"user-error", "user-error",
@@ -414,7 +412,7 @@ test("getCredentials accepts OIDC configurations", (t) => {
} }
}); });
const getCredentialsMacro = test.macro({ const getCredentialsMacro = makeMacro({
exec: async ( exec: async (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
credentials: startProxyExports.RawCredential[], credentials: startProxyExports.RawCredential[],
@@ -440,9 +438,8 @@ const getCredentialsMacro = test.macro({
title: (providedTitle = "") => `getCredentials - ${providedTitle}`, title: (providedTitle = "") => `getCredentials - ${providedTitle}`,
}); });
test( getCredentialsMacro(
"warns for PAT-like password without a username", "warns for PAT-like password without a username",
getCredentialsMacro,
[ [
{ {
type: "git_server", type: "git_server",
@@ -470,9 +467,8 @@ test(
}, },
); );
test( getCredentialsMacro(
"no warning for PAT-like password with a username", "no warning for PAT-like password with a username",
getCredentialsMacro,
[ [
{ {
type: "git_server", type: "git_server",
@@ -502,9 +498,8 @@ test(
}, },
); );
test( getCredentialsMacro(
"warns for PAT-like token without a username", "warns for PAT-like token without a username",
getCredentialsMacro,
[ [
{ {
type: "git_server", type: "git_server",
@@ -532,9 +527,8 @@ test(
}, },
); );
test( getCredentialsMacro(
"no warning for PAT-like token with a username", "no warning for PAT-like token with a username",
getCredentialsMacro,
[ [
{ {
type: "git_server", type: "git_server",
@@ -796,7 +790,7 @@ test.serial(
}, },
); );
const wrapFailureTest = test.macro({ const wrapFailureTest = makeMacro({
exec: async ( exec: async (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
setup: () => void, setup: () => void,
@@ -827,9 +821,8 @@ test.serial("downloadProxy - returns file path on success", async (t) => {
}); });
}); });
test.serial( wrapFailureTest.serial(
"downloadProxy", "downloadProxy",
wrapFailureTest,
() => { () => {
sinon.stub(toolcache, "downloadTool").throws(); sinon.stub(toolcache, "downloadTool").throws();
}, },
@@ -848,9 +841,8 @@ test.serial("extractProxy - returns file path on success", async (t) => {
}); });
}); });
test.serial( wrapFailureTest.serial(
"extractProxy", "extractProxy",
wrapFailureTest,
() => { () => {
sinon.stub(toolcache, "extractTar").throws(); sinon.stub(toolcache, "extractTar").throws();
}, },
@@ -874,9 +866,8 @@ test.serial("cacheProxy - returns file path on success", async (t) => {
}); });
}); });
test.serial( wrapFailureTest.serial(
"cacheProxy", "cacheProxy",
wrapFailureTest,
() => { () => {
sinon.stub(toolcache, "cacheDir").throws(); sinon.stub(toolcache, "cacheDir").throws();
}, },
+6 -9
View File
@@ -19,6 +19,7 @@ import {
setupTests, setupTests,
setupActionsVars, setupActionsVars,
createTestConfig, createTestConfig,
makeMacro,
} from "./testing-utils"; } from "./testing-utils";
import { BuildMode, ConfigurationError, withTmpDir, wrapError } from "./util"; import { BuildMode, ConfigurationError, withTmpDir, wrapError } from "./util";
@@ -291,10 +292,9 @@ test.serial(
}, },
); );
const testCreateInitWithConfigStatusReport = test.macro({ const testCreateInitWithConfigStatusReport = makeMacro({
exec: async ( exec: async (
t, t,
_title: string,
config: Config, config: Config,
expectedReportProperties: Partial<InitWithConfigStatusReport>, expectedReportProperties: Partial<InitWithConfigStatusReport>,
) => { ) => {
@@ -337,11 +337,10 @@ const testCreateInitWithConfigStatusReport = test.macro({
} }
}); });
}, },
title: (_, title) => `createInitWithConfigStatusReport: ${title}`, title: (title) => `createInitWithConfigStatusReport: ${title}`,
}); });
test.serial( testCreateInitWithConfigStatusReport.serial(
testCreateInitWithConfigStatusReport,
"returns a value", "returns a value",
createTestConfig({ createTestConfig({
buildMode: BuildMode.None, buildMode: BuildMode.None,
@@ -355,8 +354,7 @@ test.serial(
}, },
); );
test.serial( testCreateInitWithConfigStatusReport.serial(
testCreateInitWithConfigStatusReport,
"includes packs for a single language", "includes packs for a single language",
createTestConfig({ createTestConfig({
buildMode: BuildMode.None, buildMode: BuildMode.None,
@@ -372,8 +370,7 @@ test.serial(
}, },
); );
test.serial( testCreateInitWithConfigStatusReport.serial(
testCreateInitWithConfigStatusReport,
"includes packs for multiple languages", "includes packs for multiple languages",
createTestConfig({ createTestConfig({
buildMode: BuildMode.None, buildMode: BuildMode.None,
+27 -3
View File
@@ -2,7 +2,11 @@ import { TextDecoder } from "node:util";
import path from "path"; import path from "path";
import * as github from "@actions/github"; import * as github from "@actions/github";
import { ExecutionContext, TestFn } from "ava"; import test, {
type ExecutionContext,
type MacroDeclarationOptions,
type TestFn,
} from "ava";
import nock from "nock"; import nock from "nock";
import * as sinon from "sinon"; import * as sinon from "sinon";
@@ -85,8 +89,8 @@ function wrapOutput(context: TestContext) {
}; };
} }
export function setupTests(test: TestFn<any>) { export function setupTests(testFn: TestFn<any>) {
const typedTest = test as TestFn<TestContext>; const typedTest = testFn as TestFn<TestContext>;
typedTest.beforeEach((t) => { typedTest.beforeEach((t) => {
// Set an empty CodeQL object so that all method calls will fail // Set an empty CodeQL object so that all method calls will fail
@@ -139,6 +143,26 @@ export function setupTests(test: TestFn<any>) {
}); });
} }
/**
* Declare a reusable test implementation, with better type safety than `test.macro`.
*/
export function makeMacro<Args extends unknown[]>(
decl: MacroDeclarationOptions<Args, unknown>,
) {
const m = test.macro<Args>(decl);
const wrapper = (name: string, ...args: Args) => test(name, m, ...args);
wrapper.test = (...args: Args) => test(m, ...args);
wrapper.serial = (name: string, ...args: Args) =>
test.serial(name, m, ...args);
// Make the implementation available as `fn`. We don't call it `exec` so
// that results from this function are not valid arguments to `test`
// or `test.serial`.
wrapper.fn = decl.exec;
return wrapper;
}
/** /**
* Default values for environment variables typically set in an Actions * Default values for environment variables typically set in an Actions
* environment. Tests can override individual variables by passing them in the * environment. Tests can override individual variables by passing them in the
+7 -12
View File
@@ -6,7 +6,7 @@ import * as sinon from "sinon";
import { AnalysisKind, getAnalysisConfig } from "./analyses"; import { AnalysisKind, getAnalysisConfig } from "./analyses";
import { getRunnerLogger } from "./logging"; import { getRunnerLogger } from "./logging";
import { createFeatures, setupTests } from "./testing-utils"; import { createFeatures, makeMacro, setupTests } from "./testing-utils";
import { UploadResult } from "./upload-lib"; import { UploadResult } from "./upload-lib";
import * as uploadLib from "./upload-lib"; import * as uploadLib from "./upload-lib";
import { postProcessAndUploadSarif } from "./upload-sarif"; import { postProcessAndUploadSarif } from "./upload-sarif";
@@ -43,7 +43,7 @@ function mockPostProcessSarifFiles() {
return postProcessSarifFiles; return postProcessSarifFiles;
} }
const postProcessAndUploadSarifMacro = test.macro({ const postProcessAndUploadSarifMacro = makeMacro({
exec: async ( exec: async (
t: ExecutionContext<unknown>, t: ExecutionContext<unknown>,
sarifFiles: string[], sarifFiles: string[],
@@ -123,9 +123,8 @@ const postProcessAndUploadSarifMacro = test.macro({
title: (providedTitle = "") => `processAndUploadSarif - ${providedTitle}`, title: (providedTitle = "") => `processAndUploadSarif - ${providedTitle}`,
}); });
test.serial( postProcessAndUploadSarifMacro.serial(
"SARIF file", "SARIF file",
postProcessAndUploadSarifMacro,
["test.sarif"], ["test.sarif"],
(tempDir) => path.join(tempDir, "test.sarif"), (tempDir) => path.join(tempDir, "test.sarif"),
{ {
@@ -138,9 +137,8 @@ test.serial(
}, },
); );
test.serial( postProcessAndUploadSarifMacro.serial(
"JSON file", "JSON file",
postProcessAndUploadSarifMacro,
["test.json"], ["test.json"],
(tempDir) => path.join(tempDir, "test.json"), (tempDir) => path.join(tempDir, "test.json"),
{ {
@@ -153,9 +151,8 @@ test.serial(
}, },
); );
test.serial( postProcessAndUploadSarifMacro.serial(
"Code Scanning files", "Code Scanning files",
postProcessAndUploadSarifMacro,
["test.json", "test.sarif"], ["test.json", "test.sarif"],
undefined, undefined,
{ {
@@ -169,9 +166,8 @@ test.serial(
}, },
); );
test.serial( postProcessAndUploadSarifMacro.serial(
"Code Quality file", "Code Quality file",
postProcessAndUploadSarifMacro,
["test.quality.sarif"], ["test.quality.sarif"],
(tempDir) => path.join(tempDir, "test.quality.sarif"), (tempDir) => path.join(tempDir, "test.quality.sarif"),
{ {
@@ -184,9 +180,8 @@ test.serial(
}, },
); );
test.serial( postProcessAndUploadSarifMacro.serial(
"Mixed files", "Mixed files",
postProcessAndUploadSarifMacro,
["test.sarif", "test.quality.sarif"], ["test.sarif", "test.quality.sarif"],
undefined, undefined,
{ {
+1 -1
View File
@@ -29,6 +29,6 @@ outputs:
proxy_urls: proxy_urls:
description: A stringified JSON array of objects containing the types and URLs of the configured registries. description: A stringified JSON array of objects containing the types and URLs of the configured registries.
runs: runs:
using: node20 using: node24
main: "../lib/start-proxy-action.js" main: "../lib/start-proxy-action.js"
post: "../lib/start-proxy-action-post.js" post: "../lib/start-proxy-action-post.js"
+1 -1
View File
@@ -41,6 +41,6 @@ outputs:
{ "code-scanning": "some-id", "code-quality": "some-other-id" } { "code-scanning": "some-id", "code-quality": "some-other-id" }
runs: runs:
using: node20 using: node24
main: '../lib/upload-sarif-action.js' main: '../lib/upload-sarif-action.js'
post: '../lib/upload-sarif-action-post.js' post: '../lib/upload-sarif-action-post.js'