-
Notifications
You must be signed in to change notification settings - Fork 0
111 lines (90 loc) · 3.35 KB
/
test-cases.yml
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: Test NDC Test Cases (Relational DB)
on:
workflow_dispatch:
inputs:
ref:
description: 'Branch, tag or SHA to test'
required: true
default: 'main'
type: string
push:
branches:
- main
jobs:
validate-test-cases:
runs-on: ubuntu-latest
steps:
- name: Checkout ndc-test-cases
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref || github.ref }}
- name: Setup Docker
uses: docker/setup-buildx-action@v3
- name: Start PostgreSQL
working-directory: static/relational/postgres
run: |
docker compose up -d postgres
# Wait for PostgreSQL to be healthy
until docker compose ps postgres | grep "healthy"; do
echo "Waiting for PostgreSQL..."
sleep 5
done
- name: Setup NDC Postgres
working-directory: static/relational/postgres
env:
CONNECTION_URI: postgresql://postgres:postgres@postgres:5432/postgres
run: |
# Get latest NDC Postgres version
NDC_POSTGRES_VERSION=$(curl -s https://api.github.com/repos/hasura/ndc-postgres/releases/latest | jq -r .tag_name)
echo "Using NDC Postgres version: ${NDC_POSTGRES_VERSION}"
# Download and setup NDC Postgres
BINARY_URL="https://github.com/hasura/ndc-postgres/releases/download/${NDC_POSTGRES_VERSION}/ndc-postgres-cli-x86_64-unknown-linux-gnu"
curl -L --fail -o ndc-postgres-cli "${BINARY_URL}"
chmod +x ndc-postgres-cli
mkdir -p ndc-metadata
cd ndc-metadata
echo "Initializing NDC Postgres configuration"
../ndc-postgres-cli initialize
echo "Updating NDC Postgres configuration"
# Initialize and configure NDC using existing metadata
../ndc-postgres-cli update
cd ..
echo "Starting NDC Postgres connector"
# Start NDC service
docker compose up -d connector
# Wait for NDC service to be healthy
until docker compose ps connector | grep "healthy"; do
echo "Waiting for NDC service..."
sleep 5
if docker compose ps connector | grep -q "(Exit"; then
echo "Error: NDC service failed to start"
docker compose logs connector
exit 1
fi
done
- name: Download and Setup NDC Test
working-directory: static/relational/postgres
run: |
curl -L --fail -o ndc-test https://github.com/hasura/ndc-spec/releases/download/v0.1.6/ndc-test-x86_64-unknown-linux-gnu
chmod +x ndc-test
- name: Run Tests
working-directory: static/relational/postgres
run: |
./ndc-test replay --endpoint http://localhost:8080 --snapshots-dir ../../relational
- name: Collect Logs on Failure
if: failure()
working-directory: static/relational/postgres
run: |
mkdir -p logs
docker compose logs postgres > logs/postgres.log
docker compose logs connector > logs/connector.log
- name: Upload Logs
if: always()
uses: actions/upload-artifact@v3
with:
name: test-logs
path: static/relational/postgres/logs/
retention-days: 7
permissions:
contents: read
pull-requests: read