Skip to content

Commit 80a2f5a

Browse files
authored
[WIP] Fix missing data in contribution check workflow (#5308)
* Initial plan * fix(contribution-check): use context files for pre-fetched data Steps run in the agent job but the prompt is built in the activation job, so ${{ steps.*.outputs.* }} expressions always evaluate to empty strings. Follow the doc-maintainer pattern: write fetched data to /tmp/gh-aw/contribution-check-context/ and update the prompt to read those files. Remove stale GH_AW_EXPR env vars from activation job. Closes #5289 * fix(workflows): address contribution-check review feedback --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 39bcb8b commit 80a2f5a

3 files changed

Lines changed: 42 additions & 62 deletions

File tree

.github/workflows/contribution-check.lock.yml

Lines changed: 4 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/contribution-check.md

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -41,35 +41,32 @@ steps:
4141
- name: Fetch CONTRIBUTING.md
4242
id: contributing
4343
run: |
44-
DELIM="GHAW_CONTRIBUTING_$(date +%s)"
45-
{
46-
echo "CONTENT<<${DELIM}"
47-
gh api "repos/${GH_REPO}/contents/CONTRIBUTING.md" --jq '.content' 2>/dev/null | tr -d '\n' | base64 -d 2>/dev/null || echo "(CONTRIBUTING.md not found)"
48-
echo "${DELIM}"
49-
} >> "$GITHUB_OUTPUT"
44+
set -o pipefail
45+
CONTEXT_DIR=/tmp/gh-aw/contribution-check-context
46+
mkdir -p "$CONTEXT_DIR"
47+
gh api "repos/${GH_REPO}/contents/CONTRIBUTING.md" --jq '.content' 2>/dev/null \
48+
| tr -d '\n' | base64 -d 2>/dev/null \
49+
> "$CONTEXT_DIR/contributing.md" \
50+
|| echo "(CONTRIBUTING.md not found)" > "$CONTEXT_DIR/contributing.md"
5051
env:
5152
GH_TOKEN: ${{ github.token }}
5253
GH_REPO: ${{ github.repository }}
5354
- name: Fetch PR changed files
5455
id: pr-diff
5556
if: github.event.pull_request.number || github.event.inputs.item_number
5657
run: |
57-
DELIM="GHAW_PR_FILES_$(date +%s)"
58+
CONTEXT_DIR=/tmp/gh-aw/contribution-check-context
59+
mkdir -p "$CONTEXT_DIR"
5860
DIFF_LIMIT=50000
5961
DIFF_TMP="$(mktemp)"
60-
{
61-
echo "PR_FILES<<${DELIM}"
62-
gh api "repos/${GH_REPO}/pulls/${PR_NUMBER}/files" \
63-
--paginate --jq '.[] | "### " + .filename + " (+" + (.additions|tostring) + "/-" + (.deletions|tostring) + ")\n" + (.patch // "") + "\n"' \
64-
> "$DIFF_TMP" || true
65-
DIFF_SIZE="$(wc -c < "$DIFF_TMP" | tr -d ' ')"
66-
head -c "$DIFF_LIMIT" "$DIFF_TMP" || true
67-
if [ "$DIFF_SIZE" -gt "$DIFF_LIMIT" ]; then
68-
echo -e "\n[DIFF TRUNCATED at ${DIFF_LIMIT} bytes]"
69-
fi
70-
echo ""
71-
echo "${DELIM}"
72-
} >> "$GITHUB_OUTPUT"
62+
gh api "repos/${GH_REPO}/pulls/${PR_NUMBER}/files" \
63+
--paginate --jq '.[] | "### " + .filename + " (+" + (.additions|tostring) + "/-" + (.deletions|tostring) + ")\n" + (.patch // "") + "\n"' \
64+
> "$DIFF_TMP" || true
65+
DIFF_SIZE="$(wc -c < "$DIFF_TMP" | tr -d ' ')"
66+
head -c "$DIFF_LIMIT" "$DIFF_TMP" > "$CONTEXT_DIR/pr-files.md" || true
67+
if [ "$DIFF_SIZE" -gt "$DIFF_LIMIT" ]; then
68+
echo -e "\n[DIFF TRUNCATED at ${DIFF_LIMIT} bytes]" >> "$CONTEXT_DIR/pr-files.md"
69+
fi
7370
rm -f "$DIFF_TMP"
7471
env:
7572
GH_TOKEN: ${{ github.token }}
@@ -80,15 +77,12 @@ steps:
8077
id: pr-meta
8178
if: github.event.pull_request.number || github.event.inputs.item_number
8279
run: |
83-
DELIM="GHAW_PR_META_$(date +%s)"
84-
PR_INFO=$(gh pr view "$PR_NUMBER" --repo "$GH_REPO" \
80+
CONTEXT_DIR=/tmp/gh-aw/contribution-check-context
81+
mkdir -p "$CONTEXT_DIR"
82+
gh pr view "$PR_NUMBER" --repo "$GH_REPO" \
8583
--json title,author,baseRefName,headRefName,body \
86-
--jq '"**Title:** " + .title + "\n**Author:** " + .author.login + "\n**Base→Head:** " + .baseRefName + "→" + .headRefName + "\n**Description:**\n" + (.body // "")')
87-
{
88-
echo "PR_META<<${DELIM}"
89-
printf '%s\n' "$PR_INFO"
90-
echo "${DELIM}"
91-
} >> "$GITHUB_OUTPUT"
84+
--jq '"**Title:** " + .title + "\n**Author:** " + .author.login + "\n**Base→Head:** " + .baseRefName + "→" + .headRefName + "\n**Description:**\n" + (.body // "")' \
85+
> "$CONTEXT_DIR/pr-meta.md"
9286
env:
9387
GH_TOKEN: ${{ github.token }}
9488
PR_NUMBER: ${{ github.event.pull_request.number || github.event.inputs.item_number }}
@@ -102,23 +96,14 @@ You are a contribution guidelines reviewer for the `gh-aw-firewall` (AWF) reposi
10296

10397
## Your Task
10498

105-
Review PR #${{ github.event.pull_request.number }} in repository ${{ github.repository }}.
99+
Review PR #${{ github.event.pull_request.number || github.event.inputs.item_number }} in repository ${{ github.repository }}.
106100

107-
**Use ONLY the pre-fetched data below.** Do NOT call `gh pr diff`, `gh pr view`, `gh api`, `git diff`, `git log`, or `git show`. Do not read files from the checkout.
101+
Read the following pre-fetched context files before proceeding:
102+
- `/tmp/gh-aw/contribution-check-context/pr-meta.md` — PR metadata (title, author, base/head branch, description)
103+
- `/tmp/gh-aw/contribution-check-context/pr-files.md` — Changed files with diffs
104+
- `/tmp/gh-aw/contribution-check-context/contributing.md` — CONTRIBUTING.md content
108105

109-
## Pre-Fetched PR Metadata
110-
111-
${{ steps.pr-meta.outputs.PR_META }}
112-
113-
## Pre-Fetched Changed Files
114-
115-
```
116-
${{ steps.pr-diff.outputs.PR_FILES }}
117-
```
118-
119-
## CONTRIBUTING.md (Pre-Fetched)
120-
121-
${{ steps.contributing.outputs.CONTENT }}
106+
**Use ONLY the pre-fetched data in these context files.** Do NOT call `gh pr diff`, `gh pr view`, `gh api`, `git diff`, `git log`, or `git show`. Do not read other files from the checkout.
122107

123108
## Review Checklist
124109

scripts/ci/contribution-check-workflow.test.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,22 @@ describe('contribution-check workflow', () => {
1313
expect(source).toContain('Fetch PR metadata');
1414
expect(source).toContain('Fetch CONTRIBUTING.md');
1515
expect(source).toContain('GH_TOKEN: ${{ github.token }}');
16-
expect(source).toContain('${{ steps.pr-diff.outputs.PR_FILES }}');
17-
expect(source).toContain('${{ steps.pr-meta.outputs.PR_META }}');
18-
expect(source).toContain('${{ steps.contributing.outputs.CONTENT }}');
16+
expect(source).toContain('set -o pipefail');
17+
18+
// Steps write to context files (not $GITHUB_OUTPUT), so data persists for the agent
19+
expect(source).toContain('/tmp/gh-aw/contribution-check-context/contributing.md');
20+
expect(source).toContain('/tmp/gh-aw/contribution-check-context/pr-files.md');
21+
expect(source).toContain('/tmp/gh-aw/contribution-check-context/pr-meta.md');
1922
});
2023

2124
it('instructs agent to use pre-fetched data and not re-fetch via proxy', () => {
2225
const source = fs.readFileSync(sourcePath, 'utf-8');
2326

24-
expect(source).toContain('Use ONLY the pre-fetched data below');
27+
// Agent reads from context files written by the pre-fetch steps
28+
expect(source).toContain('Read the following pre-fetched context files before proceeding');
2529
expect(source).toContain("Do NOT call `gh pr diff`");
26-
expect(source).toContain('Do not read files from the checkout');
30+
expect(source).toContain('Use ONLY the pre-fetched data in these context files');
31+
expect(source).toContain('Review PR #${{ github.event.pull_request.number || github.event.inputs.item_number }}');
2732
});
2833

2934
it('has conservative turn limit and appropriate model', () => {

0 commit comments

Comments
 (0)