|
64 | 64 | run: | |
65 | 65 | # The full .diff endpoint rejects large-but-valid PRs at 20k lines. |
66 | 66 | # The paginated files endpoint remains filename-only for this gate. |
67 | | - FILES=$(gh api --paginate "repos/$REPO/pulls/$PR/files?per_page=100" --jq '.[].filename') |
| 67 | + if FILES=$(gh api --paginate "repos/$REPO/pulls/$PR/files?per_page=100" --jq '.[].filename'); then |
| 68 | + echo "file list: pulls/files API" |
| 69 | + else |
| 70 | + # The files endpoint renders the diff server-side too, and answers |
| 71 | + # 422 "this diff is taking too long to generate" for a PR that |
| 72 | + # regenerates a vendored parser (#2246: a 42 MB sql/parser.c) -- |
| 73 | + # so does the compare endpoint. The PR merge ref's first parent is |
| 74 | + # the base, so a name-only diff across it is the same file list. |
| 75 | + # depth 2 + blob:none fetches commits and trees only (well under |
| 76 | + # 1 MB, under a second); nothing from the PR is checked out or run. |
| 77 | + echo "::notice::pulls/files API failed; file list taken from refs/pull/$PR/merge" |
| 78 | + CHANGES_GIT="$RUNNER_TEMP/changes.git" |
| 79 | + git init -q --bare "$CHANGES_GIT" |
| 80 | + git --git-dir="$CHANGES_GIT" fetch -q --depth=2 --filter=blob:none \ |
| 81 | + "https://github.com/$REPO" "refs/pull/$PR/merge" |
| 82 | + FILES=$(git --git-dir="$CHANGES_GIT" diff --name-only --no-renames FETCH_HEAD^1 FETCH_HEAD) |
| 83 | + fi |
68 | 84 | printf '%s\n' "$FILES" |
69 | | - if printf '%s\n' "$FILES" | grep -qE '^(src/|internal/|install\.(sh|ps1)|scripts/build\.sh|scripts/smoke-test\.sh|scripts/smoke-local\.sh|scripts/smoke-fixture-server\.py|scripts/gen-third-party-notices\.sh|scripts/env\.sh|test-infrastructure/vm/(vm-smoke\.sh|windows-user-path-guard\.ps1)|Makefile\.cbm)'; then |
| 85 | + # A here-string, not a pipe: under this shell's pipefail, grep -q |
| 86 | + # exits on its first match, printf dies of SIGPIPE once the list |
| 87 | + # outgrows the pipe buffer, and the MATCH is then reported as a |
| 88 | + # failure -- product=false, smoke skipped, on the largest PRs. |
| 89 | + if grep -qE '^(src/|internal/|install\.(sh|ps1)|scripts/build\.sh|scripts/smoke-test\.sh|scripts/smoke-local\.sh|scripts/smoke-fixture-server\.py|scripts/gen-third-party-notices\.sh|scripts/env\.sh|test-infrastructure/vm/(vm-smoke\.sh|windows-user-path-guard\.ps1)|Makefile\.cbm)' <<<"$FILES"; then |
70 | 90 | echo "product=true" >> "$GITHUB_OUTPUT" |
71 | 91 | else |
72 | 92 | echo "product=false" >> "$GITHUB_OUTPUT" |
|
0 commit comments