diff --git a/README.md b/README.md index 92b2dad..2cc35e2 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,15 @@ -# sample_nodejs -A simple node.js app used in Shippable tutorials +# nodejs +This repository contains the files necessary to run a sample application in Node.js and to run CI tests on Shippable. + + +Contents: +This repository has 6 files and the functions of each file are as follows: + +1. README.md - Contains an some basic conventions and guidelines to show the working of folder level caching. +2. Shippable.yml - Configured for the language, version & to run a test during the CI step. http://docs.shippable.com/ci_configure/ gives you a detailed introduction on how to configure your CI on shippable. +3. Package.json - Installs all the libraries mentioned in dependencies list when we run npm install command from the root of this folder. The npm install command creates a new folder called node_modules which contains all the libraries mentioned in the dependency list. +4. index.js - Outputs "Welcome to Shippable" in a browser +5. test.js - Configured to run a simple unit test to check the syntax of the index.js output +6. Gruntfile.js - grunt file that loads express server and mocha Test +7. xunit.xml - +8. .gitignore - default file created at the time of creating this repository diff --git a/gruntfile.js b/gruntfile.js new file mode 100644 index 0000000..cf9fa9f --- /dev/null +++ b/gruntfile.js @@ -0,0 +1,23 @@ + +module.exports = function (grunt) { + grunt.initConfig({ + express: { + test: { + options: { + script: "index.js" + } + } + }, + mochaTest: { + test: { + options: { + reporter: 'spec-xunit-file' + }, + src: ["./test.js"] + } + } + }); + grunt.loadNpmTasks("grunt-express-server"); + grunt.loadNpmTasks("grunt-mocha-test"); + grunt.registerTask("default", ["express:test", "mochaTest"]); +}; diff --git a/index.js b/index.js new file mode 100644 index 0000000..28b7e8c --- /dev/null +++ b/index.js @@ -0,0 +1,11 @@ +var express = require("express"), + app = express(); + +var connection = null; +app.get("/", function (req, res) { + res.send("Welcome to Shippable"); +}); + +app.listen(3000, function () { + console.log('Express listening on port 3000'); +}); diff --git a/package.json b/package.json new file mode 100644 index 0000000..bf32f80 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "sample-node-couchdb", + "version": "0.0.0", + "description": "Testing CouchDB service", + "main": "index.js", + "scripts": { + "test": "grunt" + }, + "repository": { + "type": "git", + "url": "git@github.com:Shippable/sample_node.git" + }, + "author": "Patrick Ellis", + "license": "MIT", + "bugs": { + "url": "https://github.com/Shippable/sample_node/issues" + }, + "homepage": "https://github.com/Shippable/sample_node", + "dependencies": { + "express": "^4.2.0", + "nano": "^5.10.0", + "should": "^4.0.1", + "util": "~0.10.3", + "body-parser": "~1.4.2", + "express": "~4.3.1", + "request": "~2.67.0", + "parse-links": "*" + }, + "devDependencies": { + "chai": "^1.9.1", + "grunt": "^0.4.5", + "grunt-express-server": "^0.4.17", + "grunt-mocha-test": "^0.12.7", + "mocha": "^1.18.2", + "superagent": "^0.18.0", + "spec-xunit-file": "0.0.1-3" + } +} diff --git a/shippable.yml b/shippable.yml new file mode 100644 index 0000000..2c74c51 --- /dev/null +++ b/shippable.yml @@ -0,0 +1,12 @@ +language: node_js + +node_js: + - 0.12 + +env: + - XUNIT_FILE=shippable/testresults/result.xml + +build: + ci: + - npm install + - npm test diff --git a/test.js b/test.js new file mode 100644 index 0000000..d4d3857 --- /dev/null +++ b/test.js @@ -0,0 +1,13 @@ +var superagent = require("superagent"), + should = require("should"); + +describe("Index", function () { + it("renders HTML", function (done) { + superagent.get("http://localhost:3000/") + .end(function (e, res) { + (e === null).should.equal(true); + res.text.should.equal("Welcome to Shippable"); + done(); + }); + }); +}); diff --git a/xunit.xml b/xunit.xml new file mode 100755 index 0000000..e69de29