Skip to content

Import data every time #1

Import data every time

Import data every time #1

Workflow file for this run

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