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

Commit 62186e8d by Sushant Committed by GitHub

chores: cleanup contribution guidelines and local testing/sscce setup (#8690)

1 parent 2b319304
...@@ -32,8 +32,10 @@ env: ...@@ -32,8 +32,10 @@ env:
before_script: before_script:
# mount ramdisk # mount ramdisk
- "if [ $POSTGRES_VER ] || [ $MYSQL_VER ]; then sudo mkdir /mnt/sequelize-ramdisk; fi" - "if [ $POSTGRES_VER ]; then sudo mkdir /mnt/sequelize-postgres-ramdisk; fi"
- "if [ $POSTGRES_VER ] || [ $MYSQL_VER ]; then sudo mount -t ramfs tmpfs /mnt/sequelize-ramdisk; fi" - "if [ $POSTGRES_VER ]; then sudo mount -t ramfs tmpfs /mnt/sequelize-postgres-ramdisk; fi"
- "if [ $MYSQL_VER ]; then sudo mkdir /mnt/sequelize-mysql-ramdisk; fi"
- "if [ $MYSQL_VER ]; then sudo mount -t ramfs tmpfs /mnt/sequelize-mysql-ramdisk; fi"
# setup docker # setup docker
- "if [ $POSTGRES_VER ] || [ $MYSQL_VER ]; then docker-compose up -d ${POSTGRES_VER} ${MYSQL_VER}; fi" - "if [ $POSTGRES_VER ] || [ $MYSQL_VER ]; then docker-compose up -d ${POSTGRES_VER} ${MYSQL_VER}; fi"
- "if [ $MYSQL_VER ]; then docker run --link ${MYSQL_VER}:db -e CHECK_PORT=3306 -e CHECK_HOST=db --net sequelize_default giorgos/takis; fi" - "if [ $MYSQL_VER ]; then docker run --link ${MYSQL_VER}:db -e CHECK_PORT=3306 -e CHECK_HOST=db --net sequelize_default giorgos/takis; fi"
......
...@@ -40,17 +40,19 @@ Here comes a little surprise: You need [Node.JS](http://nodejs.org). ...@@ -40,17 +40,19 @@ Here comes a little surprise: You need [Node.JS](http://nodejs.org).
Just "cd" into sequelize directory and run `npm install`, see an example below: Just "cd" into sequelize directory and run `npm install`, see an example below:
```console ```sh
$ cd path/to/sequelize $ cd path/to/sequelize
$ npm install $ npm install
``` ```
### 3. Database... Come to me! ### ### 3. Database
#### 3.a Local instances
For MySQL and PostgreSQL you'll need to create a DB called `sequelize_test`. For MySQL and PostgreSQL you'll need to create a DB called `sequelize_test`.
For MySQL this would look like this: For MySQL this would look like this:
```console ```sh
$ echo "CREATE DATABASE sequelize_test;" | mysql -uroot $ echo "CREATE DATABASE sequelize_test;" | mysql -uroot
``` ```
...@@ -58,16 +60,14 @@ $ echo "CREATE DATABASE sequelize_test;" | mysql -uroot ...@@ -58,16 +60,14 @@ $ echo "CREATE DATABASE sequelize_test;" | mysql -uroot
For Postgres, creating the database and (optionally) adding the test user this would look like: For Postgres, creating the database and (optionally) adding the test user this would look like:
```console ```sh
$ psql $ psql
# create database sequelize_test; # create database sequelize_test;
# create user postgres with superuser; # create user postgres with superuser;
``` ```
**AND ONE LAST THING:** Once `npm install` worked for you (see below), you'll #### 3.b Docker
get SQLite tests for free :)
#### 3a. Docker
Makes sure `docker` and `docker-compose` are installed. Makes sure `docker` and `docker-compose` are installed.
...@@ -76,41 +76,31 @@ If running on macOS, install [Docker for Mac](https://docs.docker.com/docker-for ...@@ -76,41 +76,31 @@ If running on macOS, install [Docker for Mac](https://docs.docker.com/docker-for
Now launch the docker mysql and postgres servers with this command (you can add `-d` to run them in daemon mode): Now launch the docker mysql and postgres servers with this command (you can add `-d` to run them in daemon mode):
```sh ```sh
docker-compose up postgres-95 mysql-57 $ docker-compose up postgres-95 mysql-57
```
Then to run the tests simply run:
```sh
npm run test-docker
``` ```
**Note:** _Its possible that you wont be able to run both postgres and mysql containers at same time, this is because they share ram-disk partition. You can usually run either of them after running `sudo rm -rf /mnt/sequelize-ramdisk`_ ### 4. Running tests
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 ###
All tests are located in the `test` folder (which contains the All tests are located in the `test` folder (which contains the
lovely [Mocha](http://visionmedia.github.io/mocha/) tests). lovely [Mocha](http://visionmedia.github.io/mocha/) tests).
```console ```sh
$ npm run test-all || test-mysql || test-sqlite || test-mssql || test-postgres || test-postgres-native $ npm run test-all || test-mysql || test-sqlite || test-mssql || test-postgres || test-postgres-native
$ # alternatively you can pass database credentials with $variables when testing $ # alternatively you can pass database credentials with $variables when testing
$ DIALECT=dialect SEQ_DB=database SEQ_USER=user SEQ_PW=password npm test $ DIALECT=dialect SEQ_DB=database SEQ_USER=user SEQ_PW=password npm test
``` ```
#### 4a. Check the documentation For docker users you can use these commands instead
This step only applies if you have actually changed something in the documentation. Please read [Documentation Contribution Guidelines](https://github.com/sequelize/sequelize/blob/master/CONTRIBUTING.DOCS.md) first.
To generate documentation for the `sequelize.js` file, run (in the sequelize dir)
```console ```sh
$ npm run docs $ DIALECT=mysql npm run test-docker # Or DIALECT=postgres for Postgres SQL
```
The generated documentation will be placed in `docs/tmp.md`. # Only integration tests
$ DIALECT=mysql npm run test-docker-integration
```
### 5. Commit ### ### 5. Commit
Sequelize follows the [AngularJS Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.em2hiij8p46d). Sequelize follows the [AngularJS Commit Message Conventions](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.em2hiij8p46d).
Example: Example:
...@@ -123,11 +113,13 @@ When you commit, your commit message will be validated automatically with [valid ...@@ -123,11 +113,13 @@ When you commit, your commit message will be validated automatically with [valid
Then push and send your pull request. Happy hacking and thank you for contributing. Then push and send your pull request. Happy hacking and thank you for contributing.
### Coding Guidelines ### # Coding guidelines
Have a look at our [.eslintrc.json](https://github.com/sequelize/sequelize/blob/master/.eslintrc.json) file for the specifics. As part of the test process, all files will be linted, and your PR will **not** be accepted if it does not pass linting. Have a look at our [.eslintrc.json](https://github.com/sequelize/sequelize/blob/master/.eslintrc.json) file for the specifics. As part of the test process, all files will be linted, and your PR will **not** be accepted if it does not pass linting.
# Publishing a release # Publishing a release (For Maintainers)
**Note:** _You really don't need this as Sequelize use semantic-release, Travis will automatically release new version_
1. Ensure that latest build on master is green 1. Ensure that latest build on master is green
2. Ensure your local code is up to date (`git pull origin master`) 2. Ensure your local code is up to date (`git pull origin master`)
......
FROM node:6.10.3 FROM node:6
RUN apt-get install libpq-dev RUN apt-get install libpq-dev
COPY package.json /
RUN npm install
WORKDIR /sequelize WORKDIR /sequelize
VOLUME /sequelize VOLUME /sequelize
COPY . /sequelize
...@@ -6,7 +6,6 @@ services: ...@@ -6,7 +6,6 @@ services:
links: links:
- mysql-57 - mysql-57
- postgres-95 - postgres-95
- mssql
volumes: volumes:
- .:/sequelize - .:/sequelize
environment: environment:
...@@ -22,9 +21,9 @@ services: ...@@ -22,9 +21,9 @@ services:
POSTGRES_PASSWORD: sequelize_test POSTGRES_PASSWORD: sequelize_test
POSTGRES_DB: sequelize_test POSTGRES_DB: sequelize_test
volumes: volumes:
- /mnt/sequelize-ramdisk:/var/lib/postgresql/data - /mnt/sequelize-postgres-ramdisk:/var/lib/postgresql/data
ports: ports:
- "127.0.0.1:8998:5432" - "8998:5432"
container_name: postgres-95 container_name: postgres-95
# MySQL # MySQL
...@@ -36,9 +35,9 @@ services: ...@@ -36,9 +35,9 @@ services:
MYSQL_USER: sequelize_test MYSQL_USER: sequelize_test
MYSQL_PASSWORD: sequelize_test MYSQL_PASSWORD: sequelize_test
volumes: volumes:
- /mnt/sequelize-ramdisk:/var/lib/mysql - /mnt/sequelize-mysql-ramdisk:/var/lib/mysql
ports: ports:
- "127.0.0.1:8999:3306" - "8999:3306"
container_name: mysql-57 container_name: mysql-57
# MSSQL # MSSQL
...@@ -48,5 +47,6 @@ services: ...@@ -48,5 +47,6 @@ services:
ACCEPT_EULA: "Y" ACCEPT_EULA: "Y"
SA_PASSWORD: yourStrong(!)Password SA_PASSWORD: yourStrong(!)Password
ports: ports:
- "127.0.0.1:8997:1433" - "8997:1433"
container_name: mssql container_name: mssql
...@@ -131,7 +131,7 @@ ...@@ -131,7 +131,7 @@
"cover-integration": "cross-env COVERAGE=true node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -t 60000 --ui tdd \"test/integration/**/*.test.js\" && node -e \"require('fs').renameSync('coverage/lcov.info', 'coverage/integration.info')\"", "cover-integration": "cross-env COVERAGE=true node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -t 60000 --ui tdd \"test/integration/**/*.test.js\" && node -e \"require('fs').renameSync('coverage/lcov.info', 'coverage/integration.info')\"",
"cover-unit": "cross-env COVERAGE=true node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -t 30000 --ui tdd \"test/unit/**/*.test.js\" && node -e \"require('fs').renameSync('coverage/lcov.info', 'coverage/unit.info')\"", "cover-unit": "cross-env COVERAGE=true node_modules/.bin/istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -t 30000 --ui tdd \"test/unit/**/*.test.js\" && node -e \"require('fs').renameSync('coverage/lcov.info', 'coverage/unit.info')\"",
"merge-coverage": "lcov-result-merger \"coverage/*.info\" \"coverage/lcov.info\"", "merge-coverage": "lcov-result-merger \"coverage/*.info\" \"coverage/lcov.info\"",
"sscce": "docker-compose run sequelize /bin/sh -c \"node sscce.js\"", "sscce": "env-cmd ./test/config/.docker.env node sscce.js",
"sscce-mysql": "cross-env DIALECT=mysql npm run sscce", "sscce-mysql": "cross-env DIALECT=mysql npm run sscce",
"sscce-postgres": "cross-env DIALECT=postgres npm run sscce", "sscce-postgres": "cross-env DIALECT=postgres npm run sscce",
"sscce-sqlite": "cross-env DIALECT=sqlite npm run sscce", "sscce-sqlite": "cross-env DIALECT=sqlite npm run sscce",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!