不要怂,就是干,撸起袖子干!

Commit 9731d130 by Todd Bluhm Committed by Jan Aagaard Meier

Update Travis-CI to use Docker (#6443)

* Use Docker for travis-ci

* Fix up running local docker tests

* Travis.yml cleanup, fix postgis version type testing

* New way of accessing postgis version

* Add version specific clause around mysql error message

* Fix warning message to ignore if mysql >= 5.6

- Tweak travis env var order to be more readable in travis

* Remove testing against legacy dbs to make the testing process more lean
1 parent ff320e0f
test*.js
*.swp
.idea
.DS_STORE
node_modules
npm-debug.log
*~
test/binary/tmp/*
test/tmp/*
test/dialects/sqlite/test.sqlite
test/sqlite/test.sqlite
coverage-*
site
\ No newline at end of file
language: node_js sudo: required
dist: trusty
sudo: false language: node_js
node_js: node_js:
- "4" - "4"
- "6"
cache: branches:
directories: only:
- node_modules - master
- v3
env: env:
global: global:
- CC=clang # mysql info
- CXX=clang++ - SEQ_MYSQL_DB: sequelize_test
- npm_config_clang=1 - SEQ_MYSQL_USER: sequelize_test
matrix: - SEQ_MYSQL_PW: sequelize_test
- DIALECT=mysql - SEQ_MYSQL_HOST: 127.0.0.1
- DIALECT=postgres - SEQ_MYSQL_PORT: 8998
- DIALECT=postgres-native # postgres info
- DIALECT=sqlite - SEQ_PG_DB: sequelize_test
- SEQ_PG_USER: sequelize_test
addons: - SEQ_PG_PW: sequelize_test
apt: - SEQ_PG_HOST: 127.0.0.1
sources: - SEQ_PG_PORT: 8999
- llvm-toolchain-precise-3.6
- ubuntu-toolchain-r-test
packages:
- clang-3.6
- g++-4.8
addons: matrix:
postgresql: "9.4" - DIALECT=sqlite COVERAGE=true
- MYSQL_VER=mysql-57 DIALECT=mysql COVERAGE=true
- POSTGRES_VER=postgres-95 DIALECT=postgres COVERAGE=true
- POSTGRES_VER=postgres-95 DIALECT=postgres-native COVERAGE=true
before_script: before_script:
- "mysql -e 'create database sequelize_test;'" - "if [ $POSTGRES_VER ] || [ $MYSQL_VER ]; then docker-compose up -d ${POSTGRES_VER} ${MYSQL_VER}; fi"
- "psql -c 'create database sequelize_test;' -U postgres" - "sleep 30s" # This allows enough time for docker to get up and running before tests occur
- "psql sequelize_test -c 'create extension postgis;' -U postgres"
script: script:
- "if [ $COVERAGE ]; then npm run cover && bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info; else npm run test; fi" - "if [ $COVERAGE ]; then npm run cover && bash <(curl -s https://codecov.io/bash) -f coverage/lcov.info; else npm run test; fi"
matrix:
include:
- node_js: "6"
env: COVERAGE=true DIALECT=mysql
- node_js: "6"
env: COVERAGE=true DIALECT=postgres
- node_js: "6"
env: COVERAGE=true DIALECT=postgres-native
- node_js: "6"
env: COVERAGE=true DIALECT=sqlite
branches:
only:
- master
- v3
...@@ -73,20 +73,17 @@ Makes sure `docker` and `docker-compose` are installed. ...@@ -73,20 +73,17 @@ Makes sure `docker` and `docker-compose` are installed.
If running on Mac OSX, install [Docker for Mac](https://docs.docker.com/docker-for-mac/). If running on Mac OSX, install [Docker for Mac](https://docs.docker.com/docker-for-mac/).
Then simply run: Now launch the docker mysql and postgres servers with this command (you can add `-d` to run them in daemon mode):
```sh ```sh
npm run test-docker docker-compose up postgres-95 mysql-57
``` ```
And once in a while you might want to run: Then to run the tests simply run:
```sh ```sh
npm run build-docker npm run test-docker
``` ```
To rebuild the image (in case of changed dependencies or similar).
If sequelize is unable to connect to mysql you might want to try running `sudo docker-compose up` in a second terminal window. If sequelize is unable to connect to mysql you might want to try running `sudo docker-compose up` in a second terminal window.
### 4. Run the tests ### ### 4. Run the tests ###
......
FROM node:4
RUN apt-get install libpq-dev
COPY package.json /
ENV NPM_CONFIG_LOGLEVEL error
RUN npm install
WORKDIR /sequelize
VOLUME /sequelize
sequelize: version: '2'
build: .
links:
- mysql
- postgres
volumes:
- .:/sequelize
environment:
SEQ_DB: sequelize_test
SEQ_USER: sequelize_test
SEQ_PW: sequelize_test
JSHINT: /node_modules/.bin/jshint
MOCHA: /node_modules/.bin/mocha
postgres: services:
image: postgres:9.4 # PostgreSQL
environment: postgres-95:
POSTGRES_USER: sequelize_test image: camptocamp/postgis:9.5
POSTGRES_PASSWORD: sequelize_test environment:
POSTGRES_USER: sequelize_test
POSTGRES_PASSWORD: sequelize_test
ports:
- "127.0.0.1:8999:5432"
postgres-94:
image: camptocamp/postgis:9.4
environment:
POSTGRES_USER: sequelize_test
POSTGRES_PASSWORD: sequelize_test
ports:
- "127.0.0.1:8999:5432"
mysql: # MySQL
image: mysql:5.6 mysql-57:
environment: image: mysql:5.7
MYSQL_ROOT_PASSWORD: lollerskates environment:
MYSQL_DATABASE: sequelize_test MYSQL_ROOT_PASSWORD: lollerskates
MYSQL_USER: sequelize_test MYSQL_DATABASE: sequelize_test
MYSQL_PASSWORD: sequelize_test MYSQL_USER: sequelize_test
\ No newline at end of file MYSQL_PASSWORD: sequelize_test
ports:
- "127.0.0.1:8998:3306"
mysql-56:
image: mysql:5.6
environment:
MYSQL_ROOT_PASSWORD: lollerskates
MYSQL_DATABASE: sequelize_test
MYSQL_USER: sequelize_test
MYSQL_PASSWORD: sequelize_test
ports:
- "127.0.0.1:8998:3306"
mysql-55:
image: mysql:5.5
environment:
MYSQL_ROOT_PASSWORD: lollerskates
MYSQL_DATABASE: sequelize_test
MYSQL_USER: sequelize_test
MYSQL_PASSWORD: sequelize_test
ports:
- "127.0.0.1:8998:3306"
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
"debug": "^2.2.0", "debug": "^2.2.0",
"depd": "^1.1.0", "depd": "^1.1.0",
"dottie": "^1.0.0", "dottie": "^1.0.0",
"env-cmd": "^2.1.0",
"generic-pool": "2.4.2", "generic-pool": "2.4.2",
"inflection": "1.10.0", "inflection": "1.10.0",
"lodash": "4.16.2", "lodash": "4.16.2",
...@@ -95,10 +96,9 @@ ...@@ -95,10 +96,9 @@
"scripts": { "scripts": {
"lint": "eslint lib test", "lint": "eslint lib test",
"test": "npm run jshint && npm run teaser && npm run test-unit && npm run test-integration", "test": "npm run jshint && npm run teaser && npm run test-unit && npm run test-integration",
"test-docker": "docker-compose run sequelize /bin/sh -c \"npm run test-all\"", "test-docker": "npm run test-docker-unit && npm run test-docker-integration",
"test-docker-unit": "docker-compose run sequelize /bin/sh -c \"npm run test-unit-all\"", "test-docker-unit": "env-cmd ./test/config/.docker.env npm run test-unit",
"test-docker-integration": "docker-compose run sequelize /bin/sh -c \"npm run test-integration-all\"", "test-docker-integration": "env-cmd ./test/config/.docker.env npm run test-integration",
"build-docker": "docker-compose build",
"docs": "node docs/docs-generator.js", "docs": "node docs/docs-generator.js",
"jshint": "jshint lib test", "jshint": "jshint lib test",
"teaser": "node -e \"console.log('#'.repeat(process.env.DIALECT.length + 22) + '\\n# Running tests for ' + process.env.DIALECT + ' #\\n' + '#'.repeat(process.env.DIALECT.length + 22))\"", "teaser": "node -e \"console.log('#'.repeat(process.env.DIALECT.length + 22) + '\\n# Running tests for ' + process.env.DIALECT + ' #\\n' + '#'.repeat(process.env.DIALECT.length + 22))\"",
......
# Special ports needed for docker to prevent port conflicts
SEQ_MYSQL_PORT=8998
SEQ_MYSQL_USER=sequelize_test
SEQ_MYSQL_PW=sequelize_test
SEQ_PG_PORT=8999
SEQ_PG_USER=sequelize_test
SEQ_PG_PW=sequelize_test
...@@ -285,14 +285,14 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() { ...@@ -285,14 +285,14 @@ describe(Support.getTestDialectTeaser('DataTypes'), function() {
return new Sequelize.Promise((resolve, reject) => { return new Sequelize.Promise((resolve, reject) => {
if (/^postgres/.test(dialect)) { if (/^postgres/.test(dialect)) {
current.query(`SELECT extversion FROM pg_catalog.pg_extension WHERE extname='postgis';`) current.query(`SELECT PostGIS_Lib_Version();`)
.then((result) => { .then((result) => {
if (result[0][0] && semver.lte(result[0][0].extversion, '2.1.7')) { if (result[0][0] && semver.lte(result[0][0].postgis_lib_version, '2.1.7')) {
resolve(true); resolve(true);
} else { } else {
resolve(); resolve();
} }
}).catch(reject); }).catch(reject);
} else { } else {
resolve(true); resolve(true);
} }
......
...@@ -12,7 +12,8 @@ var chai = require('chai') ...@@ -12,7 +12,8 @@ var chai = require('chai')
, _ = require('lodash') , _ = require('lodash')
, moment = require('moment') , moment = require('moment')
, Promise = require('bluebird') , Promise = require('bluebird')
, current = Support.sequelize; , current = Support.sequelize
, semver = require('semver');
describe(Support.getTestDialectTeaser('Model'), function() { describe(Support.getTestDialectTeaser('Model'), function() {
before(function () { before(function () {
...@@ -2383,7 +2384,12 @@ describe(Support.getTestDialectTeaser('Model'), function() { ...@@ -2383,7 +2384,12 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return; return;
}).catch (function(err) { }).catch (function(err) {
if (dialect === 'mysql') { if (dialect === 'mysql') {
expect(err.message).to.match(/Can\'t create table/); // MySQL 5.7 or above doesn't support POINT EMPTY
if (dialect === 'mysql' && semver.gte(current.options.databaseVersion, '5.6.0')) {
expect(err.message).to.match(/Cannot add foreign key constraint/);
} else {
expect(err.message).to.match(/Can\'t create table/);
}
} else if (dialect === 'sqlite') { } else if (dialect === 'sqlite') {
// the parser should not end up here ... see above // the parser should not end up here ... see above
expect(1).to.equal(2); expect(1).to.equal(2);
......
...@@ -269,7 +269,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() { ...@@ -269,7 +269,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
it('logs warnings when there are warnings', function() { it('logs warnings when there are warnings', function() {
// Due to strict MySQL 5.7 all cases below will throw errors rather than warnings // Due to strict MySQL 5.7 all cases below will throw errors rather than warnings
if (semver.gte(current.options.databaseVersion, '5.7.0')) { if (semver.gte(current.options.databaseVersion, '5.6.0')) {
return; return;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!