1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2026-06-21 01:34:15 +02:00

Travis CI integration

This commit is contained in:
Alexey Kondratov
2020-04-01 15:48:51 +03:00
parent a196073944
commit 615dff5229
7 changed files with 186 additions and 3 deletions
+11
View File
@@ -47,3 +47,14 @@
# Doc files
/doc/*html
# Docker files
/docker-compose.yml
/Dockerfile
/Dockerfile.in
/run_tests.sh
/make_dockerfile.sh
/backup_restore.sh
# Misc
.python-version
+42 -3
View File
@@ -1,7 +1,46 @@
sudo: required
os: linux
dist: bionic
language: c
services:
- docker
- docker
before_install:
- cp travis/* .
install:
- ./make_dockerfile.sh
- docker-compose build
script:
- docker run -v $(pwd):/tests --rm centos:7 /tests/travis/backup_restore.sh
- docker-compose run tests
# - docker-compose run $(bash <(curl -s https://codecov.io/env)) tests
# - docker run -v $(pwd):/tests --rm centos:7 /tests/travis/backup_restore.sh
notifications:
email:
on_success: change
on_failure: always
# Default MODE is basic, i.e. all tests with PG_PROBACKUP_TEST_BASIC=ON
env:
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=archive
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=backup
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=compression
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=delta
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=locking
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=merge
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=page
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=replica
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=retention
- PG_VERSION=12 PG_BRANCH=REL_12_STABLE MODE=restore
- PG_VERSION=11 PG_BRANCH=REL_11_STABLE
- PG_VERSION=10 PG_BRANCH=REL_10_STABLE
- PG_VERSION=9.6 PG_BRANCH=REL9_6_STABLE
jobs:
allow_failures:
- if: env(MODE) IN (archive, backup, delta, locking, merge, page, replica, retention, restore)
+2
View File
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.com/postgrespro/pg_probackup.svg?branch=master)](https://travis-ci.com/postgrespro/pg_probackup)
# pg_probackup
`pg_probackup` is a utility to manage backup and recovery of PostgreSQL database clusters. It is designed to perform periodic backups of the PostgreSQL instance that enable you to restore the server in case of a failure.
+24
View File
@@ -0,0 +1,24 @@
FROM ololobus/postgres-dev:stretch
USER root
RUN apt-get update
RUN apt-get -yq install python python-pip python-virtualenv
# Environment
ENV PG_MAJOR=${PG_VERSION} PG_BRANCH=${PG_BRANCH}
ENV LANG=C.UTF-8 PGHOME=/pg/testdir/pgbin
# Make directories
RUN mkdir -p /pg/testdir
COPY run_tests.sh /run.sh
RUN chmod 755 /run.sh
COPY . /pg/testdir
WORKDIR /pg/testdir
# Grant privileges
RUN chown -R postgres:postgres /pg/testdir
USER postgres
ENTRYPOINT MODE=${MODE} /run.sh
+2
View File
@@ -0,0 +1,2 @@
tests:
build: .
+25
View File
@@ -0,0 +1,25 @@
#!/usr/bin/env sh
if [ -z ${PG_VERSION+x} ]; then
echo PG_VERSION is not set!
exit 1
fi
if [ -z ${PG_BRANCH+x} ]; then
echo PG_BRANCH is not set!
exit 1
fi
if [ -z ${MODE+x} ]; then
MODE=basic
fi
echo PG_VERSION=${PG_VERSION}
echo PG_BRANCH=${PG_BRANCH}
echo MODE=${MODE}
sed \
-e 's/${PG_VERSION}/'${PG_VERSION}/g \
-e 's/${PG_BRANCH}/'${PG_BRANCH}/g \
-e 's/${MODE}/'${MODE}/g \
Dockerfile.in > Dockerfile
+80
View File
@@ -0,0 +1,80 @@
#!/usr/bin/env bash
#
# Copyright (c) 2019-2020, Postgres Professional
#
PG_SRC=$PWD/postgres
# # Here PG_VERSION is provided by postgres:X-alpine docker image
# curl "https://ftp.postgresql.org/pub/source/v$PG_VERSION/postgresql-$PG_VERSION.tar.bz2" -o postgresql.tar.bz2
# echo "$PG_SHA256 *postgresql.tar.bz2" | sha256sum -c -
# mkdir $PG_SRC
# tar \
# --extract \
# --file postgresql.tar.bz2 \
# --directory $PG_SRC \
# --strip-components 1
# Clone Postgres
echo "############### Getting Postgres sources:"
git clone https://github.com/postgres/postgres.git -b $PG_BRANCH --depth=1
# Compile and install Postgres
echo "############### Compiling Postgres:"
cd postgres # Go to postgres dir
./configure --prefix=$PGHOME --enable-debug --enable-cassert --enable-depend --enable-tap-tests
make -s -j$(nproc) install
make -s -j$(nproc) -C contrib/ install
# Override default Postgres instance
export PATH=$PGHOME/bin:$PATH
export LD_LIBRARY_PATH=$PGHOME/lib
export PG_CONFIG=$(which pg_config)
# Get amcheck if missing
if [ ! -d "contrib/amcheck" ]; then
echo "############### Getting missing amcheck:"
git clone https://github.com/petergeoghegan/amcheck.git --depth=1 contrib/amcheck
make USE_PGXS=1 -C contrib/amcheck install
fi
# Get back to testdir
cd ..
# Show pg_config path (just in case)
echo "############### pg_config path:"
which pg_config
# Show pg_config just in case
echo "############### pg_config:"
pg_config
# Build and install pg_probackup (using PG_CPPFLAGS and SHLIB_LINK for gcov)
echo "############### Compiling and installing pg_probackup:"
# make USE_PGXS=1 PG_CPPFLAGS="-coverage" SHLIB_LINK="-coverage" top_srcdir=$CUSTOM_PG_SRC install
make USE_PGXS=1 top_srcdir=$PG_SRC install
# Setup python environment
echo "############### Setting up python env:"
virtualenv pyenv
source pyenv/bin/activate
pip install testgres==1.8.2
echo "############### Testing:"
if [ "$MODE" = "basic" ]; then
export PG_PROBACKUP_TEST_BASIC=ON
python -m unittest -v tests
python -m unittest -v tests.init
else
python -m unittest -v tests.$MODE
fi
# Generate *.gcov files
# gcov src/*.c src/*.h
# Send coverage stats to Codecov
# bash <(curl -s https://codecov.io/bash)