Skip to content

Commit b8b1986

Browse files
committed
fix(ci): fail-safe change detector — git tree diff instead of gh api
The required-check shim in elixir-ci.yml called `gh api .../pulls/N/files --paginate` and hard-failed the job when the response was not JSON ('invalid character <'), which struck every job on this PR twice in a row. Per the estate required-gate convention the detector must fail SAFE: default to running the suite, and skip only when a successful diff shows nothing relevant. Replaced with a two-dot git tree diff against the fetched base tip (works on shallow checkouts, no gh/API dependency); any detector failure now yields relevant=true. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017LDhR8gtnittEWSafunnrq
1 parent c9dd706 commit b8b1986

1 file changed

Lines changed: 26 additions & 12 deletions

File tree

.github/workflows/elixir-ci.yml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,24 @@ jobs:
3434
- name: Detect relevant changes
3535
id: detect
3636
working-directory: ${{ github.workspace }}
37-
env:
38-
GH_TOKEN: ${{ github.token }}
3937
run: |
4038
set -euo pipefail
4139
PATTERN='^elixir-mcp/'
40+
# Fail-safe detector (estate required-gate convention): default to
41+
# running the suite; skip ONLY when a successful diff against the
42+
# base tip shows nothing relevant. Uses git (two-dot tree diff, so
43+
# shallow checkouts work) instead of `gh api`, whose non-JSON error
44+
# responses hard-failed this step (#51).
4245
if [ "${{ github.event_name }}" = "pull_request" ]; then
43-
FILES=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" --paginate --jq '.[].filename')
44-
if printf '%s\n' "$FILES" | grep -qE "$PATTERN"; then
45-
echo "relevant=true" >> "$GITHUB_OUTPUT"
46+
if git fetch --no-tags --depth=1 origin "${{ github.base_ref }}" \
47+
&& FILES=$(git diff --name-only FETCH_HEAD HEAD); then
48+
if printf '%s\n' "$FILES" | grep -qE "$PATTERN"; then
49+
echo "relevant=true" >> "$GITHUB_OUTPUT"
50+
else
51+
echo "relevant=false" >> "$GITHUB_OUTPUT"; echo "No elixir-mcp changes — pass-through (required-check shim)."
52+
fi
4653
else
47-
echo "relevant=false" >> "$GITHUB_OUTPUT"; echo "No elixir-mcp changes — pass-through (required-check shim)."
54+
echo "relevant=true" >> "$GITHUB_OUTPUT"; echo "Detector could not compute the diff — failing safe (run=true)."
4855
fi
4956
else
5057
echo "relevant=true" >> "$GITHUB_OUTPUT"
@@ -92,17 +99,24 @@ jobs:
9299
- name: Detect relevant changes
93100
id: detect
94101
working-directory: ${{ github.workspace }}
95-
env:
96-
GH_TOKEN: ${{ github.token }}
97102
run: |
98103
set -euo pipefail
99104
PATTERN='^elixir-mcp/'
105+
# Fail-safe detector (estate required-gate convention): default to
106+
# running the suite; skip ONLY when a successful diff against the
107+
# base tip shows nothing relevant. Uses git (two-dot tree diff, so
108+
# shallow checkouts work) instead of `gh api`, whose non-JSON error
109+
# responses hard-failed this step (#51).
100110
if [ "${{ github.event_name }}" = "pull_request" ]; then
101-
FILES=$(gh api "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" --paginate --jq '.[].filename')
102-
if printf '%s\n' "$FILES" | grep -qE "$PATTERN"; then
103-
echo "relevant=true" >> "$GITHUB_OUTPUT"
111+
if git fetch --no-tags --depth=1 origin "${{ github.base_ref }}" \
112+
&& FILES=$(git diff --name-only FETCH_HEAD HEAD); then
113+
if printf '%s\n' "$FILES" | grep -qE "$PATTERN"; then
114+
echo "relevant=true" >> "$GITHUB_OUTPUT"
115+
else
116+
echo "relevant=false" >> "$GITHUB_OUTPUT"; echo "No elixir-mcp changes — pass-through (required-check shim)."
117+
fi
104118
else
105-
echo "relevant=false" >> "$GITHUB_OUTPUT"; echo "No elixir-mcp changes — pass-through (required-check shim)."
119+
echo "relevant=true" >> "$GITHUB_OUTPUT"; echo "Detector could not compute the diff — failing safe (run=true)."
106120
fi
107121
else
108122
echo "relevant=true" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)