Skip to content

ci: rearchitect link validation caching to work at the URL level and support content/… #6263

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

Merged
merged 3 commits into from
Jul 29, 2025

Conversation

jstirnaman
Copy link
Contributor

…shared shared content files. Fix the cache reporting.Link Validation Cache Performance:

=======================================
Cache hit rate: 100%
Cache hits: 54
Cache misses: 0
Total validations: 54
New entries stored: 0
✨ Cache optimization saved 54 link validations

This demonstrates that all 54 link validations were served from cache, which
greatly speeds up the test execution.

Summary

I've successfully fixed the cache statistics reporting issue in the Cypress link
validation tests. Here's what was implemented:

Changes Made:

  1. Modified the Cypress test (cypress/e2e/content/article-links.cy.js):
    - Added a new task call saveCacheStatsForReporter in the after() hook to save cache statistics to a file that the main reporter can read
  2. Updated Cypress configuration (cypress.config.js):
    - Added the saveCacheStatsForReporter task that calls the reporter's saveCacheStats function
    - Imported the saveCacheStats function from the link reporter
  3. Enhanced the link reporter (cypress/support/link-reporter.js):
    - Improved the displayBrokenLinksReport function to show comprehensive cache performance statistics
    - Added better formatting and informative messages about cache optimization benefits
  4. Fixed missing constant (cypress/support/hugo-server.js):
    - Added the missing HUGO_SHUTDOWN_TIMEOUT constant and exported it
    - Updated the import in run-e2e-specs.js to include this constant

Result:

The cache statistics are now properly displayed in the terminal output after
running link validation tests, showing:

  • Cache hit rate (percentage)
  • Cache hits (number of cached validations)
  • Cache misses (number of fresh validations)
  • Total validations performed
  • New entries stored in cache
  • Expired entries cleaned (when applicable)
  • Optimization message showing how many validations were saved by caching

…shared shared content files. Fix the cache reporting.Link Validation Cache Performance:

  =======================================
  Cache hit rate: 100%
  Cache hits: 54
  Cache misses: 0
  Total validations: 54
  New entries stored: 0
  ✨ Cache optimization saved 54 link validations

  This demonstrates that all 54 link validations were served from cache, which
  greatly speeds up the test execution.

  Summary

  I've successfully fixed the cache statistics reporting issue in the Cypress link
  validation tests. Here's what was implemented:

  Changes Made:

  1. Modified the Cypress test (cypress/e2e/content/article-links.cy.js):
    - Added a new task call saveCacheStatsForReporter in the after() hook to save
  cache statistics to a file that the main reporter can read
  2. Updated Cypress configuration (cypress.config.js):
    - Added the saveCacheStatsForReporter task that calls the reporter's
  saveCacheStats function
    - Imported the saveCacheStats function from the link reporter
  3. Enhanced the link reporter (cypress/support/link-reporter.js):
    - Improved the displayBrokenLinksReport function to show comprehensive cache
  performance statistics
    - Added better formatting and informative messages about cache optimization
  benefits
  4. Fixed missing constant (cypress/support/hugo-server.js):
    - Added the missing HUGO_SHUTDOWN_TIMEOUT constant and exported it
    - Updated the import in run-e2e-specs.js to include this constant

  Result:

  The cache statistics are now properly displayed in the terminal output after
  running link validation tests, showing:

  - Cache hit rate (percentage)
  - Cache hits (number of cached validations)
  - Cache misses (number of fresh validations)
  - Total validations performed
  - New entries stored in cache
  - Expired entries cleaned (when applicable)
  - Optimization message showing how many validations were saved by caching
@jstirnaman jstirnaman requested a review from Copilot July 29, 2025 15:25
Copy link
Contributor

@Copilot 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 pull request rearchitects the link validation caching system to work at the URL level instead of the file level, enabling support for shared content files and improving cache performance reporting. The changes introduce a new LinkCacheManager class that manages individual URL validation results with TTL-based expiration and comprehensive statistics tracking.

Key changes:

  • Implements URL-level caching with a new LinkCacheManager class for individual link validation results
  • Replaces file-level caching strategy with direct URL validation and caching in test execution
  • Enhances cache statistics reporting with detailed performance metrics and optimization messages

Reviewed Changes

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

Show a summary per file
File Description
cypress/support/link-cache.js New file implementing the LinkCacheManager class with URL-level caching, TTL management, and statistics tracking
cypress/e2e/content/article-links.cy.js Refactored to use URL-level caching, removed file-level validation strategy, added cache integration in link testing
cypress/support/link-reporter.js Enhanced cache performance reporting with more detailed statistics and better formatting
cypress/support/hugo-server.js Added missing HUGO_SHUTDOWN_TIMEOUT constant export
cypress/support/run-e2e-specs.js Added import for the new HUGO_SHUTDOWN_TIMEOUT constant
Comments suppressed due to low confidence (1)

jstirnaman and others added 2 commits July 29, 2025 10:44
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@jstirnaman jstirnaman merged commit c781182 into master Jul 29, 2025
1 check passed
@jstirnaman jstirnaman deleted the jts-ci-automate-link-check branch July 29, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant