I was impressed by the elaborate and through build system that Pouch. Some of the things I liked are
- Integration with Travis for continuous integration (CI) ensures that tests are run on commits and pull requests.
- Using Saucelabs allows cross browser testing, something that is vital for a javascript library that depends on a standards like IndexedDB.
- Since this was also a node module, qunit tests were also run during CI
- The command line options run using ./pouch, to run tests, start the server or build the final output javascript files.
- Test results published to a central place where they can be analyzed. This is a great place for performance metrics too.
- The build file was a single javascript file executed on Travis using node. I thought it would be easier to maintain if I could modularize it as tasks, typical of a build system. Grunt could help modularize the file into independent tasks.
- Though pouch was a node file, make was still the way to concat or minify files.
- The file had lot of Saucelabs specific code; code for establishing tunnels, running the qunit tests, etc. The jar file was also checked into the repository. The saucelabs part can be a grunt task, and could actually be reused by other projects too. I spawned a new project, and this post explains how you can use it for your grunt based project very easily.
- The qunit tests for node could also be a separate project. While at it, I realized that grunt uses [email protected] while qunit-node uses [email protected]. These are incompatible and I had to shrinkwrap the dependencies till node-qunit merges the pull request upgrading the versions of colors.
- Grunt already provides a server, I just moved the cors-server to a separate task. I am considering making a cors proxy, a grunt task and am looking at exsiting node cors-proxy modules that I could use.
- The task to publish test results was also a separate task. Since this is the last task to run, I had to ensure that all test tasks showed pass status even if they failed, to get to the last task. The last task fails, if any of the tests fail. This does not sound very clean, but it is better than grunt --force, which passes travis build, though tests may have failed. I needed a way to get to the last task, and fail only at the last task.
- The saucelabs qunit tests write the results to a database, that the build task then picks up. This coupling between the build and tests is not great, and I am looking at ways the saucelabs-qunit plugin can read JunitLogger from qunit, if something exists.
- A better way to publish results as soon as a test if over, instead of waiting till the end of tasks
- More documentation on command line options for the grunt build.
- Integrate Source maps (like this), to make pouchdb easier to debug.
- Build, run all tests and publish (also run by travis and npm test): grunt build server cors-server node-qunit saucelabs-qunit publish results
- Start development server, cors server on localhost:2020 that redirects to a remote couch installation: grunt server cors-server:2020:http://pouchdb.iriscouch.com forever
- Build files: grunt concat:amd or grunt concat:all or grunt concat min