Skip to content

Commit 880864b

Browse files
subatoimbgam-stead
authored
Improved performance and reliability for code scanning with CodeQL by implementing dependency caching [GA] (#53094)
Co-authored-by: Michael B. Gale <[email protected]> Co-authored-by: Anne-Marie <[email protected]>
1 parent ca3f79f commit 880864b

File tree

3 files changed

+49
-0
lines changed

3 files changed

+49
-0
lines changed

Diff for: content/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages.md

+41
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ The basic {% data variables.code-scanning.codeql_workflow %} uses the `autobuild
5050

5151
{% endif %}
5252

53+
{% ifversion codeql-dependency-caching %}
54+
55+
You can use dependency caching with {% data variables.product.prodname_codeql %} to store dependencies as a {% data variables.product.prodname_actions %} cache instead of downloading them from registries. For more information, see "[About dependency caching for {% data variables.product.prodname_codeql %}](#about-dependency-caching-for-codeql)" later in this article.
56+
57+
{% endif %}
58+
5359
{% ifversion codeql-no-build %}
5460

5561
## {% data variables.product.prodname_codeql %} build modes
@@ -118,6 +124,41 @@ steps:
118124
119125
For information about the languages, libraries, and frameworks that are supported in the latest version of {% data variables.product.prodname_codeql %}, see "[Supported languages and frameworks](https://codeql.github.com/docs/codeql-overview/supported-languages-and-frameworks)" in the {% data variables.product.prodname_codeql %} documentation. For information about the system requirements for running the latest version of {% data variables.product.prodname_codeql %}, see "[System requirements](https://codeql.github.com/docs/codeql-overview/system-requirements/#additional-software-requirements)" in the {% data variables.product.prodname_codeql %} documentation.
120126
127+
{% ifversion codeql-dependency-caching %}
128+
129+
## About dependency caching for {% data variables.product.prodname_codeql %}
130+
131+
You can use dependency caching with {% data variables.product.prodname_codeql %} to store dependencies as a {% data variables.product.prodname_actions %} cache instead of downloading them from registries. This reduces the risk of losing alerts when third party registries don't work well, and may result in a performance improvement for projects that have a large number of dependencies or work with slow registries. To read more about how caching dependencies can speed up workflows, see "[AUTOTITLE](/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows)."
132+
133+
Dependency caching works with all build modes, and is supported by {% data variables.code-scanning.codeql_dependency_caching_languages %}.
134+
135+
>[!NOTE]
136+
> Using dependency caching will store {% data variables.product.prodname_codeql %}-specific caches that will be subject to cache quotas for a repository. See "[AUTOTITLE](/actions/writing-workflows/choosing-what-your-workflow-does/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy)."
137+
138+
### Enabling dependency caching for {% data variables.product.prodname_codeql %}
139+
140+
For default setup workflows, dependency caching is enabled by default for {% data variables.product.github %}-hosted runners in public repositories.
141+
142+
For advanced setup workflows, dependency caching is disabled by default. To enable dependency caching for {% data variables.product.prodname_codeql %}, use the `dependency-caching` setting for the {% data variables.product.prodname_codeql %} action in your advanced setup workflow. This setting accepts the following values:
143+
144+
* `false`/`none`/`off`: Dependency caching is disabled (default)
145+
* `restore`: Only restore existing caches, do not store new caches
146+
* `store`: Only store new caches, do not restore existing caches
147+
* `true`/`full`/`on`: Restore existing caches, and store new caches
148+
149+
For example, the following settings would enable dependency caching for the {% data variables.product.prodname_codeql %} action:
150+
151+
```yaml
152+
# Initializes CodeQL with dependency caching enabled
153+
- name: Initialize CodeQL
154+
uses: {% data reusables.actions.action-codeql-action-init %}
155+
with:
156+
languages: java
157+
dependency-caching: true
158+
```
159+
160+
{% endif %}
161+
121162
{% ifversion codeql-no-build %}
122163

123164
## About build mode None for {% data variables.product.prodname_codeql %}

Diff for: data/features/codeql-dependency-caching.yml

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Reference #16278
2+
versions:
3+
fpt: '*'
4+
ghec: '*'
5+
ghes: '>3.15'

Diff for: data/variables/code-scanning.yml

+3
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ code_scanning_threat_model_support: 'Java/Kotlin{% ifversion fpt or ghec or ghes
2020

2121
# List of languages that Copilot Autofix Agent supports
2222
codeql_autofix_languages: ' C#, C/C++, Go, Java/Kotlin, Swift, JavaScript/TypeScript, Python, and Ruby'
23+
24+
# List of languages that CodeQL dependency caching supports
25+
codeql_dependency_caching_languages: 'Java, Go, and C#'

0 commit comments

Comments
 (0)