codeship + heroku is the solution of continuously integration and continuously deployment.
However, most of users just use codeship for unit test, which is not an even continuously integration test, and they use codeship as a host server, which do the compiling(building) and deployment and hosting jobs.
Actually you can do everything by heroku, but codeship can only do the compiling and running tests. However you won't do everything on heroku. Because it is a hosting server, it is nonsense to run unit test and e2e test on it. First all tests take times to run, you can't stop you app/website to run tests, even you keep running the app/website and parallelly run your tests , your tests are using CPU and other resource which will impact your app/website. Second, it doesn't make sense to have tests packages libraries in live environment. So, even heroku has the cability to handle all jobs we still want to do compiling and testing on another server. Heroku only do hosting.
Codeship can do the build and "deploy" the project into heroku. However, it is not a real deployment. Because codeship just push all your source code into heroku and let it runs compile and deploy.
The basic rule of testing and deploying is what your compiled is what you need to deploy. Because codeship done the compile, the output archive should be pushed to heroku to host directly.
however, your output folder (/bin or /dist) is in your .gitignore file. You can't push your output folder into github, codeship also can't push their output into heroku. How to solve it?
Solution1: Delete /dist from .gitignore file and clean /dist folder before you push to github
However, this is a ugly solution, because developers may forget clean the folder and your github will have a lot of garbage. This is not acceptable for enterprise-level projects. personal project is ok .
Solution 2: Delete /dist from .gitignore file on codeship.
After compared with different similar solutions, I think my solution below is the best so far:
My solution has less changes (less changes means less faults and less maintenances), and users still can get benefit from all codeship deployment stuffs e.g. application health checking after deployed, and if it is failed the build failed.
Setup Commands# By default we use the Node.js version set in your package.json or 0.10.25
# You can use nvm to install any Node.js version.
# i.e.: nvm install 0.10.25
# This is to get compass on the server
# rvm use 2.0.0-p195
rvm use ruby-2.1.2
# nvm install 0.10.32
# nvm use 0.10.32
npm install bower -g
# Install grunt-cli for running your tests or other tasks
npm install grunt-cli
#below code are used to remove .gitignore to push output into heroku.
ls -la dist/
rm -f .gitignore
git config --global user.email "firstname.lastname@example.org"
git config --global user.name "herokukiller"
git add --all
git commit -m "remove .gitignore"
export COMMIT_ID=`git rev-parse HEAD`
export CI_COMMIT_ID=`git rev-parse HEAD`
(the last line is added 2015-11-20, due to the change of codeship: http://baiduhix.blogspot.co.uk/2015/11/codeship-build-error-follow-my-previous.html)
Configure Test Pipelines:
npm run e2e