Skip to content

[CORRUPTED] Synthetic Benchmark PR #26636 - feat: implement git checkout caching to speed up CI workflows#558

Open
ofir-frd wants to merge 10 commits intobase_pr_26636_20260120_4823from
corrupted_pr_26636_20260120_4823
Open

[CORRUPTED] Synthetic Benchmark PR #26636 - feat: implement git checkout caching to speed up CI workflows#558
ofir-frd wants to merge 10 commits intobase_pr_26636_20260120_4823from
corrupted_pr_26636_20260120_4823

Conversation

@ofir-frd
Copy link

Benchmark PR calcom#26636

Type: Corrupted (contains bugs)

Original PR Title: feat: implement git checkout caching to speed up CI workflows
Original PR Description: ## What does this PR do?

Implements git checkout caching to reduce CI workflow times by eliminating redundant git checkouts across parallel jobs.

Previously, every job in the PR workflow performed its own full git checkout (via actions/checkout@v4 + dangerous-git-checkout), resulting in 20+ separate checkouts per workflow run. This was particularly slow for the cal.com repo (~1.3GB).

This PR:

  • Creates a new cache-checkout action that saves/restores the git working directory
  • The prepare job saves the checkout to cache after dangerous-git-checkout
  • All downstream workflows use sparse-checkout of .github (to access the action) then restore from cache
  • Uses cache key format git-checkout-{branch}-{sha} to ensure cache is only reused within a single PR
  • Deletes previous caches for the branch before saving to keep cache storage low (only one cache per branch)
  • Automatically cleans up git-checkout caches when PRs are closed (via delete-blacksmith-cache.yml)
  • Uses sparse-checkout in dangerous-git-checkout to exclude /example-apps/ and *.mp4 files (~38MB saved from salesroom demo video)

Expected impact: Reduces checkout time from ~10+ minutes per job to a fast cache restore, with only one full checkout per workflow run.

Link to Devin run: https://app.devin.ai/sessions/00c0c2b934dc40609aaf765ab206daaa
Requested by: @keithwillcode

Updates since last revision

  • Fixed cache key to use github.head_ref || github.ref_name and github.sha instead of github.event.pull_request.head.ref/sha (the latter is not available in workflow_call contexts)
  • Final cache key format: git-checkout-${{ github.head_ref || github.ref_name }}-${{ github.sha }}
  • Added prefix delete step before saving cache to clear previous checkout caches for the same branch (uses useblacksmith/cache-delete@v1 with prefix: "true")
  • Added cache cleanup job in delete-blacksmith-cache.yml to delete all git-checkout caches with the PR branch prefix when PR is closed
  • Added sparse-checkout to dangerous-git-checkout action to exclude example-apps/ directory and all .mp4 files
  • Fixed: Restored get_sha step and commit-sha output that was accidentally removed when adding the cache-checkout step (this was breaking the ready-for-e2e label check)
  • Fixed: Added trailing - to cache key prefix to prevent accidental deletion of other branches' caches (e.g., branch feature no longer deletes caches for feature-2)

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - CI infrastructure change only.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

This PR modifies CI infrastructure and can only be tested by running the actual workflows:

  1. Create/update a PR to trigger the workflow
  2. Verify the prepare job successfully deletes old caches and saves the checkout to cache
  3. Verify downstream jobs (lint, type-check, unit-tests, etc.) successfully restore from cache
  4. Push another commit and verify the old cache is deleted before the new one is saved
  5. Compare total workflow time before and after this change
  6. Close a PR and verify the git-checkout caches are cleaned up

Human Review Checklist

  • Verify fail-on-cache-miss: true is acceptable behavior (downstream jobs will fail if prepare job fails before caching)
  • Confirm cache paths correctly exclude .git and node_modules
  • Verify github.head_ref || github.ref_name and github.sha are available in all workflow_call contexts
  • Consider edge cases: what happens if cache is evicted mid-workflow?
  • Confirm sparse-checkout of .github is fast enough to be worthwhile vs. the previous approach
  • Verify cache key handles branch names with special characters correctly
  • Confirm prefix-based cache deletion (git-checkout-{branch}) won't accidentally delete unrelated caches - Fixed by adding trailing - to prefix
  • Verify no workflows need files from example-apps/ or the salesroom mp4 file
  • Confirm sparse-checkout patterns (/*, !/example-apps/, !**/*.mp4) work correctly in non-cone mode
  • Verify get_sha step and commit-sha output are properly restored in pr.yml

Checklist

Compliance Violation

  • Rule: All Tests Must Use Vitest Framework and UTC Timezone
  • Language: YAML
  • File: .github/workflows/api-v2-unit-tests.yml

keithwillcode and others added 10 commits January 9, 2026 19:26
- Create cache-checkout action to save/restore git working directory
- Update prepare job in pr.yml to cache checkout after dangerous-git-checkout
- Update all downstream workflows to restore from cache instead of checkout
- Pass commit-sha to all workflow calls for cache key consistency

This reduces the number of full git checkouts from 20+ per workflow run to just 1,
significantly improving CI performance especially for large repos.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Remove sparse-checkout and use actions/cache/restore@v4 directly in all
downstream workflows. This eliminates the need for any git fetch operation
before restoring from cache, making the optimization more effective.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- Remove commit-sha input from all downstream workflows
- Update cache-checkout action to use github.event.pull_request.head.sha directly
- Remove commit-sha output from prepare job
- Remove commit-sha from all workflow calls in pr.yml
- Keep sparse-checkout of .github to access the cache-checkout action

This eliminates the need to pass commit-sha around while still using
a reusable action for the cache restore logic.

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
… removed

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…tion of other branches' caches

The prefix-based cache deletion was using 'git-checkout-{branch}' which would
accidentally match and delete caches for branches with similar prefixes.
For example, branch 'feature' would delete caches for 'feature-2', 'feature-new', etc.

Adding a trailing '-' ensures exact branch matching:
- 'git-checkout-feature-' matches 'git-checkout-feature-abc123' (intended)
- 'git-checkout-feature-' does NOT match 'git-checkout-feature-2-def456' (correct)

Fixes both the cache-checkout action and the PR close cleanup workflow.

Co-Authored-By: unknown <>
@github-actions
Copy link

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "[CORRUPTED] Synthetic Benchmark PR #26636 - feat: implement git checkout caching to speed up CI workflows". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@github-actions
Copy link

This PR has been marked as stale due to inactivity. If you're still working on it or need any help, please let us know or update the PR to keep it active.

@github-actions github-actions bot added the Stale label Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants