From 47c2c774e395b0f26acf741aab6e1330e153c184 Mon Sep 17 00:00:00 2001 From: shubham yadav <126192924+yadavshubham01@users.noreply.github.com> Date: Tue, 21 Jan 2025 19:13:19 +0530 Subject: [PATCH] Add GraphQL Generation Check to CI Workflow (#9742) This pull request addresses the issue of ensuring that npx nx run twenty-front:graphql:generate and npx nx run twenty-front:graphql:generate --configuration=metadata commands are run to generate the necessary GraphQL files. This prevents changes from being missed and ending up in subsequent unrelated PRs. Changes: Added a step in the ci-server.yml workflow to check for pending GraphQL generation. If any GraphQL changes are detected, the CI will fail, and an error message will be displayed instructing the developer to run the necessary commands and commit the changes. This approach is similar to the existing TypeORM migration check and helps maintain consistency and correctness in the codebase. Issue Resolved: #9726 --------- Co-authored-by: Charles Bochet --- .github/workflows/ci-server.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/ci-server.yaml b/.github/workflows/ci-server.yaml index b72f73563..ba7a40e34 100644 --- a/.github/workflows/ci-server.yaml +++ b/.github/workflows/ci-server.yaml @@ -97,6 +97,19 @@ jobs: exit 1 fi + - name: GraphQL / Check for Pending Generation + if: steps.changed-files.outputs.any_changed == 'true' + run: | + GRAPHQL_GENERATE_OUTPUT=$(npx nx run twenty-front:graphql:generate || true) + GRAPHQL_METADATA_OUTPUT=$(npx nx run twenty-front:graphql:generate --configuration=metadata || true) + if [[ $GRAPHQL_GENERATE_OUTPUT == *"No changes detected"* && $GRAPHQL_METADATA_OUTPUT == *"No changes detected"* ]]; then + echo "GraphQL generation check passed." + else + echo "::error::Unexpected GraphQL changes detected. Please run the required commands and commit the changes." + echo "$GRAPHQL_GENERATE_OUTPUT" + echo "$GRAPHQL_METADATA_OUTPUT" + exit 1 + fi - name: Save server setup uses: ./.github/workflows/actions/save-cache with: