Skip to content

Commit de8be40

Browse files
authored
Merge pull request #10589 from The-OpenROAD-Project-staging/ci/clang-tidy-post-overwrite-event
ci: overwrite runner event file so reviewdog detects fork PRs
2 parents f52ad70 + 51ace53 commit de8be40

1 file changed

Lines changed: 13 additions & 36 deletions

File tree

.github/workflows/github-actions-clang-tidy-bazel-post.yml

Lines changed: 13 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -81,20 +81,20 @@ jobs:
8181
done < pr-meta.txt
8282
8383
- name: Synthesize pull_request event payload
84-
id: event
8584
env:
8685
PR_NUMBER: ${{ steps.meta.outputs.pr_number }}
8786
HEAD_SHA: ${{ steps.meta.outputs.head_sha }}
8887
BASE_SHA: ${{ steps.meta.outputs.base_sha }}
8988
HEAD_REPO: ${{ steps.meta.outputs.head_repo }}
9089
BASE_REPO: ${{ steps.meta.outputs.base_repo }}
9190
run: |
92-
# Reviewdog's `github-pr-review` reporter reads GITHUB_EVENT_PATH
93-
# expecting a pull_request payload. The real event here is
94-
# workflow_run, so we synthesize the minimum payload reviewdog
95-
# needs and point GITHUB_EVENT_PATH at it for the next step.
96-
EVENT_PATH="${RUNNER_TEMP}/pr-event.json"
97-
python3 - <<'PY' > "$EVENT_PATH"
91+
# reviewdog reads pull_request.number from the event file at
92+
# GITHUB_EVENT_PATH; the workflow_run event has none (its
93+
# pull_requests[] is empty for fork PRs), so it bails with "this is
94+
# not PullRequest build". GITHUB_EVENT_PATH is runner-protected, so
95+
# an env: override is silently ignored — overwrite the event file in
96+
# place instead. Safe: nothing downstream reads the original event.
97+
python3 - <<'PY' > "${GITHUB_EVENT_PATH}"
9898
import json, os
9999
payload = {
100100
"action": "synchronize",
@@ -118,57 +118,34 @@ jobs:
118118
}
119119
print(json.dumps(payload))
120120
PY
121-
echo "event_path=${EVENT_PATH}" >> "$GITHUB_OUTPUT"
122121
123122
- name: Set up reviewdog
124123
uses: reviewdog/action-setup@d8a7baabd7f3e8544ee4dbde3ee41d0011c3a93f # v1.5.0
125124
with:
126125
reviewdog_version: latest
127126

128127
- name: Dump reviewdog-visible env and event payload
129-
# Gated on debug re-runs. Reviewdog emits "this is not PullRequest
130-
# build" and posts nothing for fork PRs even though the synthesized
131-
# pull_request payload is well-formed (verified locally against
132-
# reviewdog v0.21.0). Suspect: step-level `env:` cannot override
133-
# runner-protected GITHUB_EVENT_PATH / GITHUB_EVENT_NAME, so reviewdog
134-
# reads the runner's workflow_run event payload instead of our synth.
135-
# This step proves what reviewdog actually sees on the next debug
136-
# re-run.
128+
# Debug-gated: confirm the event file now holds the synthesized
129+
# pull_request payload reviewdog will read.
137130
if: runner.debug == '1'
138-
env:
139-
GITHUB_EVENT_NAME: pull_request
140-
GITHUB_EVENT_PATH: ${{ steps.event.outputs.event_path }}
141-
GITHUB_SHA: ${{ steps.meta.outputs.head_sha }}
142-
GITHUB_REPOSITORY: ${{ steps.meta.outputs.base_repo }}
143131
run: |
144-
echo "::group::GITHUB_* env visible to next step"
132+
echo "::group::GITHUB_* env visible to reviewdog"
145133
env | grep -E '^(GITHUB_|RUNNER_|REVIEWDOG_)' | sort
146134
echo "::endgroup::"
147-
echo "::group::Synth event file location and content"
148-
echo "steps.event.outputs.event_path = ${{ steps.event.outputs.event_path }}"
149-
echo "Effective GITHUB_EVENT_PATH = ${GITHUB_EVENT_PATH}"
135+
echo "::group::Effective GITHUB_EVENT_PATH content (should be our synth)"
136+
echo "Effective GITHUB_EVENT_PATH = ${GITHUB_EVENT_PATH}"
150137
if [ -f "${GITHUB_EVENT_PATH}" ]; then
151-
echo "--- file exists, content: ---"
152138
cat "${GITHUB_EVENT_PATH}"
153139
else
154140
echo "::warning::GITHUB_EVENT_PATH file does not exist"
155141
fi
156142
echo "::endgroup::"
157-
echo "::group::Synth file at literal path (should match above)"
158-
SYNTH="${{ steps.event.outputs.event_path }}"
159-
[ -f "${SYNTH}" ] && cat "${SYNTH}" || echo "missing"
160-
echo "::endgroup::"
161143
162144
- name: Run reviewdog
163145
env:
164146
REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
165-
GITHUB_EVENT_NAME: pull_request
166-
GITHUB_EVENT_PATH: ${{ steps.event.outputs.event_path }}
167-
GITHUB_SHA: ${{ steps.meta.outputs.head_sha }}
168-
GITHUB_REPOSITORY: ${{ steps.meta.outputs.base_repo }}
169147
run: |
170-
# On debug re-runs add reviewdog's own -log-level=debug so the
171-
# cienv detection trace is visible alongside the env dump above.
148+
# -log-level=debug on debug re-runs for tracing.
172149
LOG_FLAGS=()
173150
if [ "${RUNNER_DEBUG}" = "1" ]; then
174151
LOG_FLAGS+=(-log-level=debug)

0 commit comments

Comments
 (0)