diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f07918eb8..d79f79714 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -34,11 +34,29 @@ jobs: # if: steps.node-modules-cache.outputs.cache-hit != 'true' run: yarn install - # 5. Build only if build artifacts aren't cached + # 5. Check codegen is up to date + - name: Check codegen is up to date + run: | + echo "Running codegen to check if outputs are current..." + yarn generate + + echo "Checking if codegen outputs changed..." + if ! git diff --exit-code src/generated/; then + echo "❌ Codegen outputs are outdated!" + echo "The following files have changes:" + git diff --name-only src/generated/ + echo "" + echo "Please run 'yarn generate' locally and commit the changes." + exit 1 + fi + + echo "✅ Codegen outputs are up to date" + + # 6. Build only if build artifacts aren't cached - name: Build run: yarn build - # 6. Run tests + # 7. Run tests - name: Run tests run: yarn test diff --git a/.husky/pre-commit b/.husky/pre-commit index b903358dc..dc141bace 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,6 +1,32 @@ # Get list of staged files before running formatter/linter STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACMR) +# Check if any GraphQL queries or schema-related files are being committed +GRAPHQL_FILES=$(echo "$STAGED_FILES" | grep -E '\.(graphql|gql)$' || true) +SCHEMA_RELATED_FILES=$(echo "$STAGED_FILES" | grep -E '(codegen\.ts|wagmi\.config\.ts)$' || true) + +# If GraphQL or schema files are being committed, check codegen +if [ -n "$GRAPHQL_FILES" ] || [ -n "$SCHEMA_RELATED_FILES" ]; then + echo "🔍 GraphQL or schema files detected, checking codegen..." + + # Run codegen + yarn generate + + # Check if codegen outputs changed + if ! git diff --exit-code src/generated/; then + echo "⚠️ Codegen outputs have changed!" + echo "The following files were updated:" + git diff --name-only src/generated/ + echo "" + echo "These changes will be automatically staged for commit." + + # Stage the generated files + git add src/generated/ + else + echo "✅ Codegen outputs are up to date" + fi +fi + # Run format and lint yarn format-and-lint diff --git a/src/generated/contractHooks.ts b/src/generated/contractHooks.ts index 6b1086fdc..4f43e0ec8 100644 --- a/src/generated/contractHooks.ts +++ b/src/generated/contractHooks.ts @@ -19581,3 +19581,4 @@ export const useWatchTractorHelpers_OperatorReward = address: tractorHelpersAddress, eventName: 'OperatorReward', }) +// manual change to test CI failure