Skip to content

ci: save pre-commit cache only from the default branch - #3047

Merged
juenglin merged 1 commit into
NVIDIA:mainfrom
juenglin:precommit-cache-trim
Oct 8, 2026
Merged

juenglin merged 1 commit into
NVIDIA:mainfrom
juenglin:precommit-cache-trim

Conversation

@juenglin

@juenglin juenglin commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Description

This is a CI infrastructure change; there is no separate tracking issue.

.github/workflows/pre-commit.yml used a single actions/cache step that both restored and saved. GitHub scopes caches by ref, so every PR merge ref (refs/pull/N/merge) saved its own ~260 MB copy of identical hook environments that no other run can read, steadily consuming the per-repository cache quota.

Changes:

  • Split the single cache step into actions/cache/restore and actions/cache/save (same pinned SHA). Gate the save with github.ref_name == github.event.repository.default_branch so pull requests restore the shared cache but stop creating per-PR duplicates. !cancelled() keeps a push that fails lint from discarding the valid hook environments, and the save is skipped on an exact key hit to avoid re-saving identical content.
  • Keep the full Python patch version in the primary key, but add a minor-version restore-keys prefix. A runner-image patch bump (3.14.7 -> 3.14.8) then misses the exact key, warm-starts from the previous cache via the prefix, and re-saves once, instead of exact-hitting a stale minor-only entry and rebuilding the hook environments on every run.
  • Add ctk-next to the push branches. It is the default branch of the private mirror, so the save also refreshes there; the branch does not exist upstream, so the trigger never fires here and this file stays byte-identical across both repositories.

Net effect: each repository keeps about one Linux + one Windows entry instead of a pair per pull request, and the Windows cache is preserved.

Checklist

  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

The single actions/cache step saved a ~260 MB copy of identical hook
environments on every PR merge ref (refs/pull/N/merge), which GitHub
scopes per ref so no other run can read them. Split the step into
cache/restore + cache/save and gate the save to the default branch, so
PRs restore the shared cache but stop creating per-PR duplicates.

Keep the full Python patch version in the primary key and add a
minor-version restore-key prefix so a runner-image patch bump warm-starts
from the previous cache and re-saves once, instead of exact-hitting a
stale entry and rebuilding every run. Add "ctk-next" to the push triggers
so the save also runs on the private mirror's default branch, keeping this
file byte-identical across both repositories.
@juenglin juenglin added this to the cuda.core 1.3.0 milestone Oct 7, 2026
@juenglin juenglin added the CI/CD CI/CD infrastructure label Oct 7, 2026
@juenglin juenglin self-assigned this Oct 7, 2026
@copy-pr-bot

copy-pr-bot Bot commented Oct 7, 2026

Copy link
Copy Markdown
Contributor

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@juenglin juenglin added cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module cuda.pathfinder Everything related to the cuda.pathfinder module labels Oct 7, 2026
@juenglin
juenglin requested review from jpascucci-nv and rwgk October 7, 2026 22:11
@coderabbitai

coderabbitai Bot commented Oct 7, 2026

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: NVIDIA/cuda-python/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 48589f83-87bd-432f-8eee-4a4341ff98c2
📥 Commits

Reviewing files that changed from the base of the PR and between 94139a0 and 5aebb5e.

📒 Files selected for processing (1)
  • .github/workflows/pre-commit.yml

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Summary

Summary by CodeRabbit

  • Chores
    • Updated automated pre-commit checks to run for changes pushed to both main and ctk-next.
    • Updated the Python version used by the checks and refined how their cached data is restored and saved, helping keep the checks consistent across runs.

Walkthrough

The pre-commit workflow now runs on pushes to ctk-next as well as main. It sets Python 3.14 through an environment variable and uses separate cache restore and save steps with conditional saving.

Changes

Pre-commit workflow

Layer / File(s) Summary
Configure Python and cache lifecycle
.github/workflows/pre-commit.yml
The workflow adds the ctk-next push trigger and configures Python 3.14 through PYTHON_VERSION. Cache restoration uses the resolved Python version and configuration hash, with a minor-version restore prefix. Cache saving runs only when the job is not cancelled, the ref is the default branch, and restoration did not find an exact cache hit.

Suggested reviewers: rwgk

Priority: ⬇️ Low

Change: Other

Merge Risk: ⚪ Minimal · up to 5aebb

The workflow preserves the intended cache-refresh behavior while limiting writes to the repository’s default branch. No actionable merge-blocking risk remains.

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Comment @coderabbitai help to get the list of available commands.

@jpascucci-nv jpascucci-nv left a comment

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.

Seems fine.

@juenglin

juenglin commented Oct 7, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5aebb5e

@juenglin
juenglin enabled auto-merge (squash) October 7, 2026 22:19
@github-actions

github-actions Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor
Doc Preview CI
Preview removed because the pull request was closed or merged.

@juenglin
juenglin merged commit cd5d361 into NVIDIA:main Oct 8, 2026
133 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 8, 2026
Removed preview folders for the following PRs:
- PR #2266
- PR #2959
- PR #2986
- PR #3004
- PR #3018
- PR #3035
- PR #3037
- PR #3041
- PR #3042
- PR #3043
- PR #3044
- PR #3047
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD CI/CD infrastructure cuda.bindings Everything related to the cuda.bindings module cuda.core Everything related to the cuda.core module cuda.pathfinder Everything related to the cuda.pathfinder module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants