├── Dockerfile ├── README.md ├── index.js ├── test.js ├── Gruntfile.js ├── package.json ├── shippable.yml ├── LICENSE └── installMongo.sh /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM drydock/u12nod:prod 2 | 3 | RUN mkdir -p /tmp/logs 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Node.js Sample! 2 | ================= 3 | 4 | A simple Node.js application with tests. 5 | 6 | Uses Grunt to run tests against an Express server, then generates reports with Xunit and Istanbul. 7 | 8 | This sample is built for Shippable, a docker based continuous integration and deployment platform. 9 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var express = require("express"), 2 | nano = require('nano')('http://localhost:5984'), 3 | app = express(); 4 | 5 | app.get("/", function (req, res) { 6 | res.send("Hey buddy!"); 7 | }); 8 | 9 | app.listen(3000, function () { 10 | console.log('Express listening on port 3000'); 11 | }); 12 | -------------------------------------------------------------------------------- /test.js: -------------------------------------------------------------------------------- 1 | var superagent = require("superagent"), 2 | chai = require("chai"), 3 | expect = chai.expect, 4 | should = require("should"); 5 | 6 | describe("Index", function () { 7 | it("renders HTML", function (done) { 8 | superagent.get("http://localhost:3000/") 9 | .end(function (e, res) { 10 | (e === null).should.equal(true); 11 | res.text.should.equal("Hey buddy!"); 12 | done(); 13 | }); 14 | }); 15 | }); -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | require("xunit-file"); 2 | 3 | module.exports = function (grunt) { 4 | grunt.initConfig({ 5 | express: { 6 | test: { 7 | options: { 8 | script: "index.js" 9 | } 10 | } 11 | }, 12 | simplemocha: { 13 | options: { 14 | globals: ["should"], 15 | timeout: 3000, 16 | ignoreLeaks: false, 17 | ui: "bdd", 18 | reporter: "xunit-file" 19 | }, 20 | all: { src: ["./test.js"] } 21 | } 22 | }); 23 | grunt.loadNpmTasks("grunt-express-server"); 24 | grunt.loadNpmTasks("grunt-simple-mocha"); 25 | grunt.registerTask("default", ["express:test", "simplemocha:all"]); 26 | }; 27 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sample-node-couchdb", 3 | "version": "0.0.0", 4 | "description": "Testing CouchDB service", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "grunt" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git@github.com:Shippable/sample_node.git" 12 | }, 13 | "author": "Patrick Ellis", 14 | "license": "MIT", 15 | "bugs": { 16 | "url": "https://github.com/Shippable/sample_node/issues" 17 | }, 18 | "homepage": "https://github.com/Shippable/sample_node", 19 | "dependencies": { 20 | "express": "^4.2.0", 21 | "nano": "^5.10.0", 22 | "should": "^4.0.1" 23 | }, 24 | "devDependencies": { 25 | "chai": "^1.9.1", 26 | "grunt": "^0.4.5", 27 | "grunt-express-server": "^0.4.17", 28 | "grunt-simple-mocha": "^0.4.0", 29 | "istanbul": "^0.2.9", 30 | "mocha": "^1.18.2", 31 | "superagent": "^0.18.0", 32 | "xunit-file": "0.0.5" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /shippable.yml: -------------------------------------------------------------------------------- 1 | # Language setting 2 | language: node_js 3 | 4 | build_image: drydock/u12nod:prod 5 | 6 | # Version number 7 | node_js: 8 | - 0.12 9 | 10 | # The path for Xunit to output test reports 11 | env: 12 | - XUNIT_FILE=shippable/testresults/result.xml 13 | 14 | install: 15 | - source ~/.nvm/nvm.sh && nvm install 0.12 16 | - node --version 17 | - npm install 18 | # - . installMongo.sh 19 | # - cat /etc/mongod.conf 20 | # - sudo mongod --smallfiles & 21 | # - sleep 15 22 | # - mongo --eval 'db.collection.find()' 23 | 24 | # Create directories for test and coverage reports 25 | before_script: 26 | - mkdir -p shippable/testresults 27 | - mkdir -p shippable/codecoverage 28 | 29 | # Running the tests with grunt 30 | script: 31 | - grunt 32 | 33 | # Tell istanbul to generate a coverage report 34 | after_script: 35 | - ./node_modules/.bin/istanbul cover grunt -- -u tdd 36 | - ./node_modules/.bin/istanbul report cobertura --dir shippable/codecoverage/ 37 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Patrick 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /installMongo.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash -x 2 | 3 | sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10 4 | 5 | echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list 6 | sudo apt-get update 7 | sudo apt-get install -y mongodb-org=2.6.11 mongodb-org-server=2.6.11 mongodb-org-shell=2.6.11 mongodb-org-mongos=2.6.11 mongodb-org-tools=2.6.11 8 | 9 | sudo mkdir -p /data/db 10 | 11 | # Pin the current version 12 | sudo echo "mongodb-org hold" | sudo dpkg --set-selections 13 | sudo echo "mongodb-org-server hold" | sudo dpkg --set-selections 14 | sudo echo "mongodb-org-shell hold" | sudo dpkg --set-selections 15 | sudo echo "mongodb-org-mongos hold" | sudo dpkg --set-selections 16 | sudo echo "mongodb-org-tools hold" | sudo dpkg --set-selections 17 | 18 | #replace closed port & bing IP 19 | sudo sed -i 's/#port = 27017/port = 27017/' /etc/mongod.conf 20 | sudo sed -i 's/bind_ip = 127.0.0.1/bind_ip = 0.0.0.0/' /etc/mongod.conf 21 | sudo sed -i 's/# nojournal = true/nojournal = true/' /etc/mongod.conf 22 | sudo sed -i 's/#noprealloc = true/noprealloc = true/' /etc/mongod.conf 23 | --------------------------------------------------------------------------------