Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor C# cache content paths into a function
  • Loading branch information
mbg committed Nov 13, 2025
commit cf8b7a6e14d039e1cb0f7b5afbe0f2830bab2c11
5 changes: 4 additions & 1 deletion lib/analyze-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion src/dependency-caching.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ export function getJavaDependencyDirs(): string[] {
];
}

/**
* 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.
Comment on lines +82 to +86
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit, here and elsewhere: avoid duplicating doc comments by just keeping the @returns paragraph.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Probably not worth the effort of changing here, but happy to reduce duplication going forward.

*/
Comment on lines +81 to +87
Copy link

Copilot AI Nov 13, 2025

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.

Copilot uses AI. Check for mistakes.
export function getCsharpDependencyDirs(): string[] {
return [join(os.homedir(), ".nuget", "packages")];
}

/**
* Checks that there are files which match `patterns`. If there are matching files for any of the patterns,
* this function returns all `patterns`. Otherwise, `undefined` is returned.
Expand Down Expand Up @@ -158,7 +169,7 @@ const defaultCacheConfigs: { [language: string]: CacheConfig } = {
]),
},
csharp: {
getDependencyPaths: () => [join(os.homedir(), ".nuget", "packages")],
getDependencyPaths: getCsharpDependencyDirs,
getHashPatterns: getCsharpHashPatterns,
},
go: {
Expand Down