Skip to content

ci(render-check): detect changed files via git diff, not the GitHub API#7521

Open
jstirnaman wants to merge 2 commits into
masterfrom
jts/harden-render-check-detect
Open

ci(render-check): detect changed files via git diff, not the GitHub API#7521
jstirnaman wants to merge 2 commits into
masterfrom
jts/harden-render-check-detect

Conversation

@jstirnaman

Copy link
Copy Markdown
Contributor

What changed

The cypress-render job's "Detect layout/asset changes" step now diffs the PR's base..head SHAs (from the event payload) instead of curling the GitHub API and piping to jq.

Why

During a GitHub API hiccup, the API returned a non-JSON body (a 503 "Service Unavailable" page). jq -r '.[].filename' failed with Invalid numeric literal at line 1, column 10, and the job's -eo pipefail shell aborted (exit 5). The render-check failed on a transient outage unrelated to the PR's contents. Observed on PR #7338: the same step passed, then failed twice in a row while the API was degraded.

Impact

  • Removes the network/token/jq dependency from change detection. No API call, no parse-failure mode.
  • actions/checkout already uses fetch-depth: 0, so both base.sha and head.sha are present locally.
  • Behavior is otherwise identical: same grep -qE filter decides whether Cypress runs.

Verification

  • actionlint clean on the changed step (pre-existing SC2086 infos on the untouched >> $GITHUB_OUTPUT lines left as-is).
  • Editing this workflow self-triggers the cypress-render job (the file is in its own trigger allowlist), so this PR exercises the new detection path.

The "Detect layout/asset changes" step curled the GitHub API for the
PR's changed files and piped the response to `jq`. When the API returned
a non-JSON body (e.g. a 503 "Service Unavailable" page during an API
hiccup), `jq` failed with "Invalid numeric literal" and the job's
`-eo pipefail` shell aborted (exit 5) — failing the whole render-check
on a transient outage unrelated to the PR's contents.

Diff the PR's base..head SHAs from the event payload instead. The
checkout already uses fetch-depth: 0, so both commits are present
locally. No network call, no token, no `jq`, no parse-failure mode.
@jstirnaman
jstirnaman requested a review from a team as a code owner July 16, 2026 23:18
@jstirnaman
jstirnaman requested review from Copilot and sanderson and removed request for a team July 16, 2026 23:18

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

Replaces API-based PR file detection with a local Git diff to avoid transient API failures.

Changes:

  • Removes the curl and jq dependency.
  • Uses event payload SHAs for change detection.
  • Needs three-dot merge-base semantics to match PR files accurately.

Comment thread .github/workflows/pr-render-check.yml Outdated
Use a three-dot diff here to match the pull request Files API. A two-endpoint diff compares the current base tip directly with the head, so when the base branch advances after the PR branch diverges, unrelated base-branch layout or asset changes are reported as PR changes and unnecessarily trigger Cypress. The repository's other PR detector uses merge-base semantics in .github/workflows/pr-remark-check.yml:47.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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