Skip to content

Conversation

@dennisdoomen
Copy link
Owner

@dennisdoomen dennisdoomen commented Jul 3, 2025

Introduces a package caching mechanism to speed up future analysis in the system. It allows caching of license information and other package metadata, saving it to a default location or a user-specified path, so that subsequent runs can leverage this cached data, reducing the overhead of fetching the same information repeatedly. T

Several additions were made to configuration files, build scripts, and command-line options, such as the --use-caching flag for enabling caching and --cache-file-path for specifying the cache file location. These changes aim to optimize performance, streamline processes, and improve usability when working on multiple or repeated project analyses. PackageGuard

Closes #44

@github-actions
Copy link

github-actions bot commented Jul 3, 2025

Test Results

42 tests  +4   42 ✅ +4   33s ⏱️ +2s
 2 suites ±0    0 💤 ±0 
 2 files   ±0    0 ❌ ±0 

Results for commit 807bcec. ± Comparison against base commit 2344d84.

This pull request removes 4 and adds 8 tests. Note that renamed tests count towards both.
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ A_package_version_inside_the_allowed_range_is_okay
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ A_package_version_outside_the_allowed_range_is_a_violation
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ Can_allow_a_package_that_violates_the_allowed_licenses
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ Specifying_a_specific_project_file_requires_it_to_exist
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ A_specified_project_must_exist
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ A_version_inside_the_allowed_range_is_okay
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ A_version_outside_the_allowed_range_is_a_violation
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ Can_reuse_a_cache_from_an_earlier_run
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ Can_still_allow_a_package_that_violates_the_allowed_licenses
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ Creates_a_cache_at_a_specific_path_if_asked_for
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ Creates_a_cache_if_asked_for
PackageGuard.Specs.CSharpProjectAnalyzerSpecs ‑ Will_ignore_a_corrupt_cache

♻️ This comment has been updated with latest results.

@dennisdoomen dennisdoomen marked this pull request as ready for review July 4, 2025 09:28
@dennisdoomen dennisdoomen force-pushed the feature/license-caching branch 4 times, most recently from 7bc5d20 to c287896 Compare July 11, 2025 16:00
@dennisdoomen dennisdoomen force-pushed the feature/license-caching branch 3 times, most recently from 99e61fd to c590561 Compare July 12, 2025 12:52
@dennisdoomen dennisdoomen requested a review from Copilot July 12, 2025 12:52
Copy link

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 adds a package‐level cache to the analysis process, controlled by new CLI flags and configuration properties.

  • Introduce UseCaching and CacheFilePath options to AnalyzeCommandSettings and pass them through to CSharpProjectAnalyzer.
  • Implement PackageInfoCollection.TryInitializeFromCache and WriteToCache using MemoryPack to load/save cached package metadata.
  • Update projects, tests, and documentation to reference Name instead of Id on PackageInfo and bump various package versions.

Reviewed Changes

Copilot reviewed 23 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
PackageGuard.csproj Upgrade configuration packages and add Pathy reference
AnalyzeCommandSettings.cs Add UseCaching and CacheFilePath CLI options
AnalyzeCommand.cs Pass caching settings into analyzer
PackageInfoCollection.cs Add cache load/save, rename constructor to take logger
PackageInfo.cs Rename IdName, mark [MemoryPackable]
NuGetPackageAnalyzer.cs Propagate source list to Find and metadata retrieval
CSharpProjectAnalyzer.cs Wire up cache logic in ExecuteAnalysis
Multiple test/spec files Update to use Name and add caching specs
README.md Document new CLI flags and caching details
Comments suppressed due to low confidence (3)

README.md:154

  • [nitpick] This new header has no accompanying text; consider adding an explanation of the caching feature or removing the empty section to keep the docs clear.
### Speed-up the analysis using caching

README.md:172

  • [nitpick] The backlog list contains duplicated and inconsistent bullet formatting; clean up or reformat the sections under “Major features”/“Minor features” for readability.
**Major features**

Src/PackageGuard.Specs/CSharpProjectAnalyzerSpecs.cs:535

  • There’s no test verifying that when UseCaching is false, no cache file is written; consider adding a negative test to ensure the cache path is untouched when caching is disabled.
    public async Task Creates_a_cache_if_asked_for()

@dennisdoomen dennisdoomen force-pushed the feature/license-caching branch 2 times, most recently from 110dac2 to b003786 Compare July 12, 2025 19:18
@coveralls
Copy link

coveralls commented Jul 12, 2025

Pull Request Test Coverage Report for Build 16241778058

Details

  • 79 of 93 (84.95%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+2.1%) to 76.449%

Changes Missing Coverage Covered Lines Changed/Added Lines %
Src/PackageGuard.Core/PackageInfo.cs 6 7 85.71%
Src/PackageGuard.Core/LicenseFetcher.cs 8 10 80.0%
Src/PackageGuard/AnalyzeCommand.cs 0 2 0.0%
Src/PackageGuard/AnalyzeCommandSettings.cs 0 2 0.0%
Src/PackageGuard.Core/PackageInfoCollection.cs 38 45 84.44%
Totals Coverage Status
Change from base Build 16089372995: 2.1%
Covered Lines: 471
Relevant Lines: 626

💛 - Coveralls

@dennisdoomen dennisdoomen force-pushed the feature/license-caching branch 7 times, most recently from b449f8a to bd404fd Compare July 12, 2025 20:30
@dennisdoomen dennisdoomen force-pushed the feature/license-caching branch from bd404fd to 807bcec Compare July 12, 2025 20:31
@dennisdoomen dennisdoomen added the enhancement New feature or request label Jul 12, 2025
@dennisdoomen dennisdoomen merged commit 67e9439 into main Jul 12, 2025
3 checks passed
@dennisdoomen dennisdoomen deleted the feature/license-caching branch July 12, 2025 20:37
@dennisdoomen dennisdoomen changed the title We will now maintain a package cache to speed-up the analysis. Add --use-caching flag to maintain a persisted cache to speed-up the analysis using Jul 12, 2025
@dennisdoomen dennisdoomen changed the title Add --use-caching flag to maintain a persisted cache to speed-up the analysis using Added --use-caching flag to maintain a persisted cache to speed-up the analysis using Jul 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add caching of the license information

3 participants