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

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:
- "4"
- "6"
cache:
directories:
- node_modules
branches:
only:
- master
- v3
env:
global:
- CC=clang
- CXX=clang++
- npm_config_clang=1
matrix:
- DIALECT=mysql
- DIALECT=postgres
- DIALECT=postgres-native
- DIALECT=sqlite
addons:
apt:
sources:
- llvm-toolchain-precise-3.6
- ubuntu-toolchain-r-test
packages:
- clang-3.6
- g++-4.8
# mysql info
- SEQ_MYSQL_DB: sequelize_test
- SEQ_MYSQL_USER: sequelize_test
- SEQ_MYSQL_PW: sequelize_test
- SEQ_MYSQL_HOST: 127.0.0.1
- SEQ_MYSQL_PORT: 8998
# postgres info
- SEQ_PG_DB: sequelize_test
- SEQ_PG_USER: sequelize_test
- SEQ_PG_PW: sequelize_test
- SEQ_PG_HOST: 127.0.0.1
- SEQ_PG_PORT: 8999
addons:
postgresql: "9.4"
matrix:
- 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:
- "mysql -e 'create database sequelize_test;'"
- "psql -c 'create database sequelize_test;' -U postgres"
- "psql sequelize_test -c 'create extension postgis;' -U postgres"
- "if [ $POSTGRES_VER ] || [ $MYSQL_VER ]; then docker-compose up -d ${POSTGRES_VER} ${MYSQL_VER}; fi"
- "sleep 30s" # This allows enough time for docker to get up and running before tests occur
script:
- "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.
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
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
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.
### 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:
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
version: '2'
postgres:
image: postgres:9.4
environment:
POSTGRES_USER: sequelize_test
POSTGRES_PASSWORD: sequelize_test
services:
# PostgreSQL
postgres-95:
image: camptocamp/postgis:9.5
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:
image: mysql:5.6
environment:
MYSQL_ROOT_PASSWORD: lollerskates
MYSQL_DATABASE: sequelize_test
MYSQL_USER: sequelize_test
MYSQL_PASSWORD: sequelize_test
\ No newline at end of file
# MySQL
mysql-57:
image: mysql:5.7
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-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 @@
"debug": "^2.2.0",
"depd": "^1.1.0",
"dottie": "^1.0.0",
"env-cmd": "^2.1.0",
"generic-pool": "2.4.2",
"inflection": "1.10.0",
"lodash": "4.16.2",
......@@ -95,10 +96,9 @@
"scripts": {
"lint": "eslint lib test",
"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-unit": "docker-compose run sequelize /bin/sh -c \"npm run test-unit-all\"",
"test-docker-integration": "docker-compose run sequelize /bin/sh -c \"npm run test-integration-all\"",
"build-docker": "docker-compose build",
"test-docker": "npm run test-docker-unit && npm run test-docker-integration",
"test-docker-unit": "env-cmd ./test/config/.docker.env npm run test-unit",
"test-docker-integration": "env-cmd ./test/config/.docker.env npm run test-integration",
"docs": "node docs/docs-generator.js",
"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))\"",
......
# 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() {
return new Sequelize.Promise((resolve, reject) => {
if (/^postgres/.test(dialect)) {
current.query(`SELECT extversion FROM pg_catalog.pg_extension WHERE extname='postgis';`)
.then((result) => {
if (result[0][0] && semver.lte(result[0][0].extversion, '2.1.7')) {
resolve(true);
} else {
resolve();
}
}).catch(reject);
current.query(`SELECT PostGIS_Lib_Version();`)
.then((result) => {
if (result[0][0] && semver.lte(result[0][0].postgis_lib_version, '2.1.7')) {
resolve(true);
} else {
resolve();
}
}).catch(reject);
} else {
resolve(true);
}
......
......@@ -12,7 +12,8 @@ var chai = require('chai')
, _ = require('lodash')
, moment = require('moment')
, Promise = require('bluebird')
, current = Support.sequelize;
, current = Support.sequelize
, semver = require('semver');
describe(Support.getTestDialectTeaser('Model'), function() {
before(function () {
......@@ -2383,7 +2384,12 @@ describe(Support.getTestDialectTeaser('Model'), function() {
return;
}).catch (function(err) {
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') {
// the parser should not end up here ... see above
expect(1).to.equal(2);
......
......@@ -269,7 +269,7 @@ describe(Support.getTestDialectTeaser('Sequelize'), function() {
it('logs warnings when there are warnings', function() {
// 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;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!