This is a self contained pre-configured Truffle project that can be compiled and tested on a build server.
Read the full blog post for information on how to set this up https://davidburela.wordpress.com/2017/09/06/ethereum-devops-with-vsts-easier-now-with-new-truffle-installer-npx/
- Clone the repo
- make sure you have npm 5.3.0 or later
- Run
npm installto restore the npm packages. - you can now compile and run the tests using npx to execute the npm packages that are in the DevDependencies
npx truffle compile
npx truffle test --network localtestrpc
I'm taking advantage of 2 important things:
- the new
npxcommand allows you to execute node packages that used to need to be installed globally, and instead you can install as a DevDependency and run it just in the project folder. - I specified a new network in
truffle.jsthat uses the TestRPC provider. This will make Truffle run TestRPC temporarily for the duration of the commmand, and then tear it down again.
to run on a build server the critical commands are:
npm install
npx truffle compile
npx truffle test --network localtestrpc
You may also want to change the mocha reporter to output to a .xml file. You can do this by modifying the truffle.js file
e.g. change mocha: { reporter: "spec", and replace with mocha: { reporter: "mocha-junit-reporter",