-
Notifications
You must be signed in to change notification settings - Fork 421
C#: Cache temporary dependency directory for BMN #3286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
And also clean it up.
There was a problem hiding this 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 extends dependency caching for C# build-mode: none analysis by configuring a stable temporary directory path for the C# extractor, similar to the existing Java implementation. The feature is controlled by the CsharpCacheBuildModeNone feature flag and is designed to be safe to merge before the corresponding C# extractor support is available.
Key changes:
- Added new feature flag
CsharpCacheBuildModeNonewith environment variableCODEQL_ACTION_CSHARP_CACHE_BMN - Implemented C# dependency directory caching with conditional inclusion based on feature flag
- Extended cleanup logic to remove C# temporary dependency directories alongside Java directories
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/feature-flags.ts | Adds the CsharpCacheBuildModeNone feature flag configuration |
| src/dependency-caching.ts | Implements getCsharpTempDependencyDir() and getCsharpDependencyDirs() functions, updates getDependencyPaths signature to be async, and includes the feature in the cache key hash |
| src/dependency-caching.test.ts | Adds tests verifying C# dependency directory inclusion based on feature flag state, and tests for feature prefix generation |
| src/analyze.ts | Sets CODEQL_EXTRACTOR_CSHARP_OPTION_BUILDLESS_DEPENDENCY_DIR environment variable when feature is enabled for C# build-mode: none, and threads features parameter through extraction functions |
| src/analyze-action.ts | Passes features parameter to runFinalize() |
| src/analyze-action-post.ts | Extends cleanup logic to remove both Java and C# temporary dependency directories |
| src/analyze-action-input.test.ts | Updates test assertions to account for new features parameter in runFinalize() |
| src/analyze-action-env.test.ts | Updates test assertions to account for new features parameter in runFinalize() |
| lib/*.js | Generated JavaScript files reflecting TypeScript changes |
| /** | ||
| * Returns an array of paths of directories on the runner that should be included in a dependency cache | ||
| * for a C# analysis. | ||
| * | ||
| * @returns The paths of directories on the runner that should be included in a dependency cache | ||
| * for a C# analysis. | ||
| */ |
Copilot
AI
Nov 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider adding a note similar to the one in getJavaDependencyDirs documentation (lines 54-56) explaining why this needs to be a function: "It is important that this is a function, because we call getTemporaryDirectory which would otherwise fail in tests if we haven't had a chance to initialise RUNNER_TEMP." This would improve consistency and help future maintainers understand the design decision.
|
@mbg : If the action only requires being able to communicate the dependency directory via an environment variable - then maybe we shouldn't expose the functionality as an extractor option? |
I have no strong feelings about this and just mirrored what we did for the Java extractor. IIRC the team there explicitly suggested making it an extractor option. Personally, I see no harm in it being an extractor option, but I am happy for you to make that decision and just let me know what environment variable we should set here |
Let's do the same as for Java for consistency. |
michaelnebel
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks plausible to me, but it is probably a good idea to a get a review from someone that knows more about the actions code.
Follow-up from #3117. This PR extends the paths we cache for C# BMN with a similar solution as for Java BMN by configuring a particular, stable path for the extractor to store dependencies in.
There are four key parts to this:
This change depends on support for the
CODEQL_EXTRACTOR_CSHARP_OPTION_BUILDLESS_DEPENDENCY_DIRenvironment variable in the C# extractor, but is designed to be safe to merge as-is before that is available.Risk assessment
For internal use only. Please select the risk level of this change:
Which use cases does this change impact?
analysis-kinds: code-scanning).analysis-kinds: code-quality).How did/will you validate this change?
.test.tsfiles).pr-checks).If something goes wrong after this change is released, what are the mitigation and rollback strategies?
How will you know if something goes wrong after this change is released?
Merge / deployment checklist