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

Commit 83750392 by Mick Hansen

new docker setup

1 parent 7ef35962
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
...@@ -67,34 +67,24 @@ $ psql ...@@ -67,34 +67,24 @@ $ psql
get SQLite tests for free :) get SQLite tests for free :)
#### 3a. Docker #### 3a. Docker
If you don't feel like setting up databases and users, you can use our [docker](http://docker.io) [image](https://index.docker.io/u/mhansen/sequelize-contribution/) for sequelize contribution.
Getting the image: Makes sure Docker and docker-compose are installed.
```console
$ sudo docker pull mhansen/sequelize-contribution
```
Start the container and save references to container id and ip: Then simply run:
```console
# Start mysql/postgres container
$ CONTAINER=$(sudo docker run -d -i -t mhansen/sequelize-contribution)
# Or start postgres 9.4 container
$ CONTAINER=$(sudo docker run --name sequelize-postgres -e POSTGRES_USER=sequelize_test -e POSTGRES_PASSWORD=sequelize_test -d postgres:9.4)
$ CONTAINER_IP=$(sudo docker inspect --format='{{.NetworkSettings.IPAddress}}' $CONTAINER) ```sh
npm run test-docker
``` ```
Run tests: And once in a while you might want to run:
```console
$ SEQ_HOST=$CONTAINER_IP SEQ_USER=sequelize_test make all
```
Stop the container: ```sh
```console npm run build-docker
$ sudo docker stop $CONTAINER
``` ```
When running tests repeatedly, you only need to redo step 3 if you haven't stopped the container. 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.
#### 3b. Docker and OSX: #### 3b. Docker and OSX:
......
FROM iojs:1.6
RUN apt-get install libpq-dev
COPY package.json /
RUN npm install
WORKDIR /sequelize
VOLUME /sequelize
\ No newline at end of file
REPORTER ?= spec REPORTER ?= spec
TESTS = $(shell find ./test/integration/* -name "*.test.js") TESTS = $(shell find ./test/integration/* -name "*.test.js")
DIALECT ?= mysql DIALECT ?= mysql
JSHINT ?= ./node_modules/.bin/jshint
MOCHA ?= ./node_modules/.bin/mocha
# test commands # test commands
...@@ -20,7 +22,7 @@ endif ...@@ -20,7 +22,7 @@ endif
# Unit tests # Unit tests
test-unit: test-unit:
./node_modules/mocha/bin/mocha --globals setImmediate,clearImmediate --ui tdd --check-leaks --colors -t 15000 --reporter $(REPORTER) ./test/unit/*.js ./test/unit/**/*.js $(MOCHA) --globals setImmediate,clearImmediate --ui tdd --check-leaks --colors -t 15000 --reporter $(REPORTER) ./test/unit/*.js ./test/unit/**/*.js
test-unit-all: test-unit-sqlite test-unit-mysql test-unit-postgres test-unit-postgres-native test-unit-mariadb test-unit-mssql test-unit-all: test-unit-sqlite test-unit-mysql test-unit-postgres test-unit-postgres-native test-unit-mariadb test-unit-mssql
...@@ -40,9 +42,9 @@ test-unit-postgres-native: ...@@ -40,9 +42,9 @@ test-unit-postgres-native:
# Integration tests # Integration tests
test-integration: test-integration:
@if [ "$$GREP" ]; then \ @if [ "$$GREP" ]; then \
./node_modules/mocha/bin/mocha --globals setImmediate,clearImmediate --ui tdd --check-leaks --colors -t 15000 --reporter $(REPORTER) -g "$$GREP" $(TESTS); \ $(MOCHA) --globals setImmediate,clearImmediate --ui tdd --check-leaks --colors -t 15000 --reporter $(REPORTER) -g "$$GREP" $(TESTS); \
else \ else \
./node_modules/mocha/bin/mocha --globals setImmediate,clearImmediate --ui tdd --check-leaks --colors -t 15000 --reporter $(REPORTER) $(TESTS); \ $(MOCHA) --globals setImmediate,clearImmediate --ui tdd --check-leaks --colors -t 15000 --reporter $(REPORTER) $(TESTS); \
fi fi
test-integration-all: test-integration-sqlite test-integration-mysql test-integration-postgres test-integration-postgres-native test-integration-mariadb test-integration-mssql test-integration-all: test-integration-sqlite test-integration-mysql test-integration-postgres test-integration-postgres-native test-integration-mariadb test-integration-mssql
...@@ -62,7 +64,7 @@ test-integration-postgres-native: ...@@ -62,7 +64,7 @@ test-integration-postgres-native:
jshint: jshint:
./node_modules/.bin/jshint lib test $(JSHINT) lib test
mariadb: mariadb:
@DIALECT=mariadb make test @DIALECT=mariadb make test
......
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
postgres:
image: postgres:9.4
environment:
POSTGRES_USER: sequelize_test
POSTGRES_PASSWORD: sequelize_test
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
{ {
"name": "sequelize", "name": "sequelize",
"description": "Multi dialect ORM for Node.JS", "description": "Multi dialect ORM for Node.JS/io.js",
"version": "2.1.3", "version": "2.1.3",
"author": "Sascha Depold <sascha@depold.com>", "author": "Sascha Depold <sascha@depold.com>",
"contributors": [ "contributors": [
...@@ -79,6 +79,8 @@ ...@@ -79,6 +79,8 @@
"main": "index", "main": "index",
"scripts": { "scripts": {
"test": "make all", "test": "make all",
"test-docker": "sudo docker-compose run sequelize /bin/sh -c \"make all\"",
"build-docker": "sudo docker-compose build",
"docs": "node docs/docs-generator.js" "docs": "node docs/docs-generator.js"
}, },
"engines": { "engines": {
......
...@@ -31,8 +31,8 @@ module.exports = { ...@@ -31,8 +31,8 @@ module.exports = {
database: process.env.SEQ_MYSQL_DB || process.env.SEQ_DB || 'sequelize_test', database: process.env.SEQ_MYSQL_DB || process.env.SEQ_DB || 'sequelize_test',
username: process.env.SEQ_MYSQL_USER || process.env.SEQ_USER || 'root', username: process.env.SEQ_MYSQL_USER || process.env.SEQ_USER || 'root',
password: process.env.SEQ_MYSQL_PW || process.env.SEQ_PW || null, password: process.env.SEQ_MYSQL_PW || process.env.SEQ_PW || null,
host: process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1', host: process.env.MYSQL_PORT_3306_TCP_ADDR || process.env.SEQ_MYSQL_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306, port: process.env.MYSQL_PORT_3306_TCP_PORT || process.env.SEQ_MYSQL_PORT || process.env.SEQ_PORT || 3306,
pool: { pool: {
maxConnections: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5, maxConnections: process.env.SEQ_MYSQL_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000 maxIdleTime: process.env.SEQ_MYSQL_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
...@@ -46,8 +46,8 @@ module.exports = { ...@@ -46,8 +46,8 @@ module.exports = {
database: process.env.SEQ_PG_DB || process.env.SEQ_DB || 'sequelize_test', database: process.env.SEQ_PG_DB || process.env.SEQ_DB || 'sequelize_test',
username: process.env.SEQ_PG_USER || process.env.SEQ_USER || 'postgres', username: process.env.SEQ_PG_USER || process.env.SEQ_USER || 'postgres',
password: process.env.SEQ_PG_PW || process.env.SEQ_PW || 'postgres', password: process.env.SEQ_PG_PW || process.env.SEQ_PW || 'postgres',
host: process.env.SEQ_PG_HOST || process.env.SEQ_HOST || '127.0.0.1', host: process.env.POSTGRES_PORT_5432_TCP_ADDR || process.env.SEQ_PG_HOST || process.env.SEQ_HOST || '127.0.0.1',
port: process.env.SEQ_PG_PORT || process.env.SEQ_PORT || 5432, port: process.env.POSTGRES_PORT_5432_TCP_PORT || process.env.SEQ_PG_PORT || process.env.SEQ_PORT || 5432,
pool: { pool: {
maxConnections: process.env.SEQ_PG_POOL_MAX || process.env.SEQ_POOL_MAX || 5, maxConnections: process.env.SEQ_PG_POOL_MAX || process.env.SEQ_POOL_MAX || 5,
maxIdleTime: process.env.SEQ_PG_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000 maxIdleTime: process.env.SEQ_PG_POOL_IDLE || process.env.SEQ_POOL_IDLE || 3000
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!