-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
69 lines (61 loc) · 1.93 KB
/
Copy pathaction.yml
File metadata and controls
69 lines (61 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
name: 'GraphQL Schema Linter'
description: 'Lint GraphQL schema files for naming conventions using graphql-schema-linter'
author: 'DataSQRL'
branding:
icon: 'check-circle'
color: 'purple'
inputs:
schemas:
description: 'Glob pattern or space-separated list of schema files to lint'
required: false
default: '**/*.graphqls'
rules:
description: 'Comma-separated list of linting rules'
required: false
default: 'fields-are-camel-cased,types-are-capitalized,enum-values-all-caps,input-object-values-are-camel-cased'
ignore:
description: 'JSON object for ignoring specific rule violations'
required: false
default: '{}'
runs:
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Install graphql-schema-linter
shell: bash
run: npm install -g graphql-schema-linter graphql
- name: Lint GraphQL schemas
shell: bash
env:
INPUT_SCHEMAS: ${{ inputs.schemas }}
INPUT_RULES: ${{ inputs.rules }}
INPUT_IGNORE: ${{ inputs.ignore }}
run: |
if [[ "$INPUT_SCHEMAS" == *"*"* ]]; then
SCHEMAS=$(find . -path "./.git" -prune -o -name "*.graphqls" -type f -print 2>/dev/null)
else
SCHEMAS="$INPUT_SCHEMAS"
fi
if [ -z "$SCHEMAS" ]; then
echo "No GraphQL schemas found"
exit 0
fi
FAILED=0
for schema in $SCHEMAS; do
echo "::group::Checking $schema"
if [ "$INPUT_IGNORE" != "{}" ]; then
output=$(graphql-schema-linter --rules "$INPUT_RULES" --ignore "$INPUT_IGNORE" "$schema" 2>&1)
else
output=$(graphql-schema-linter --rules "$INPUT_RULES" "$schema" 2>&1)
fi
result=$?
echo "$output"
echo "::endgroup::"
if [ $result -ne 0 ]; then
FAILED=1
fi
done
exit $FAILED