Add PostgreSQL 10 to CI (#1947)

* Exit with error code when create-test-tables fails

* Add PostgreSQL 10 to CI

and change to Ubuntu 18.04 so building OpenSSL isn’t necessary, and move old PostgreSQL version tests to the latest Node LTS.

* Add Node 13 to CI

* Preserve create-test-tables’s compatibility with PostgreSQL <9.4
This commit is contained in:
Charmander 2019-11-20 15:38:40 -08:00 committed by Brian C
parent 30f67bb246
commit 8f56b8c2fd
5 changed files with 71 additions and 127 deletions

View File

@ -1,50 +1,56 @@
language: node_js
sudo: true
dist: trusty
dist: bionic
before_script:
- node script/create-test-tables.js pg://postgres@127.0.0.1:5432/postgres
before_install:
- if [ $TRAVIS_OS_NAME == "linux" ]; then
if [[ $(node -v) =~ v[1-9][0-9] ]]; then
source ./ci_scripts/build.sh;
fi
fi
env:
- CC=clang CXX=clang++ npm_config_clang=1 PGUSER=postgres PGDATABASE=postgres
node_js:
- lts/dubnium
- lts/erbium
- 13
addons:
postgresql: "10"
matrix:
include:
- node_js: "lts/boron"
# different Node versions on PostgreSQL 9.5 that require precise
- node_js: lts/argon
addons:
postgresql: "9.5"
dist: precise
- node_js: lts/boron
addons:
postgresql: "9.5"
dist: precise
- node_js: lts/carbon
addons:
postgresql: "9.5"
dist: precise
# different PostgreSQL versions on Node LTS
- node_js: lts/erbium
addons:
postgresql: "9.3"
- node_js: lts/erbium
addons:
postgresql: "9.4"
- node_js: lts/erbium
addons:
postgresql: "9.5"
- node_js: lts/erbium
addons:
postgresql: "9.6"
- node_js: "lts/argon"
addons:
postgresql: "9.6"
- node_js: "10"
addons:
postgresql: "9.6"
- node_js: "12"
addons:
postgresql: "9.6"
- node_js: "lts/carbon"
# PostgreSQL 9.1 and 9.2 only work on precise
- node_js: lts/carbon
addons:
postgresql: "9.1"
dist: precise
- node_js: "lts/carbon"
- node_js: lts/carbon
addons:
postgresql: "9.2"
- node_js: "lts/carbon"
addons:
postgresql: "9.3"
- node_js: "lts/carbon"
addons:
postgresql: "9.4"
- node_js: "lts/carbon"
addons:
postgresql: "9.5"
- node_js: "lts/carbon"
addons:
postgresql: "9.6"
dist: precise

View File

@ -1,9 +0,0 @@
#!/bin/sh
BUILD_DIR="$(pwd)"
source ./ci_scripts/install_openssl.sh 1.1.1b
sudo updatedb
source ./ci_scripts/install_libpq.sh
sudo updatedb
sudo ldconfig
cd $BUILD_DIR

View File

@ -1,38 +0,0 @@
#!/bin/bash
set -e
OPENSSL_DIR="$(pwd)/openssl-1.1.1b"
POSTGRES_VERSION="11.3"
POSTGRES_DIR="$(pwd)/postgres-${POSTGRES_VERSION}"
TMP_DIR="/tmp/postgres"
JOBS="-j$(nproc || echo 1)"
if [ -d "${TMP_DIR}" ]; then
rm -rf "${TMP_DIR}"
fi
mkdir -p "${TMP_DIR}"
curl https://ftp.postgresql.org/pub/source/v${POSTGRES_VERSION}/postgresql-${POSTGRES_VERSION}.tar.gz | \
tar -C "${TMP_DIR}" -xzf -
cd "${TMP_DIR}/postgresql-${POSTGRES_VERSION}"
if [ -d "${POSTGRES_DIR}" ]; then
rm -rf "${POSTGRES_DIR}"
fi
mkdir -p $POSTGRES_DIR
./configure --prefix=$POSTGRES_DIR --with-openssl --with-includes=${OPENSSL_DIR}/include --with-libraries=${OPENSSL_DIR}/lib --without-readline
cd src/interfaces/libpq; make; make install; cd -
cd src/bin/pg_config; make install; cd -
cd src/backend; make generated-headers; cd -
cd src/include; make install; cd -
export PATH="${POSTGRES_DIR}/bin:${PATH}"
export CFLAGS="-I${POSTGRES_DIR}/include"
export LDFLAGS="-L${POSTGRES_DIR}/lib"
export LD_LIBRARY_PATH="${POSTGRES_DIR}/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="${POSTGRES_DIR}/lib/pkgconfig:$PKG_CONFIG_PATH"

View File

@ -1,35 +0,0 @@
#!/bin/sh
if [ ${#} -lt 1 ]; then
echo "OpenSSL version required." 1>&2
exit 1
fi
OPENSSL_VERSION="${1}"
OPENSSL_DIR="$(pwd)/openssl-${OPENSSL_VERSION}"
TMP_DIR="/tmp/openssl"
JOBS="-j$(nproc)"
if [ -d "${TMP_DIR}" ]; then
rm -rf "${TMP_DIR}"
fi
mkdir -p "${TMP_DIR}"
curl -s https://www.openssl.org/source/openssl-${OPENSSL_VERSION}.tar.gz | \
tar -C "${TMP_DIR}" -xzf -
pushd "${TMP_DIR}/openssl-${OPENSSL_VERSION}"
if [ -d "${OPENSSL_DIR}" ]; then
rm -rf "${OPENSSL_DIR}"
fi
./Configure \
--prefix=${OPENSSL_DIR} \
enable-crypto-mdebug enable-crypto-mdebug-backtrace \
linux-x86_64
make -s $JOBS
make install_sw
popd
export PATH="${OPENSSL_DIR}/bin:${PATH}"
export CFLAGS="-I${OPENSSL_DIR}/include"
export LDFLAGS="-L${OPENSSL_DIR}/lib"
export LD_LIBRARY_PATH="${OPENSSL_DIR}/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="${OPENSSL_DIR}/lib/pkgconfig:$PKG_CONFIG_PATH"

View File

@ -38,15 +38,35 @@ var con = new pg.Client({
password: args.password,
database: args.database
})
con.connect()
var query = con.query('drop table if exists person')
con.query('create table person(id serial, name varchar(10), age integer)', (err, res) => {
console.log('Created table person')
console.log('Filling it with people')
})
people.map(function (person) {
return con.query(new pg.Query("insert into person(name, age) values('" + person.name + "', '" + person.age + "')"))
}).pop().on('end', function () {
console.log('Inserted 26 people')
con.end()
con.connect((err) => {
if (err) {
throw err
}
con.query(
'DROP TABLE IF EXISTS person;'
+ ' CREATE TABLE person (id serial, name varchar(10), age integer)',
(err) => {
if (err) {
throw err
}
console.log('Created table person')
console.log('Filling it with people')
con.query(
'INSERT INTO person (name, age) VALUES'
+ people
.map((person) => ` ('${person.name}', ${person.age})`)
.join(','),
(err, result) => {
if (err) {
throw err
}
console.log(`Inserted ${result.rowCount} people`)
con.end()
})
})
})