Skip to content

Commit

Permalink
run the checks on any new PR against the main branch also
Browse files Browse the repository at this point in the history
  • Loading branch information
codingkarthik committed Dec 18, 2024
1 parent 3b6ba37 commit 7156122
Showing 1 changed file with 104 additions and 0 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
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: 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: Setup NDC Postgres
working-directory: static/relational/postgres
env:
CONNECTION_URI: postgresql://postgres:[email protected]:5433/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
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

0 comments on commit 7156122

Please sign in to comment.