Repository navigation
test(executor-e2e): cover conclusion work-item filing for signal safe outputs #200
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR Data Prefetch | |
| # Fetches the PR diff, metadata and existing inline review comments once per | |
| # commit and saves them to the Actions cache under | |
| # `pr-prefetch-full-v1-<pr-number>-<head-sha>`. | |
| # | |
| # The PR number is part of the key so that the reviewers' `restore-keys` prefix | |
| # (`pr-prefetch-full-v1-<pr-number>-`) can find the newest entry for a PR even when the | |
| # head SHA is unknown — which is the case for `/review` slash-command runs, | |
| # where the centralized router dispatches `workflow_dispatch` with no PR payload. | |
| # | |
| # The five `/review` reviewers all restore that cache and run the shared | |
| # `pre-agent-steps` from `.github/workflows/shared/pr-diff-data-fetch.md`, which | |
| # detects the pre-fetched files and skips its own GitHub API calls entirely. | |
| # The `pr-data-head-sha.txt` marker is what makes a prefix-matched restore safe: | |
| # a stale entry is detected and refetched rather than silently reviewed. | |
| # | |
| # This works because the workflow has no AI engine: it finishes in ~30-60s, | |
| # while the reviewers' activation jobs take ~60-90s. By the time their agent | |
| # jobs restore the cache, it is warm. | |
| # | |
| # Without this, five reviewers would each independently pull the same diff, | |
| # metadata and comment list on every single push. | |
| on: | |
| pull_request: | |
| types: [ready_for_review, synchronize] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| concurrency: | |
| # One prefetch per commit. Deliberately NOT cancel-in-progress: cancelling | |
| # between the fetch and the cache save would leave the reviewers with a cold | |
| # cache and no benefit. | |
| group: pr-data-prefetch-${{ github.event.pull_request.head.sha }} | |
| cancel-in-progress: false | |
| jobs: | |
| prefetch: | |
| # Mirrors the `draft: false` filter on the reviewers themselves — there is | |
| # no point warming a cache for a review that will not run. | |
| if: github.event.pull_request.draft == false | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Pre-fetch PR diff, metadata and review comments | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} | |
| TARGET_REPOSITORY: ${{ github.repository }} | |
| run: | | |
| set -euo pipefail | |
| mkdir -p /tmp/gh-aw/agent | |
| # Exclusions must stay in sync with | |
| # .github/workflows/shared/pr-diff-data-fetch.md — these are all | |
| # generated artefacts, and line-commenting on them is pure noise. | |
| gh pr diff "$PR_NUMBER" --repo "$TARGET_REPOSITORY" \ | |
| --exclude '**/*.lock.yml' \ | |
| --exclude 'scripts/ado-script/*.js' \ | |
| --exclude 'scripts/ado-script/test-bin/**' \ | |
| --exclude '**/*.gen.ts' \ | |
| --exclude '**/*.gen.json' \ | |
| --exclude '**/dist/**' \ | |
| --exclude 'Cargo.lock' \ | |
| > /tmp/gh-aw/agent/pr-diff.patch | |
| LINES=$(wc -l < /tmp/gh-aw/agent/pr-diff.patch) | |
| gh pr view "$PR_NUMBER" \ | |
| --repo "$TARGET_REPOSITORY" \ | |
| --json number,title,body,headRefName,headRefOid,additions,deletions,changedFiles,files \ | |
| > /tmp/gh-aw/agent/pr-meta.json | |
| gh api "repos/$TARGET_REPOSITORY/pulls/$PR_NUMBER/comments" \ | |
| --paginate \ | |
| --jq '.[] | {id, path, line: (.line // .original_line), body: .body[:200], user: .user.login}' \ | |
| 2>/dev/null | jq -s '.' > /tmp/gh-aw/agent/pr-review-comments.json \ | |
| || echo '[]' > /tmp/gh-aw/agent/pr-review-comments.json | |
| # Written last: the reviewers treat this marker as proof that all | |
| # three files above were produced for this exact head commit. | |
| printf '%s\n' "$PR_HEAD_SHA" > /tmp/gh-aw/agent/pr-data-head-sha.txt | |
| COMMENT_COUNT=$(jq 'length' /tmp/gh-aw/agent/pr-review-comments.json) | |
| echo "Pre-fetched PR diff (${LINES} lines), metadata and ${COMMENT_COUNT} existing review comments for head ${PR_HEAD_SHA}" | |
| - name: Save PR data to cache | |
| uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 | |
| with: | |
| key: pr-prefetch-full-v1-${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }} | |
| path: /tmp/gh-aw/agent |