|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright (c) 2019-2020, Postgres Professional |
| 5 | +# |
| 6 | + |
| 7 | + |
| 8 | +PG_SRC=$PWD/postgres |
| 9 | + |
| 10 | +# # Here PG_VERSION is provided by postgres:X-alpine docker image |
| 11 | +# curl "https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2" -o postgresql.tar.bz2 |
| 12 | +# echo "$PG_SHA256 *postgresql.tar.bz2" | sha256sum -c - |
| 13 | + |
| 14 | +# mkdir $PG_SRC |
| 15 | + |
| 16 | +# tar \ |
| 17 | +# --extract \ |
| 18 | +# --file postgresql.tar.bz2 \ |
| 19 | +# --directory $PG_SRC \ |
| 20 | +# --strip-components 1 |
| 21 | + |
| 22 | +# Clone Postgres |
| 23 | +echo "############### Getting Postgres sources" |
| 24 | +git clone https://github.com/postgres/postgres.git -b $PG_BRANCH --depth=1 |
| 25 | + |
| 26 | +# Clone pg_probackup |
| 27 | +echo "############### Getting pg_probackup sources" |
| 28 | +git clone https://github.com/postgrespro/pg_probackup.git --depth=1 |
| 29 | + |
| 30 | +# Compile and install Postgres |
| 31 | +cd postgres # Go to postgres dir |
| 32 | +echo "############### Applying ptrack patch" |
| 33 | +git apply -v -3 ../patches/$PG_BRANCH-ptrack-core.diff |
| 34 | + |
| 35 | +echo "############### Compiling Postgres" |
| 36 | +./configure --prefix=$PGHOME --enable-debug --enable-cassert --enable-depend --enable-tap-tests |
| 37 | +make -s -j$(nproc) install |
| 38 | +make -s -j$(nproc) -C contrib/ install |
| 39 | + |
| 40 | +# Override default Postgres instance |
| 41 | +export PATH=$PGHOME/bin:$PATH |
| 42 | +export LD_LIBRARY_PATH=$PGHOME/lib |
| 43 | +export PG_CONFIG=$(which pg_config) |
| 44 | + |
| 45 | +# Get amcheck if missing |
| 46 | +if [ ! -d "contrib/amcheck" ]; then |
| 47 | + echo "############### Getting missing amcheck" |
| 48 | + git clone https://github.com/petergeoghegan/amcheck.git --depth=1 contrib/amcheck |
| 49 | + make USE_PGXS=1 -C contrib/amcheck install |
| 50 | +fi |
| 51 | + |
| 52 | +# Get back to testdir |
| 53 | +cd .. |
| 54 | + |
| 55 | +# Build and install ptrack extension |
| 56 | +echo "############### Compiling and installing ptrack extension" |
| 57 | +make USE_PGXS=1 install |
| 58 | + |
| 59 | +# Show pg_config path (just in case) |
| 60 | +echo "############### pg_config path" |
| 61 | +which pg_config |
| 62 | + |
| 63 | +# Show pg_config just in case |
| 64 | +echo "############### pg_config" |
| 65 | +pg_config |
| 66 | + |
| 67 | +# Build and install pg_probackup (using PG_CPPFLAGS and SHLIB_LINK for gcov) |
| 68 | +echo "############### Compiling and installing pg_probackup" |
| 69 | +cd pg_probackup # Go to pg_probackup dir |
| 70 | +# make USE_PGXS=1 PG_CPPFLAGS="-coverage" SHLIB_LINK="-coverage" top_srcdir=$CUSTOM_PG_SRC install |
| 71 | +make USE_PGXS=1 top_srcdir=$PG_SRC install |
| 72 | + |
| 73 | +# Setup python environment |
| 74 | +echo "############### Setting up python env" |
| 75 | +virtualenv pyenv |
| 76 | +source pyenv/bin/activate |
| 77 | +pip install testgres==1.8.2 |
| 78 | + |
| 79 | +echo "############### Testing" |
| 80 | +if [ "$MODE" = "basic" ]; then |
| 81 | + export PG_PROBACKUP_TEST_BASIC=ON |
| 82 | +fi |
| 83 | +python -m unittest -v tests.ptrack |
| 84 | + |
| 85 | +# Generate *.gcov files |
| 86 | +# gcov src/*.c src/*.h |
| 87 | + |
| 88 | +# Send coverage stats to Codecov |
| 89 | +# bash <(curl -s https://codecov.io/bash) |
0 commit comments