Update diligence #383
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | |
lfs: 'true' | |
- 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 | |
working-directory: ./hasura | |
if: env.no_op != 'true' | |
run: | | |
find supergraph-config/* -maxdepth 1 -type d ! -name starter | while read -r dir; do | |
profile=$(basename "$dir") | |
echo "Initialising supergraph: $profile" | |
ddn run init -- "$profile" | |
done | |
- name: Build all supergraphs | |
working-directory: ./hasura | |
if: env.no_op != 'true' | |
run: | | |
find supergraph-config/* -maxdepth 1 -type d ! -name starter | while read -r dir; do | |
profile=$(basename "$dir") | |
for file in "$dir"/*.yaml; do | |
[ -e "$file" ] || continue # skip if no yaml files | |
echo "Building supergraph: $file with profile: $profile" | |
ddn supergraph build local --supergraph "$file" -c "$profile" | |
done | |
done | |
- 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: | | |
# Sleep to allow all containers to be ready before we try to query | |
sleep 20 | |
QUERY='{ | |
"query": "query getUsers { publicCustomers(where: {customerId: {_eq: 7}}) { customerId firstName lastName email satisfactionScore churnRisk customerPlans { customerPlanDevices { device { brand } } } } }" | |
}' | |
EXPECTED_RESPONSE='{"data":{"publicCustomers":[{"customerId":7,"firstName":"Alexis","lastName":"Marchand","email":"alexis.marchand@gmail.com","satisfactionScore":5,"churnRisk":"0.55","customerPlans":[{"customerPlanDevices":[{"device":{"brand":"Apple"}}]}]}]}}' | |
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 |