Skip to content

ci: skip pull request creation when only the analysis cache changes - #87

Merged
ruccho merged 1 commit into
mainfrom
feature/skip-pr-on-cache-only-changes
Sep 17, 2026
Merged

ruccho merged 1 commit into
mainfrom
feature/skip-pr-on-cache-only-changes

Conversation

@ruccho

@ruccho ruccho commented Sep 17, 2026

Copy link
Copy Markdown
Collaborator

Background

The Update Builtin Tasks workflow opened a pull request whenever a new Unity version was detected. However, when a new version introduces no change to the APIs the built-in build tasks depend on, the regenerated Tasks.*.g.cs files are identical to the ones already committed, and the only difference is in AnalysisCache/*.json. A pull request like that contains nothing to review.

In addition, the analysis cache does not reach the default branch until the pull request is merged. If the workflow ran again while the pull request was still open, the same Unity versions were cloned from UnityCsReference and analyzed all over again.

Changes

Evaluate the generated code and the analysis cache separately

A Detect changes step now compares Generated/ and AnalysisCache/ against the default branch independently.

  • When the generated code differs, a pull request is created or updated as before.
  • When the generated code is unchanged and only the analysis cache differs, no pull request is created. The Commit analysis cache only step commits and pushes the cache alone to the working branch (auto/update-builtin-tasks).

Restore the analysis cache from the working branch

A Restore analysis cache from the working branch step restores only the AnalysisCache directory from the working branch when that branch exists. This lets an open, unmerged pull request still spare the next run from re-analyzing versions that have already been analyzed.

The working branch itself is not checked out — only the cache directory is restored — so the pull request is still opened against the default branch. The restore has to happen before the new-version check (Check for new Unity versions), which is why it is placed immediately above it.

Other

  • fetch-depth of actions/checkout is set to 0, since the workflow now commits and pushes to the working branch.
  • The branch name and the output directory of the generated code are consolidated into env (BRANCH, GENERATED_DIR).

Notes

peter-evans/create-pull-request rebuilds the branch from the base and force-pushes it. The contents of a cache-only commit are nevertheless preserved, because every run pulls the working branch's cache into the working tree before the generator runs.

Once a pull request is merged the working branch is deleted, and the analysis cache lives on the default branch, so the restore step becomes a no-op.

Verification

The shell scripts embedded in the workflow were checked with bash -n. Actual behavior is expected to be verified by a manual workflow_dispatch run after the merge.

🤖 Generated with Claude Code

The Update Builtin Tasks workflow opened a pull request whenever a new Unity
version was found, even when the regenerated built-in tasks were identical to
the ones already committed. Such a pull request carries no reviewable change.

The generated code and the analysis cache are now compared separately against
the default branch. A pull request is created only when the generated code
differs. When only the analysis cache differs, the cache is committed directly
to the working branch instead, so that the analyzed versions are not analyzed
again on the next run.

To make the cache reusable before the working branch is merged, the workflow
now restores the analysis cache from that branch at the beginning of the run.
Only the cache directory is restored, so the pull request is still opened
against the default branch.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@ruccho
ruccho marked this pull request as ready for review September 17, 2026 02:44
@ruccho
ruccho requested a review from hkmt-mmy September 17, 2026 02:44
@ruccho
ruccho merged commit 6cccd52 into main Sep 17, 2026
1 check passed
@ruccho
ruccho deleted the feature/skip-pr-on-cache-only-changes branch September 17, 2026 03:18
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.

2 participants