From f3311ecadfc732d49bfa84347d509d2661cbd81a Mon Sep 17 00:00:00 2001 From: Sergey Kozyrenko Date: Wed, 22 Jul 2026 12:59:14 +0700 Subject: [PATCH] ci: scope the codegen-freshness check to its inputs and name the fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The check ran on every push and failed with a bare diff, so a backend schema change surfaced as an unexplained red frontend job. Run it only when a codegen input moved — the backend schema, the operations document, the codegen config, or the lockfile (a codegen bump can change the output, and skipping it there would let types.ts go stale and fail someone else's later push). When the compare range can't be resolved (new branch, force-push, tag) it still runs. On failure it now says which command to run. Co-Authored-By: Claude Opus 4.8 --- .github/workflows/ci.yml | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 08052f23..346cdcfb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,14 +67,37 @@ jobs: working-directory: frontend run: pnpm run typescript + # Only when a codegen input moved. The lockfile is included on purpose: a codegen + # version bump can change the output, and skipping it there would let types.ts go + # stale and fail the next schema push for something its author did not do. + # When the range can't be resolved (new branch, force-push, tag), check anyway. + - name: Frontend - Detect GraphQL codegen input changes + id: codegen-inputs + run: | + base='${{ github.event.before }}' + if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ] \ + || ! git cat-file -e "$base^{commit}" 2>/dev/null; then + echo "changed=true" >> "$GITHUB_OUTPUT" + exit 0 + fi + if git diff --name-only "$base" "${{ github.sha }}" | grep -qE '^(backend/pkg/graph/schema\.graphqls|frontend/graphql-schema\.graphql|frontend/graphql-codegen\.ts|frontend/pnpm-lock\.yaml)$'; then + echo "changed=true" >> "$GITHUB_OUTPUT" + else + echo "changed=false" >> "$GITHUB_OUTPUT" + fi + # The app ships the operations compiled into src/graphql/types.ts; regenerate and # diff so it can't drift from graphql-schema.graphql (the codegen input the stand's # schema-compat pre-flight validates against). - name: Frontend - GraphQL codegen is fresh + if: steps.codegen-inputs.outputs.changed == 'true' working-directory: frontend run: | pnpm run graphql:generate - git diff --exit-code src/graphql/types.ts + git diff --exit-code src/graphql/types.ts || { + echo "::error file=frontend/src/graphql/types.ts::src/graphql/types.ts is stale — run 'pnpm run graphql:generate' in frontend/ and commit the result" + exit 1 + } - name: Frontend - Test working-directory: frontend