-
Notifications
You must be signed in to change notification settings - Fork 5
111 lines (95 loc) · 4.74 KB
/
ddn-test.yaml
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
name: Axiom auto-test
permissions:
contents: read
pull-requests: write
on:
pull_request:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Check for [no-op] in commit message
run: |
if [[ "${{ github.event.pull_request.title }}" =~ ^\[no-op\] ]]; then
echo "no_op=true" >> $GITHUB_ENV
else
echo "no_op=false" >> $GITHUB_ENV
fi
- name: Set up DDN CLI and login
if: env.no_op != 'true'
uses: hasura/ddn-deployment@main
with:
hasura-pat: ${{ secrets.HASURA_PAT }}
- name: Install dependencies (jq)
if: env.no_op != 'true'
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Prep repository
if: env.no_op != 'true'
run: |
cp hasura/.env.telco.template hasura/.env.telco
cp .data/.env.template .data/telco/.env
- name: Build all supergraphs
working-directory: ./hasura
if: env.no_op != 'true'
run: |
ddn supergraph build local --supergraph supergraph-config/telco/1-supergraph-project-queries.yaml
ddn supergraph build local --supergraph supergraph-config/telco/2-supergraph-domain.yaml
ddn supergraph build local --supergraph supergraph-config/telco/3-supergraph.yaml
ddn supergraph build local --supergraph supergraph-config/telco/4-supergraph-with-mutations.yaml
- name: Set up demo databases & Run DDN
working-directory: ./hasura
if: env.no_op != 'true'
env:
HASURA_DDN_PAT: ${{ secrets.HASURA_PAT }}
run: |
ddn run demo -- telco
- name: Wait for DDN to be ready
if: env.no_op != 'true'
run: |
echo "Waiting for GraphQL service to start..."
until curl -s http://localhost:3280/graphql -o /dev/null; do
echo "Service not ready, retrying in 5 seconds..."
sleep 5
done
echo "Service is up!"
- name: Query DDN endpoint and validate response
if: env.no_op != 'true'
run: |
# Add a 5s delay here for the pg databases to populate before running the queries
sleep 5
QUERY='{
"query": "query getUsers { usersById(id: 1) { email } customers(limit: 1) { firstName lastName email segment customerLinks { customerPreferences { socialMedia { linkedin } } supportDB { supportHistory { date status } } } creditCards { maskCreditCard expiry cvv } billings { formatBillingDate paymentStatus totalAmount } } calls(limit: 1) { callid } cdr(limit: 1) { guid } documents(limit: 1) { uuid } }"
}'
EXPECTED_RESPONSE='{"data":{"usersById":{"email":"[email protected]"},"customers":[{"firstName":"Adam","lastName":"Mcdaniel","email":"[email protected]","segment":"family","customerLinks":[{"customerPreferences":{"socialMedia":{"linkedin":null}},"supportDB":{"supportHistory":[{"date":"2020-03-22","status":"Resolved"}]}}],"creditCards":[{"maskCreditCard":"***********8922","expiry":"2028-04-23","cvv":651}],"billings":[{"formatBillingDate":"Thu Feb 02 2023","paymentStatus":"overdue","totalAmount":"50.50"}]}],"calls":[],"cdr":[{"guid":"96dbde7a-aa94-466e-9480-666220398fff"}],"documents":[{"uuid":"a1b2c3d4-5e6f-7a8b-9c0d-1e2f3a4b5c6d"}]}}'
RESPONSE=$(curl -s -X POST "http://localhost:3280/graphql" -H "Content-Type: application/json" -d "$QUERY")
# Compare the actual response with the expected response
if echo "$RESPONSE" | jq -e --argjson expected "$EXPECTED_RESPONSE" '. == $expected' > /dev/null; then
echo "✅ Response matches expected output."
else
echo "❌ Response does not match expected output."
echo "Expected: $EXPECTED_RESPONSE"
echo "Got: $RESPONSE"
exit 1
fi
- name: Query RESTified endpoint and validate response
if: env.no_op != 'true'
run: |
EXPECTED_RESPONSE='{"data":{"users":[{"id":1,"email":"[email protected]","roles":"customer"}]}}'
RESPONSE=$(curl -s -X GET "http://localhost:3280/v1/api/rest/users?limit=1" -H "Content-Type: application/json")
# Compare the actual response with the expected response
if echo "$RESPONSE" | jq -e --argjson expected "$EXPECTED_RESPONSE" '. == $expected' > /dev/null; then
echo "✅ Response matches expected output."
else
echo "❌ Response does not match expected output."
echo "Expected: $EXPECTED_RESPONSE"
echo "Got: $RESPONSE"
exit 1
fi