Skip to content

fix: tables with missing primary key fail with a proper error #123

fix: tables with missing primary key fail with a proper error

fix: tables with missing primary key fail with a proper error #123

Workflow file for this run

name: CI
on:
pull_request:
types: [opened, synchronize, reopened, labeled]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
permissions:
contents: read
jobs:
check:
name: Check
runs-on: ubuntu-latest
strategy:
matrix:
check: [fmt, clippy]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: ${{ matrix.check == 'fmt' && 'rustfmt' || 'clippy' }}
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.check }}
- name: Run cargo fmt
if: matrix.check == 'fmt'
run: cargo fmt --check
- name: Run cargo clippy
if: matrix.check == 'clippy'
run: cargo clippy --all-targets --all-features --no-deps -- -D warnings
test:
name: Test
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
services:
postgres:
image: postgres:15
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5430:5432
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
with:
key: test
- name: Wait for Postgres to be ready
run: |
until pg_isready -h localhost -p 5430; do
echo "Waiting for Postgres..."
sleep 1
done
- name: Start BigQuery emulator
run: |
docker run -d --name bigquery-emulator \
-p 9050:9050 -p 9060:9060 \
ghcr.io/goccy/bigquery-emulator:latest \
--project=local-project \
--dataset=local-dataset \
--port=9050 \
--grpc-port=9060
- name: Wait for BigQuery emulator to be ready
run: |
until curl -s "http://localhost:9050/" > /dev/null; do
echo "Waiting for BigQuery emulator..."
sleep 1
done
- name: Update WAL Settings
# This step is necessary to enable logical replication for the tests
# wal_level = logical is needed because we use logical replication in tests
# max_wal_senders = 100 is needed because we use multiple connections
# to the database in tests, without which the tests would fail
run: |
PGPASSWORD=postgres psql -h localhost -p 5430 -U postgres \
-c "ALTER SYSTEM SET wal_level = 'logical';" \
-c "ALTER SYSTEM SET max_wal_senders = 100;" \
-c "ALTER SYSTEM SET max_replication_slots = 100;"
- name: Restart Postgres service container
run: |
docker restart ${{ job.services.postgres.id }}
- name: Install sqlx-cli
run: |
cargo install sqlx-cli \
--features native-tls,postgres \
--no-default-features \
--locked
- name: Migrate database
run: |
sudo apt-get install libpq-dev -y
SKIP_DOCKER=true ./scripts/init_db.sh
- name: Install cargo-llvm-cov
uses: taiki-e/install-action@cargo-llvm-cov
- name: Set up BigQuery environment variables and credentials
run: |
printf '%s' '${{ secrets.TESTS_BIGQUERY_SA_KEY_JSON }}' > /tmp/bigquery-sa-key.json
echo "TESTS_BIGQUERY_PROJECT_ID=${{ secrets.TESTS_BIGQUERY_PROJECT_ID }}" >> $GITHUB_ENV
echo "TESTS_BIGQUERY_SA_KEY_PATH=/tmp/bigquery-sa-key.json" >> $GITHUB_ENV
- name: Generate code coverage
id: coverage
run: |
cargo llvm-cov test \
--workspace --no-fail-fast \
--lcov --output-path lcov.info
- name: Upload coverage to Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
path-to-lcov: lcov.info
debug: true