Skip to content

Commit

Permalink
Add CI job to check graphql schema
Browse files Browse the repository at this point in the history
  • Loading branch information
gustavlrsn committed Jan 20, 2025
1 parent 9a5725f commit 66bd2c8
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ jobs:

- run: npm run langs:check

graphql-update-check:
runs-on: ubuntu-latest
timeout-minutes: 15

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup project
uses: ./.github/actions/setup-project
with:
CACHE_VERSION: ${{ secrets.CACHE_VERSION }}

- run: npm run graphql:check

build:
runs-on: ubuntu-latest

Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@
"docs:generate:contribution-flow": "tsx ./scripts/docs/contribution-flow.js",
"git:clean": "cross-env ./scripts/git_clean.sh",
"graphql:codegen": "graphql-codegen --config scripts/config/graphql-codegen.ts",
"graphql:check": "cross-env scripts/check_graphql_schema.sh",
"graphql:get-schema": "npm-run-all graphql:updateV1 graphql:updateV2",
"graphql:update": "npm-run-all graphql:updateV1 graphql:updateV2 graphql:codegen",
"graphql:updateV1": "tsx ./scripts/update-gql-schemas.js http://localhost:3060/graphql/v1 lib/graphql/schema.graphql && prettier lib/graphql/schema.graphql --write",
Expand Down
23 changes: 23 additions & 0 deletions scripts/check_graphql_schema.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -e
set -x

# Move to the root directory of the project
cd -- "$(dirname $0)/.."

# Update GraphQL schema files
npm run graphql:update

# Check if GraphQL schema files changed
CHANGED=$(git status --porcelain | grep 'schema')
if [ -n "${CHANGED}" ] ; then
echo "GraphQL schema files are not up to date. Please run 'npm run graphql:update'"
echo "-------- FILES --------"
git status
echo "-------- DIFF --------"
git --no-pager diff
exit 1
else
echo "GraphQL schema is up to date."
fi

0 comments on commit 66bd2c8

Please sign in to comment.