Skip to content

Commit 865d67c

Browse files
authored
Merge pull request #96 from DataSQRL/graphql-lint
Add GraphQL schema linting to CI
2 parents e53ca79 + f8d62d4 commit 865d67c

File tree

1 file changed

+32
-1
lines changed

1 file changed

+32
-1
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,40 @@ jobs:
211211
tags: datasqrl/examples:${{ matrix.tag && matrix.tag != '' && matrix.tag || matrix.path }}
212212
platforms: linux/amd64,linux/arm64
213213

214+
lint-graphql:
215+
name: Lint GraphQL Schemas
216+
runs-on: ubuntu-latest
217+
steps:
218+
- uses: actions/checkout@v4
219+
220+
- name: Lint GraphQL schemas
221+
run: |
222+
SCHEMAS=$(find . -name "*.graphqls" -type f)
223+
if [ -z "$SCHEMAS" ]; then
224+
echo "No GraphQL schemas found"
225+
exit 0
226+
fi
227+
228+
LINT_OPTS="--rules fields-are-camel-cased,types-are-capitalized,enum-values-all-caps,input-object-values-are-camel-cased"
229+
IGNORE='{"fields-are-camel-cased":["Query.Shipment","Query.Vehicle","Query.Customer"]}'
230+
FAILED=0
231+
232+
for schema in $SCHEMAS; do
233+
echo "::group::Checking $schema"
234+
output=$(docker run --rm -v "$PWD":/app -w /app node:18-slim npx graphql-schema-linter $LINT_OPTS --ignore "$IGNORE" "$schema" 2>&1)
235+
result=$?
236+
echo "$output" | grep -v "^npm"
237+
echo "::endgroup::"
238+
if [ $result -ne 0 ]; then
239+
FAILED=1
240+
fi
241+
done
242+
243+
exit $FAILED
244+
214245
ci-summary:
215246
name: build ✅ summary
216-
needs: build
247+
needs: [build, lint-graphql]
217248
runs-on: ubuntu-latest
218249
if: always()
219250
steps:

0 commit comments

Comments
 (0)