Skip to content

Conversation

@kerneltoast
Copy link
Collaborator

@kerneltoast kerneltoast commented Dec 5, 2025

Speed up the cloning process by only cloning what is necessary.

Successful test run: https://github.com/ctrliq/kernel-src-tree/actions/runs/19975988193/job/57292178451?pr=749

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 optimizes the GitHub Actions workflow for validating kernel commits by implementing shallow cloning and targeted fetching strategies to reduce the amount of git history that needs to be cloned, significantly speeding up the CI process.

Key Changes

  • Replaces full repository checkout with shallow clones using --depth=1 for the base branch and calculated depth for PR branches
  • Adds a staleness check to verify PR branches are rebased on the latest base commit
  • Implements smart upstream mainline fetching using --shallow-exclude based on kernel version tags
  • Updates all Python script calls to use commit SHAs instead of branch names for consistency

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@kerneltoast kerneltoast force-pushed the {sultan}_gha-optimize-clone branch from 1dc2739 to 5f30a99 Compare December 5, 2025 07:31
Copilot AI review requested due to automatic review settings December 5, 2025 21:05
@kerneltoast kerneltoast force-pushed the {sultan}_gha-optimize-clone branch from 5f30a99 to eff55e0 Compare December 5, 2025 21:05
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Check that the PR branch is up to date with the latest base branch commit,
and fail if it isn't.
Cloning the base branch takes a long time because a fetch-depth of 0 causes
all history for all branches and tags to be cloned (!). In addition, the
entire history of the PR branch is fetched.

Only the tip of the base branch along with the new commits present in a PR
need to be cloned; anything more than that is unneeded.

Reduce the depth of the base branch clone to 1 commit and the PR branch
fetch to the number of commits in the PR plus 1 (to get the tip of the base
branch).

The same philosophy is applied to fetching the mainline branch, which is
substantially more complex. All that is needed _at most_ is the history
between the kernel version tag and the tip of mainline, since the kernel
version tag is the most recent common ancestor between us and mainline.
History older than the kernel version tag is thus excluded via
--shallow-exclude.

And as an added bonus, skip checkout on the base branch clone since all of
the python scripts inspecting the tree perform checkouts themselves. That
way, no time is wasted on checking out the tree to a different SHA than the
first checkout by one of the python scripts.
@kerneltoast kerneltoast force-pushed the {sultan}_gha-optimize-clone branch from e409580 to cf8e45a Compare December 5, 2025 22:08
Copy link
Collaborator

@PlaidCat PlaidCat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

We may want to look at some of these optimization for the build workflows, but we can create a jira project to do that so everyone can learn this ... fun with GHA's

Copy link
Collaborator

@bmastbergen bmastbergen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥌

@kerneltoast kerneltoast merged commit cf8e45a into main Dec 6, 2025
@kerneltoast kerneltoast deleted the {sultan}_gha-optimize-clone branch December 6, 2025 02:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants