Use a matrix based test for the different PostgreSQL versions.

This adds parallelism for the different versions, and separates the logs.
This commit is contained in:
Dave Page 2023-04-05 16:04:20 +01:00
parent bdb43f84e8
commit 0987c955f5

View File

@ -8,12 +8,14 @@ on:
workflow_dispatch: workflow_dispatch:
env:
POSTGRESQL_VERSIONS: 15 14 13 12 11
jobs: jobs:
build: build:
runs-on: ubuntu-latest strategy:
fail-fast: false
matrix:
pgver: [11, 12, 13, 14, 15]
runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
@ -25,41 +27,29 @@ jobs:
- name: Install platform dependencies - name: Install platform dependencies
run: | run: |
PACKAGES=
for VERSION in ${POSTGRESQL_VERSIONS};
do
PACKAGES="${PACKAGES} postgresql-${VERSION} postgresql-${VERSION}-pldebugger"
done
sudo apt update sudo apt update
sudo apt install -y libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev ${PACKAGES} pgagent sudo apt install -y libpq-dev libffi-dev libssl-dev libkrb5-dev zlib1g-dev postgresql-${{ matrix.pgver }} postgresql-${{ matrix.pgver }}-pldebugger pgagent
- name: Create the tablespace directory - name: Create the tablespace directory
run: | run: |
for VERSION in ${POSTGRESQL_VERSIONS}; sudo mkdir -p /var/lib/postgresql/tablespaces/${{ matrix.pgver }}
do sudo chown postgres:postgres /var/lib/postgresql/tablespaces/${{ matrix.pgver }}
sudo mkdir -p /var/lib/postgresql/tablespaces/${VERSION}
sudo chown postgres:postgres /var/lib/postgresql/tablespaces/${VERSION}
done
- name: Start PostgreSQL - name: Start PostgreSQL
run: | run: |
# Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed # Note: we use a custom port for PostgreSQL as the runner may already have a version of PostgreSQL installed
for VERSION in ${POSTGRESQL_VERSIONS}; sudo su -c "echo local all all trust > /etc/postgresql/${{ matrix.pgver }}/main/pg_hba.conf"
do sudo sed -i "s/port = 543[0-9]/port = 59${{ matrix.pgver }}/g" /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf
sudo su -c "echo local all all trust > /etc/postgresql/${VERSION}/main/pg_hba.conf" sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = '\$libdir\/plugin_debugger'/g" /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf
sudo sed -i "s/port = 543[0-9]/port = 59${VERSION}/g" /etc/postgresql/${VERSION}/main/postgresql.conf sudo su - postgres -c "/usr/lib/postgresql/${{ matrix.pgver }}/bin/postgres -D /var/lib/postgresql/${{ matrix.pgver }}/main -c config_file=/etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf &"
sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = '\$libdir\/plugin_debugger'/g" /etc/postgresql/${VERSION}/main/postgresql.conf
sudo su - postgres -c "/usr/lib/postgresql/${VERSION}/bin/postgres -D /var/lib/postgresql/${VERSION}/main -c config_file=/etc/postgresql/${VERSION}/main/postgresql.conf &"
until sudo runuser -l postgres -c "pg_isready -p 59${VERSION}" 2>/dev/null; do until sudo runuser -l postgres -c "pg_isready -p 59${{ matrix.pgver }}" 2>/dev/null; do
>&2 echo "Postgres is unavailable - sleeping for 2 seconds" >&2 echo "Postgres is unavailable - sleeping for 2 seconds"
sleep 2 sleep 2
done
psql -U postgres -p 59${VERSION} -c 'CREATE EXTENSION pgagent;'
psql -U postgres -p 59${VERSION} -c 'CREATE EXTENSION pldbgapi;'
done done
psql -U postgres -p 59${{ matrix.pgver }} -c 'CREATE EXTENSION pgagent;'
psql -U postgres -p 59${{ matrix.pgver }} -c 'CREATE EXTENSION pldbgapi;'
- name: Install Python dependencies - name: Install Python dependencies
run: make install-python-testing run: make install-python-testing
@ -110,41 +100,22 @@ jobs:
}, },
"server_group": 1, "server_group": 1,
"server_credentials": [ "server_credentials": [
EOF
function add_server_def() {
SEP=","
if [ "$1" = "$2" ]; then
SEP=""
fi
cat <<EOF >> web/regression/test_config.json
{ {
"name": "PostgreSQL $1", "name": "PostgreSQL ${{ matrix.pgver }}",
"comment": "PostgreSQL $1 Server", "comment": "PostgreSQL ${{ matrix.pgver }} Server",
"db_username": "postgres", "db_username": "postgres",
"host": "/var/run/postgresql", "host": "/var/run/postgresql",
"db_password": "postgres", "db_password": "postgres",
"db_port": 59$1, "db_port": 59${{ matrix.pgver }},
"maintenance_db": "postgres", "maintenance_db": "postgres",
"sslmode": "prefer", "sslmode": "prefer",
"tablespace_path": "/var/lib/postgresql/tablespaces/$1", "tablespace_path": "/var/lib/postgresql/tablespaces/${{ matrix.pgver }}",
"enabled": true, "enabled": true,
"default_binary_paths": { "default_binary_paths": {
"pg": "/usr/lib/postgresql/$1/bin", "pg": "/usr/lib/postgresql/${{ matrix.pgver }}/bin",
"ppas": "" "ppas": ""
} }
}${SEP} }
EOF
}
LAST_VERSION=$(echo ${POSTGRESQL_VERSIONS} | awk '{print $NF}')
for VERSION in ${POSTGRESQL_VERSIONS};
do
add_server_def ${VERSION} ${LAST_VERSION}
done
cat <<EOF >> web/regression/test_config.json
], ],
"server_update_data": [ "server_update_data": [
{ {
@ -163,12 +134,12 @@ jobs:
if: success() || failure() if: success() || failure()
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: server-log name: server-log-pg${{ matrix.pgver }}
path: var/pgadmin4.log path: var/pgadmin4.log
- name: Archive regression log - name: Archive regression log
if: success() || failure() if: success() || failure()
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: regression-log name: regression-log-pg${{ matrix.pgver }}
path: web/regression/regression.log path: web/regression/regression.log