Skip to content

Commit f99ff20

Browse files
committed
feat(experimental): a graphql check against core
1 parent a9ee81d commit f99ff20

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: 🔒 Validate GitHub repository with GraphQL schema
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
graphql-validation:
10+
name: Validate GraphQL
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: 20
17+
18+
- name: Fetch repository
19+
uses: actions/checkout@v3
20+
with:
21+
path: ".tmp"
22+
23+
- name: Get core key from compatibility.md
24+
id: get-core-key
25+
run: |
26+
core_version=$(grep '^core:' .tmp/docs/compatibility.md | cut -d ' ' -f 2)
27+
echo "core_version=$core_version" >> $GITHUB_ENV
28+
29+
- name: Run codegen
30+
run: |
31+
cat <<EOF > codegen.yml
32+
schema: "https://raw.githubusercontent.com/opencrvs/opencrvs-core/refs/heads/${{ env.core_version }}/packages/gateway/src/graphql/schema.graphql"
33+
documents: ".tmp/**/*.{graphql,js,ts,jsx,tsx}"
34+
generates:
35+
./throwaway.ts:
36+
plugins:
37+
- "typescript"
38+
- "typescript-operations"
39+
- "typescript-resolvers"
40+
EOF
41+
42+
npm install @graphql-codegen/cli@5.0.2 \
43+
@graphql-codegen/typescript@4.0.9 \
44+
@graphql-codegen/typescript-operations@4.2.3 \
45+
@graphql-codegen/typescript-resolvers@4.2.1 \
46+
graphql@16.9.0
47+
48+
npx graphql-codegen
49+
50+
if [ $? -ne 0 ]; then
51+
echo "### :x: GraphQL Validation Failed" >> $GITHUB_STEP_SUMMARY
52+
echo "The GraphQL schema validation encountered errors. Please check the logs for more details." >> $GITHUB_STEP_SUMMARY
53+
else
54+
echo "### :white_check_mark: GraphQL Validation Passed" >> $GITHUB_STEP_SUMMARY
55+
echo "The GraphQL schema validation completed successfully." >> $GITHUB_STEP_SUMMARY
56+
fi

0 commit comments

Comments
 (0)