diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4772e9bb..8f0cc0fd 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -211,9 +211,40 @@ jobs: tags: datasqrl/examples:${{ matrix.tag && matrix.tag != '' && matrix.tag || matrix.path }} platforms: linux/amd64,linux/arm64 + lint-graphql: + name: Lint GraphQL Schemas + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Lint GraphQL schemas + run: | + SCHEMAS=$(find . -name "*.graphqls" -type f) + if [ -z "$SCHEMAS" ]; then + echo "No GraphQL schemas found" + exit 0 + fi + + LINT_OPTS="--rules fields-are-camel-cased,types-are-capitalized,enum-values-all-caps,input-object-values-are-camel-cased" + IGNORE='{"fields-are-camel-cased":["Query.Shipment","Query.Vehicle","Query.Customer"]}' + FAILED=0 + + for schema in $SCHEMAS; do + echo "::group::Checking $schema" + output=$(docker run --rm -v "$PWD":/app -w /app node:18-slim npx graphql-schema-linter $LINT_OPTS --ignore "$IGNORE" "$schema" 2>&1) + result=$? + echo "$output" | grep -v "^npm" + echo "::endgroup::" + if [ $result -ne 0 ]; then + FAILED=1 + fi + done + + exit $FAILED + ci-summary: name: build ✅ summary - needs: build + needs: [build, lint-graphql] runs-on: ubuntu-latest if: always() steps: