Support requesting latest version from toolcache with tools: toolcache#3175
Support requesting latest version from toolcache with tools: toolcache#3175
tools: toolcache#3175Conversation
|
https://github.com/github/codeql-action/actions/runs/18225669790/job/51896145459#step:6:28 is a run of the new PR check with |
| - 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 }} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
I think we can probably depend on CodeQL being available in the toolcache.
There was a problem hiding this comment.
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 thetoolsparameter 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) |
There was a problem hiding this comment.
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?
| - 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 }} |
There was a problem hiding this comment.
I think we can probably depend on CodeQL being available in the toolcache.
Allows
toolcacheas a possible input fortools. 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:
Merge / deployment checklist