From 4e9b70bead663e94525f24d736dad1024a0a4920 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Wed, 20 Nov 2019 11:04:31 -0800 Subject: [PATCH 1/4] Exit with error code when create-test-tables fails --- script/create-test-tables.js | 43 +++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/script/create-test-tables.js b/script/create-test-tables.js index c887629ec..2749c95b6 100644 --- a/script/create-test-tables.js +++ b/script/create-test-tables.js @@ -38,15 +38,36 @@ 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) SELECT * FROM UNNEST ($1::text[], $2::integer[])', + [ + people.map((person) => person.name), + people.map((person) => person.age), + ], + (err, result) => { + if (err) { + throw err + } + + console.log(`Inserted ${result.rowCount} people`) + con.end() + }) + }) }) From 867b67482e748a901a84f988c6c3a2fb4eac1716 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Wed, 20 Nov 2019 12:30:06 -0800 Subject: [PATCH 2/4] =?UTF-8?q?Preserve=20create-test-tables=E2=80=99s=20c?= =?UTF-8?q?ompatibility=20with=20PostgreSQL=20<9.4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/create-test-tables.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/script/create-test-tables.js b/script/create-test-tables.js index 2749c95b6..e2110313a 100644 --- a/script/create-test-tables.js +++ b/script/create-test-tables.js @@ -56,11 +56,10 @@ con.connect((err) => { console.log('Filling it with people') con.query( - 'INSERT INTO person (name, age) SELECT * FROM UNNEST ($1::text[], $2::integer[])', - [ - people.map((person) => person.name), - people.map((person) => person.age), - ], + 'INSERT INTO person (name, age) VALUES' + + people + .map((person) => ` ('${person.name}', ${person.age})`) + .join(','), (err, result) => { if (err) { throw err From 664e98fad9454ce044cf482d37d03b763fe817b6 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Fri, 16 Aug 2019 14:45:47 -0700 Subject: [PATCH 3/4] Add PostgreSQL 10 to CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit and change to Ubuntu 18.04 so building OpenSSL isn’t necessary, and move old PostgreSQL version tests to the latest Node LTS. --- .travis.yml | 63 +++++++++++++++++++---------------- ci_scripts/build.sh | 9 ----- ci_scripts/install_libpq.sh | 38 --------------------- ci_scripts/install_openssl.sh | 35 ------------------- 4 files changed, 34 insertions(+), 111 deletions(-) delete mode 100644 ci_scripts/build.sh delete mode 100644 ci_scripts/install_libpq.sh delete mode 100644 ci_scripts/install_openssl.sh diff --git a/.travis.yml b/.travis.yml index ee95ab265..672c48107 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,50 +1,55 @@ 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 + - 12 + +addons: + postgresql: "10" + matrix: include: - - node_js: "lts/boron" - addons: - postgresql: "9.6" - - node_js: "lts/argon" - addons: - postgresql: "9.6" - - node_js: "10" + # different Node versions on PostgreSQL 9.5 that require precise + - node_js: lts/argon addons: - postgresql: "9.6" - - node_js: "12" - addons: - postgresql: "9.6" - - node_js: "lts/carbon" + postgresql: "9.5" + dist: precise + - node_js: lts/boron addons: - postgresql: "9.1" + postgresql: "9.5" dist: precise - - node_js: "lts/carbon" + - node_js: lts/carbon addons: - postgresql: "9.2" - - node_js: "lts/carbon" + postgresql: "9.5" + dist: precise + + # different PostgreSQL versions on Node LTS + - node_js: lts/dubnium addons: postgresql: "9.3" - - node_js: "lts/carbon" + - node_js: lts/dubnium addons: postgresql: "9.4" - - node_js: "lts/carbon" + - node_js: lts/dubnium addons: postgresql: "9.5" - - node_js: "lts/carbon" + - node_js: lts/dubnium addons: postgresql: "9.6" + + # PostgreSQL 9.1 and 9.2 only work on precise + - node_js: lts/carbon + addons: + postgresql: "9.1" + dist: precise + - node_js: lts/carbon + addons: + postgresql: "9.2" + dist: precise diff --git a/ci_scripts/build.sh b/ci_scripts/build.sh deleted file mode 100644 index 707bf4d55..000000000 --- a/ci_scripts/build.sh +++ /dev/null @@ -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 diff --git a/ci_scripts/install_libpq.sh b/ci_scripts/install_libpq.sh deleted file mode 100644 index 936c7d645..000000000 --- a/ci_scripts/install_libpq.sh +++ /dev/null @@ -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" diff --git a/ci_scripts/install_openssl.sh b/ci_scripts/install_openssl.sh deleted file mode 100644 index 24c0d3a5a..000000000 --- a/ci_scripts/install_openssl.sh +++ /dev/null @@ -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" From 9284f2445d3359341a8da76ffa3e37395ec711f6 Mon Sep 17 00:00:00 2001 From: Charmander <~@charmander.me> Date: Wed, 20 Nov 2019 11:58:48 -0800 Subject: [PATCH 4/4] Add Node 13 to CI --- .travis.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 672c48107..94b3da4e7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,7 +9,8 @@ env: node_js: - lts/dubnium - - 12 + - lts/erbium + - 13 addons: postgresql: "10" @@ -31,16 +32,16 @@ matrix: dist: precise # different PostgreSQL versions on Node LTS - - node_js: lts/dubnium + - node_js: lts/erbium addons: postgresql: "9.3" - - node_js: lts/dubnium + - node_js: lts/erbium addons: postgresql: "9.4" - - node_js: lts/dubnium + - node_js: lts/erbium addons: postgresql: "9.5" - - node_js: lts/dubnium + - node_js: lts/erbium addons: postgresql: "9.6"