Skip to content

fixup! ci: Check extension install vs upgrade #99

fixup! ci: Check extension install vs upgrade

fixup! ci: Check extension install vs upgrade #99

Workflow file for this run

name: Run powa-archivist tests
on:
push:
branches:
- master
- ci_validate_extupgrade
pull_request:
branches:
- master
env:
DATADIR: /dev/shm/data
LOGFILE: /dev/shm/data/logfile
RUST: 1.75.0
jobs:
powa-archivist_tests:
name: powa-archivist tests
runs-on: ${{ matrix.os }}
strategy:
matrix:
postgres_major_version: [
"9.5",
"9.6",
"10",
"11",
"12",
"13",
"14",
"15",
"16"
]
os: ["ubuntu-22.04"]
steps:
- uses: actions/checkout@v4
- name: Set up prerequisites and environment
run: |
echo "************ CLEAN IMAGE ***********"
sudo apt remove -y '^postgres.*' '^libpq.*'
echo ""
echo "********* REPOSITORY SET UP ********"
sudo apt-get install -y wget gnupg
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update -y -qq --fix-missing
echo ""
echo "*********** ENVIRONMENT ************"
export PG_MAJOR_VERSION=${{ matrix.postgres_major_version }}
echo "PG_MAJOR_VERSION=$PG_MAJOR_VERSION" >> $GITHUB_ENV
echo "MAKEFLAGS=$MAKEFLAGS -j $(grep -c ^processor /proc/cpuinfo)" >> $GITHUB_ENV
echo ""
echo "******** INSTALL POSTGRES **********"
sudo apt-get install -y \
postgresql-$PG_MAJOR_VERSION \
postgresql-server-dev-$PG_MAJOR_VERSION \
postgresql-contrib-$PG_MAJOR_VERSION
echo ""
echo "******* INSTALL DEPENDENCIES *******"
sudo apt-get install -y \
gcc \
make \
build-essential \
pkg-config
echo ""
echo "********** READJUST PATH ***********"
export PATH=$(pg_config --bindir):$PATH
echo "PATH=$PATH" >> $GITHUB_ENV
cat $GITHUB_ENV
echo ""
- name: Start a postgres ${{ matrix.postgres_major_version }} server
run: |
sudo chmod a+rwx /var/run/postgresql/
pg_ctl -D $DATADIR initdb
echo "shared_preload_libraries = 'pg_stat_statements'" >> $DATADIR/postgresql.conf
pg_ctl -D $DATADIR -l $LOGFILE start || cat $LOGFILE
# a sleep is required for pg9.6 (at least)
sleep 1
psql -c 'select 1 as ok' postgres
- name: Build and install powa-archivist for postgres ${{ matrix.postgres_major_version }}
run: |
make
sudo make install
- name: Run powa-archivist tests for postgres ${{ matrix.postgres_major_version }}
run: make installcheck || ( errcode=$?; cat regression.diffs && exit $errcode )
- name: Check pg_dump for postgres ${{ matrix.postgres_major_version }}
run: pg_dump -d contrib_regression
- name: Check extension install vs upgrade for postgres ${{ matrix.postgres_major_version }}
run: |
# install dependencies
sudo apt-get install -y silversearcher-ag
# install rust
rustup toolchain install ${{ env.RUST }}
# install pg_validate_extupgrade
git clone https://github.com/rjuju/pg_validate_extupgrade.git
cd pg_validate_extupgrade
cargo build
cd ..
# roles created by an extensions are not removed in case of rollback,
# so we create one of the default pseudo predefined roles to make sure
# that no pseudo predefined roles will automatically be created
createuser powa_admin
# get the default extension version
to_ver=$(ag default_version powa.control | ag -o "(\d+\.?)+")
echo "to_ver: ${to_ver}"
pwd
ls -al
# Check the number of extension scripts containing the default versions
nb=$(ls *--*.sql | ag ${to_ver} | wc -l)
# If only one sql script found with the default version, it should be a
# new major version that is allowed to no provide an upgrade script.
if [[ ${nb} -eq 1 ]]; then
# Check that it's a new major version
echo "${to_ver}" | ag '\.0\.0$'
echo "New major version without ugprade script"
exit 0
fi
# Get the previous version
from_ver=$(ls *--*--${new_vew}.sql \
| ag -o 'powa--\d+\.\d+\.\d+' \
| ag -o "\d+\.\d+\.\d+")
# Generate the config file
cat .github/powa-archivist.toml.template \
| sed "s/%%FROM_VER%%/${from_ver}/" \
| sed "s/%%TO_VER%%/${to_ver}/" \
> powa-archivist.toml
# Run pg_validate_extupgrade
./pg_validate_extupgrade/target/debug/pg_validate_extupgrade \
-c ./powa-archivist.toml
- name: Stop the running postgres ${{ matrix.postgres_major_version }} server
run: pg_ctl -D $DATADIR stop