From c37245cb64c2fee4fe18f54c6254b09068349f99 Mon Sep 17 00:00:00 2001 From: Mikkel Hoegh Date: Tue, 4 Dec 2018 22:15:54 +0100 Subject: [PATCH 1/3] test: simple docker-compose testing setup Makes it possible to run the tests locally with multiple versions of PostgreSQL and Node.js. --- .env | 7 +++++++ README.md | 13 +++++++++++++ docker-compose.yml | 24 ++++++++++++++++++++++++ test/test_all_versions.sh | 24 ++++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 .env create mode 100644 docker-compose.yml create mode 100755 test/test_all_versions.sh diff --git a/.env b/.env new file mode 100644 index 0000000..809bb3a --- /dev/null +++ b/.env @@ -0,0 +1,7 @@ +# Environment variables for docker-compose +PGHOST=db +PGPASSWORD=pg-cursor-test +POSTGRES_PASSWORD=pg-cursor-test +PGUSER=postgres +POSTGRES_VERSION=9.6 +NODE_VERSION=8 diff --git a/README.md b/README.md index 1b01b3d..ea2c07d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,19 @@ ___note___: this depends on _either_ `npm install pg` or `npm install pg.js`, bu ### :star: [Documentation](https://node-postgres.com/api/cursor) :star: +### Testing + +To run the test suite against all supported versions of PostgreSQL and +Node.js locally, you will need to install and run Docker, and then run + + ./test_all_versions.sh + +This will take a while, and consume a lot of bandwidth downloading Docker +images. + +Due to a [bug in npm][npmbug], the output is very verbose, but with a bit of +scrolling, you should hopefully see green checkmarks for every test run. + ### license The MIT License (MIT) diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..b9b4958 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,24 @@ +version: "3" + +services: + db: + image: "postgres:${POSTGRES_VERSION}" + restart: always + expose: + - 5432 + environment: + - POSTGRES_PASSWORD + test: + image: "node:${NODE_VERSION}" + links: + - db + environment: + - PGHOST + - PGPASSWORD + - PGUSER + working_dir: /app + volumes: + - .:/app + command: bash -c " + npm rebuild --silent && + npm test " diff --git a/test/test_all_versions.sh b/test/test_all_versions.sh new file mode 100755 index 0000000..43f0fb5 --- /dev/null +++ b/test/test_all_versions.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +node_versions='6 8 10' +pg_versions='9.6 10 11' + +trap cleanup 0 1 2 3 6 +set -e + +function cleanup { + docker-compose down +} + +for node_version in $node_versions +do + export NODE_VERSION=$node_version + for pg_version in $pg_versions + do + export POSTGRES_VERSION=$pg_version + echo "Running tests with Node v$node_version, PostgreSQL v$pg_version..." + docker-compose run --rm test + docker-compose down + done +done +echo "All done" From a68d48a3aaaff76ca73803bd01d18cf1160e96ec Mon Sep 17 00:00:00 2001 From: Mikkel Hoegh Date: Tue, 8 Jan 2019 15:55:04 +0100 Subject: [PATCH 2/3] test: run tests on node v10, drop node v4 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 54d6654..a63d01f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,9 @@ language: node_js dist: trusty sudo: false node_js: - - "4.2" - "6" - "8" + - "10" env: - PGUSER=postgres services: From 8ba47d7b94e3dfab26eeba408233add8788aba7d Mon Sep 17 00:00:00 2001 From: Mikkel Hoegh Date: Tue, 8 Jan 2019 16:01:07 +0100 Subject: [PATCH 3/3] fix: add missing README link --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ea2c07d..6fae016 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ images. Due to a [bug in npm][npmbug], the output is very verbose, but with a bit of scrolling, you should hopefully see green checkmarks for every test run. +[npmbug]: https://npm.community/t/npm-rebuild-silent-is-not-silent/3834 + ### license The MIT License (MIT)