Skip to content

Consolidate PR data pre-fetch across three skills-reviewer workflows - #47392

Merged
pelikhan merged 2 commits into
mainfrom
copilot/deep-report-consolidate-github-reads
Jul 22, 2026
Merged

Consolidate PR data pre-fetch across three skills-reviewer workflows#47392
pelikhan merged 2 commits into
mainfrom
copilot/deep-report-consolidate-github-reads

Conversation

Copilot AI commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

pr-code-quality-reviewer, impeccable-skills-reviewer, and mattpocock-skills-reviewer each independently fetched the same PR diff/metadata/comments on every ready_for_review event — 9 API calls where 3 suffice, consuming ~40% of the repo's daily REST API quota (~10k calls/day).

Changes

  • shared/pr-diff-data-fetch.md (new): Shared pre-agent-steps component that fetches PR diff, metadata, and review comments. Handles both pull_request and slash_command events via ${{ github.event.issue.number || github.event.pull_request.number }}.

  • Three reviewer workflows: Replaced identical inline pre-agent-steps blocks with imports: - shared/pr-diff-data-fetch.md. The cache: keys and skip-if-cached logic are unchanged.

  • pr-data-prefetch.yml (new): A non-agentic plain GitHub Actions workflow on the same pull_request: [ready_for_review] trigger that fetches PR data and saves it to actions/cache with key pr-prefetch-<sha>. Because it has no AI engine or containers, it completes in ~30–60 s — before the reviewer workflows finish their activation jobs and reach the cache-restore step in their agent jobs.

Cache warm-up flow

T=0s    All 4 workflows trigger simultaneously
T~40s   pr-data-prefetch saves actions/cache[pr-prefetch-<sha>]
T~90s   Reviewer agent jobs start → cache restore → HIT → skip fetch

On cache miss (e.g., first run before prefetch saves), the shared component falls back to fetching as before. Subsequent runs on the same SHA and re-triggers always hit cache.

…flows

Extract the duplicate pre-agent-steps from pr-code-quality-reviewer,
impeccable-skills-reviewer, and mattpocock-skills-reviewer into a new
shared/pr-diff-data-fetch.md component.

Add a new pr-data-prefetch.yml (non-agentic) workflow that warms the
Actions cache (key: pr-prefetch-<sha>) before reviewer agent jobs start,
so all three reviewers can skip their GitHub API calls on cache hit.

This reduces the three independent GitHub API fetch sets (~9 calls) to
one shared fetch (~3 calls) per PR event, saving ~10k REST API quota/day.

Closes #47345

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Consolidate shared GitHub reads across skills-reviewer workflows Consolidate PR data pre-fetch across three skills-reviewer workflows Jul 22, 2026
Copilot AI requested a review from pelikhan July 22, 2026 20:09
@pelikhan
pelikhan marked this pull request as ready for review July 22, 2026 20:27
Copilot AI review requested due to automatic review settings July 22, 2026 20:27
@pelikhan
pelikhan merged commit ad6b7fd into main Jul 22, 2026
@pelikhan
pelikhan deleted the copilot/deep-report-consolidate-github-reads branch July 22, 2026 20:28
Copilot stopped reviewing on behalf of pelikhan due to an error July 22, 2026 20:28

Copilot AI 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.

Pull request overview

Note

Copilot could not run the full agentic suite for this review because it was automatically requested on a bot-authored pull request. Request a review from Copilot under Reviewers to retry with the full agentic suite. Improved support for bot-authored pull requests is coming soon.

Introduces a shared “pre-agent” step for fetching PR diff/metadata/review comments and adds a dedicated workflow to prefetch + cache this data once per commit, reducing duplicated GitHub API calls across PR reviewer workflows.

Changes:

  • Added reusable shared component to fetch PR diff, PR metadata, and inline review comments with a cache-hit short-circuit.
  • Added pr-data-prefetch.yml workflow to warm an Actions cache keyed by head SHA.
  • Updated reviewer workflows to import the shared prefetch component instead of duplicating shell steps.
Show a summary per file
File Description
.github/workflows/shared/pr-diff-data-fetch.md Adds shared pre-agent prefetch logic with cache-hit detection and standardized output files.
.github/workflows/pr-data-prefetch.yml New workflow to prefetch PR data on ready_for_review and save it to Actions cache.
.github/workflows/pr-code-quality-reviewer.md Switches from inline pre-agent steps to importing the shared prefetch component.
.github/workflows/pr-code-quality-reviewer.lock.yml Regenerated lockfile reflecting the new shared import and prompt changes.
.github/workflows/mattpocock-skills-reviewer.md Switches from inline pre-agent steps to importing the shared prefetch component.
.github/workflows/mattpocock-skills-reviewer.lock.yml Regenerated lockfile reflecting the new shared import and updated env/run blocks.
.github/workflows/impeccable-skills-reviewer.md Switches from inline pre-agent steps to importing the shared prefetch component.
.github/workflows/impeccable-skills-reviewer.lock.yml Regenerated lockfile reflecting the new shared import and updated env/run blocks.

Review details

Tip

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

  • Files reviewed: 8/8 changed files
  • Comments generated: 6
  • Review effort level: Low

Comment on lines +62 to +66
- name: Save PR data to cache
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
key: pr-prefetch-${{ github.event.pull_request.head.sha }}
path: /tmp/gh-aw/agent
Comment on lines +32 to +36
if [ -f /tmp/gh-aw/agent/pr-diff.patch ] && [ -f /tmp/gh-aw/agent/pr-meta.json ] && [ -f /tmp/gh-aw/agent/pr-review-comments.json ]; then
LINES=$(wc -l < /tmp/gh-aw/agent/pr-diff.patch)
COMMENT_COUNT=$(jq 'length' /tmp/gh-aw/agent/pr-review-comments.json)
echo "Cache hit: using pre-fetched PR data (${LINES} diff lines, ${COMMENT_COUNT} review comments)"
else
COMMENT_COUNT=$(jq 'length' /tmp/gh-aw/agent/pr-review-comments.json)
echo "Cache hit: using pre-fetched PR data (${LINES} diff lines, ${COMMENT_COUNT} review comments)"
else
{ gh pr diff "$PR_NUMBER" --repo $EXPR_GITHUB_REPOSITORY \
Comment on lines +44 to +45
gh pr view "$PR_NUMBER" \
--repo $EXPR_GITHUB_REPOSITORY \
COMMENT_COUNT=$(jq 'length' /tmp/gh-aw/agent/pr-review-comments.json)
echo "Cache hit: using pre-fetched PR data (${LINES} diff lines, ${COMMENT_COUNT} review comments)"
else
{ gh pr diff "$PR_NUMBER" --repo $EXPR_GITHUB_REPOSITORY \
Comment on lines +42 to +43
|| true; } | head -n "${PR_DIFF_MAX_LINES}" > /tmp/gh-aw/agent/pr-diff.patch
LINES=$(wc -l < /tmp/gh-aw/agent/pr-diff.patch)
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.83.1

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.

[deep-report] Consolidate shared GitHub reads across the three skills-reviewer workflows (~10k API quota/day)

3 participants