diff --git a/.ci/apt-install-postgres b/.ci/apt-install-postgres deleted file mode 100755 index 1f3032f..0000000 --- a/.ci/apt-install-postgres +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/bash - -set -e - -# Determine the version of PostgreSQL. -if [ -z ${1+x} ]; then - echo "ERROR: No PostgreSQL version number passed to $0" - echo "Usage:" - echo " $0 \$PGVERSION" - exit 2 -fi - -PGVERSION=${1:-} - -apt-get update -apt-get install -y --no-install-recommends \ - build-essential clang llvm llvm-dev llvm-runtime cmake \ - ca-certificates gnupg2 curl libicu-dev libxml2 locales ssl-cert libxml2-utils -apt-get -y purge postgres* - -curl https://salsa.debian.org/postgresql/postgresql-common/-/raw/master/pgdg/apt.postgresql.org.sh -O --output-dir /usr/local/bin/ -chmod +x /usr/local/bin/apt.postgresql.org.sh - -apt.postgresql.org.sh -i -v "$PGVERSION" -chmod a+rwx "$(pg_config --pkglibdir)" "$(pg_config --sharedir)/extension" - -pg_createcluster --start "$PGVERSION" test -p "${PGPORT:-5433}" -- -A trust || true diff --git a/.ci/test-cover b/.ci/test-cover index cdc2da6..875b0ab 100755 --- a/.ci/test-cover +++ b/.ci/test-cover @@ -24,8 +24,16 @@ if [ "$(uname -o)" = "Darwin" ]; then export RUSTFLAGS="-Clink-arg=-Wl,-undefined,dynamic_lookup $RUSTFLAGS" fi +coverargs=() +if [ -n "${PGUSER}" ]; then + coverargs+=(--runas "$PGUSER") +fi +if [ -n "${PGDATA}" ]; then + coverargs+=(--pgdata "$PGDATA") +fi + export LLVM_PROFILE_FILE="${DESTDIR}/default_%m_%p.profraw" -cargo test --all --no-default-features --features "pg${PGVERSION} pg_test" -- --nocapture +cargo pgrx test "${coverargs[@]}" "pg${PGVERSION}" grcov "${DESTDIR}" \ --ignore '**/clang-sys*/**' \ diff --git a/.github/workflows/lint-and-test.yml b/.github/workflows/lint-and-test.yml index 1c66251..2783c17 100644 --- a/.github/workflows/lint-and-test.yml +++ b/.github/workflows/lint-and-test.yml @@ -5,20 +5,35 @@ on: branches-ignore: [wip/**] jobs: + test: + runs-on: ubuntu-latest + container: pgxn/pgxn-tools + strategy: + matrix: + pg: [11, 12, 13, 14, 15, 16] + name: 🐘 Postgres ${{ matrix.pg }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Start PostgreSQL ${{ matrix.pg }} + run: pg-start ${{ matrix.pg }} + - name: Setup Rust Cache + uses: Swatinem/rust-cache@v2 + - name: Test on PostgreSQL ${{ matrix.pg }} + run: pgrx-build-test + lint: - name: 🔎 Lint and Cover + name: ✅ Lint and Cover runs-on: ubuntu-latest + container: pgxn/pgxn-tools env: { PGVERSION: 16 } steps: - name: Checkout uses: actions/checkout@v4 - - name: Setup Rust Toolchain - uses: dtolnay/rust-toolchain@stable - with: { components: "rustfmt, clippy" } + - name: Start PostgreSQL ${{ env.PGVERSION }} + run: pg-start ${{ env.PGVERSION }} - name: Setup Rust Cache uses: Swatinem/rust-cache@v2 - - name: Install Postgres - run: sudo ./.ci/apt-install-postgres ${{ env.PGVERSION }} - name: Install pgrx run: make install-pgrx - name: Initialize pgrx @@ -26,43 +41,10 @@ jobs: - name: Format and Lint run: make lint - name: Generate Coverage - run: make cover RUST_BACKTRACE=1 PGUSER=postgres + run: make cover RUST_BACKTRACE=1 PGUSER=postgres PGDATA=/var/lib/postgresql/pgrx - name: Publish Coverage uses: codecov/codecov-action@v4 with: token: ${{ secrets.CODECOV_TOKEN }} slug: tembo-io/pg-jsonschema-boon files: target/cover/cobertura.xml - - name: Remove Data Diretory - run: rm -rf target/pgrx-test-data-${{ env.PGVERSION }} - - test: - runs-on: ubuntu-latest - strategy: - matrix: - pg: [11, 12, 13, 14, 15, 16] - os: [[🐧, Ubuntu]] # [🍎, macOS], [🪟, Windows]] - name: 🐘 Postgres ${{ matrix.pg }} on ${{ matrix.os[0] }} ${{ matrix.os[1] }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Setup Rust Toolchain - uses: dtolnay/rust-toolchain@stable - - name: Install Postgres ${{ matrix.pg }} - run: sudo ./.ci/apt-install-postgres ${{ matrix.pg }} - - name: Setup Rust Cache - uses: Swatinem/rust-cache@v2 - - name: Install pgrx - run: make install-pgrx - - name: Remove Data Diretory - run: rm -rf target/pgrx-test-data-${{ matrix.pg }} - - name: Initialize pgrx - run: make pgrx-init - - name: Run the tests - run: make test RUST_BACKTRACE=1 PGUSER=postgres - - name: Install - run: make install - - name: Run Install Check - run: make installcheck PGUSER=postgres PGPORT=5433 - - name: Remove Data Diretory - run: rm -rf target/pgrx-test-data-${{ matrix.pg }}