-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (98 loc) · 3.59 KB
/
pr-test.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
112
113
114
115
116
117
118
119
120
121
122
name: Test NDC Test Cases (PR)
on:
pull_request:
branches:
- main
jobs:
validate-test-cases:
runs-on: ubuntu-latest
steps:
- name: Checkout ndc-test-cases
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Docker
uses: docker/setup-buildx-action@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install Python Dependencies
run: |
pip install psycopg2-binary pandas sqlalchemy
- 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 2
done
- name: Load Data into PostgreSQL
working-directory: static/relational/postgres
run: |
python import-data.py ../../../relational/dataset \
--database postgres \
--user postgres \
--port 5433 \
--password postgres
- name: Setup NDC Postgres
working-directory: static/relational/postgres
env:
CONNECTION_URI: postgresql://postgres:postgres@local.hasura.dev:5433/postgres
run: |
# Get latest NDC Postgres version
NDC_POSTGRES_VERSION=v1.2.0
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
sudo mv ndc-test /usr/local/bin/
- name: Run Tests
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