fix(ci): stop the codegen gate from skipping itself on a large diff

`git diff --name-only | grep -qE` matched, grep exited, git died on SIGPIPE, and
`pipefail` turned the whole pipeline into a failure — so a push that edited the
schema alongside enough other files printed `changed=false` and skipped the
freshness check entirely. Read the list into a variable and match it in the
shell instead.

The two unresolvable-base cases could not see any of this: they asserted
`changed=true`, which the diff-failed fallback also prints, so deleting the
guard they were named for left them green. The script now names the branch it
took on stderr and they assert that.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Sergey Kozyrenko
2026-07-27 14:21:37 +07:00
co-authored by Claude Opus 5
parent 9e217703f8
commit f42a76b1ea
2 changed files with 53 additions and 5 deletions
+24 -3
View File
@@ -21,16 +21,37 @@ else
fi
# When the range can't be resolved (new branch, force-push, tag), check anyway.
# stdout is consumed verbatim as a workflow output, so diagnostics go to stderr.
if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ] \
|| ! git cat-file -e "$base^{commit}" 2>/dev/null; then
echo "reason=unresolvable-base" >&2
echo "changed=true"
exit 0
fi
# The generated file is in the list too: a push that edits only it would otherwise skip
# the check, and the drift surfaces later on someone else's unrelated codegen push.
if git diff --name-only "$base" "$HEAD_SHA" | grep -qE '^(backend/pkg/graph/schema\.graphqls|frontend/graphql-schema\.graphql|frontend/graphql-codegen\.ts|frontend/pnpm-lock\.yaml|frontend/src/graphql/types\.ts)$'; then
INPUTS=(
backend/pkg/graph/schema.graphqls
frontend/graphql-schema.graphql
frontend/graphql-codegen.ts
frontend/pnpm-lock.yaml
frontend/src/graphql/types.ts
)
if ! files=$(git diff --name-only "$base" "$HEAD_SHA"); then
echo "reason=diff-failed" >&2
echo "changed=true"
else
echo "changed=false"
exit 0
fi
for input in "${INPUTS[@]}"; do
case $'\n'"$files"$'\n' in
*$'\n'"$input"$'\n'*)
echo "changed=true"
exit 0
;;
esac
done
echo "changed=false"