Skip to content

Conversation

mbg
Copy link
Member

@mbg mbg commented Oct 3, 2025

Allows toolcache as a possible input for tools. Useful if you don't necessarily care about the a specific version of CodeQL and care more about having it readily available on the runner.

Risk assessment

For internal use only. Please select the risk level of this change:

  • Low risk: Changes are fully under feature flags, or have been fully tested and validated in pre-production environments and are highly observable, or are documentation or test only.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Consider adding a changelog entry for this change.
  • Confirm the readme and docs have been updated if necessary.

@mbg
Copy link
Member Author

mbg commented Oct 3, 2025

https://github.com/github/codeql-action/actions/runs/18225669790/job/51896145459#step:6:28 is a run of the new PR check with tools: toolcache working as expected.

Comment on lines +8 to +22
- name: Check toolcache contains CodeQL
continue-on-error: true
uses: actions/github-script@v8
with:
script: |
const toolcache = require('@actions/tool-cache');
const allCodeqlVersions = toolcache.findAllVersions('CodeQL');
if (allCodeqlVersions.length === 0) {
throw new Error(`CodeQL could not be found in the toolcache`);
}
- id: init
uses: ./../action/init
with:
languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have set continue-on-error: true here since I didn't want to depend on the CLI always being available in the toolcache. In general, I am happy for this check to just exercise that the workflow generally works if tools: toolcache, but perhaps we could post a comment on the PR if no CLI was found in the toolcache?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably depend on CodeQL being available in the toolcache.

@mbg mbg marked this pull request as ready for review October 3, 2025 15:33
@mbg mbg requested a review from a team as a code owner October 3, 2025 15:33
@mbg mbg requested review from Copilot and henrymercer October 3, 2025 15:34
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for requesting the latest version from the toolcache using tools: toolcache. This feature allows users to leverage any CodeQL CLI version already cached in the runner's toolcache instead of downloading or using a specific version.

Key changes include:

  • Adds a new "toolcache" option for the tools parameter that finds the latest available version in the toolcache
  • Implements fallback behavior to download the default version if no CodeQL CLI is found in the toolcache
  • Updates documentation and test configuration to support the new option

Reviewed Changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/setup-codeql.ts Adds toolcache logic and getLatestToolcacheVersion function
src/setup-codeql.test.ts Comprehensive test coverage for toolcache functionality
pr-checks/checks/bundle-from-toolcache.yml New test configuration for toolcache functionality
init/action.yml Documentation update for new toolcache option
.github/actions/prepare-test/action.yml Support for toolcache in test preparation
lib/*.js Generated JavaScript code (auto-generated, not reviewed per guidelines)
.github/workflows/__bundle-from-toolcache.yml Generated workflow file (auto-generated, not reviewed per guidelines)

Copy link
Contributor

@henrymercer henrymercer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not against having the ability to request tools from the toolcache for internal testing purposes for instance. However we need to make it very clear that this will cause alerts to open and close repeatedly while new runner images roll out (a period of about half a day or so every two weeks). For this reason, this is an option we're unlikely to want to recommend.

Do you have a particular use case in mind?

@mbg mbg requested a review from henrymercer October 6, 2025 12:23
Comment on lines +8 to +22
- name: Check toolcache contains CodeQL
continue-on-error: true
uses: actions/github-script@v8
with:
script: |
const toolcache = require('@actions/tool-cache');
const allCodeqlVersions = toolcache.findAllVersions('CodeQL');
if (allCodeqlVersions.length === 0) {
throw new Error(`CodeQL could not be found in the toolcache`);
}
- id: init
uses: ./../action/init
with:
languages: javascript
tools: ${{ steps.prepare-test.outputs.tools-url }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can probably depend on CodeQL being available in the toolcache.

@mbg mbg enabled auto-merge October 7, 2025 09:09
@mbg mbg merged commit 2f11c17 into main Oct 7, 2025
258 of 259 checks passed
@mbg mbg deleted the mbg/setup/toolcache branch October 7, 2025 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants