Skip to content

Comments

Implement dependency caching for build-site.yml#6

Merged
guygregory merged 5 commits intomainfrom
copilot/fix-5
Jul 18, 2025
Merged

Implement dependency caching for build-site.yml#6
guygregory merged 5 commits intomainfrom
copilot/fix-5

Conversation

Copy link
Contributor

Copilot AI commented Jul 18, 2025

This PR implements dependency caching for the GitHub Actions workflow to optimize build performance by moving hardcoded dependencies to a requirements.txt file and enabling pip caching.

Changes Made

1. Created requirements.txt

Added a new requirements file with the exact dependency versions that were previously hardcoded:

pelican==4.11.0
Markdown==3.8.2

2. Enhanced GitHub Actions Workflow

Modified .github/workflows/build-site.yml to:

  • Add actions/cache@v3 step for pip dependencies
  • Use ~/.cache/pip as the cache path
  • Use ${{ hashFiles('**/requirements.txt') }} as the cache key with OS prefix
  • Include restore-keys for fallback caching when requirements change
  • Replace hardcoded pip install pelican markdown with pip install -r requirements.txt

Benefits

  • Faster builds: Pip cache will be restored between workflow runs, significantly reducing dependency installation time
  • Maintainable dependencies: Dependencies are now centralized in requirements.txt instead of hardcoded in the workflow
  • Automatic cache invalidation: Cache key is based on requirements.txt content, ensuring fresh installs when dependencies change
  • Backward compatibility: Maintains exact same functionality with improved performance

Cache Strategy

The caching implementation uses:

  • Primary key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
  • Restore keys: ${{ runner.os }}-pip- (fallback for partial cache hits)

This ensures that:

  1. Dependencies are cached per OS (ubuntu-latest)
  2. Cache is invalidated when requirements.txt changes
  3. Partial cache restoration is available for faster builds even with dependency changes

Fixes #5.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI and others added 3 commits July 18, 2025 09:48
Co-authored-by: guygregory <16044916+guygregory@users.noreply.github.com>
Co-authored-by: guygregory <16044916+guygregory@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement dependency caching for build-site.yml Implement dependency caching for build-site.yml Jul 18, 2025
Copilot AI requested a review from guygregory July 18, 2025 09:57
@guygregory guygregory marked this pull request as ready for review July 18, 2025 10:00
@guygregory guygregory merged commit 8fe7708 into main Jul 18, 2025
1 check passed
@guygregory guygregory deleted the copilot/fix-5 branch September 9, 2025 20:36
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.

Implement dependency caching for build-site.yml

2 participants