Solidity-coverage: Error : /bin/sh: 1: truffle: not found

Created on 6 Sep 2019  路  4Comments  路  Source: sc-forks/solidity-coverage

I I just installed and used this package in few days ago . it was great . but when I try to run it on Circle CI it gets this error.

./node_modules/.bin/solidity-coverage
Generating coverage environment
Running: truffle compile --network coverage 
(this can take a few seconds)...
/bin/sh: 1: truffle: not found
ls: no such file or directory: ./coverageEnv/build/contracts/*.json
Skipping instrumentation of  ./coverageEnv/contracts/Migrations.sol
Instrumenting  ./coverageEnv/contracts/SimpleContract.sol
Running: truffle compile --network coverage 
(this can take a few seconds)...
/bin/sh: 1: truffle: not found
ls: no such file or directory: ./coverageEnv/build/contracts/*.json
Launched testrpc on port 8555
Running: truffle test --network coverage 
(this can take a few seconds)...
/bin/sh: 1: truffle: not found
Cleaning up...
Shutting down testrpc-sc (pid 1243)
Event trace could not be read.
Error: ENOENT: no such file or directory, open './allFiredEvents'
Exiting without generating coverage...
Exited with code 1

This is my .circleci/config.yml

version: 2
jobs:
  build:
    working_directory: ~/smart-contracts
    # The primary container is an instance of the first image listed. The job's commands run in this container.
    docker:
      - image: circleci/node:8-browsers
      # The secondary container is an instance of the second listed image which is run in a common network where ports exposed on the primary container are available on localhost.
      - image: trufflesuite/ganache-cli
    steps:
      - checkout
      - run:
          name: Update npm
          command: 'sudo npm install -g npm@latest'
      - restore_cache:
          key: dependency-cache-{{ checksum "package.json" }}
      - run:
          name: Install npm wee
          command: npm install
      - run:
          name: Migrate Contracts
          command: ./node_modules/truffle/build/cli.bundled.js migrate --network development
      - run:
          name: Test Contracts
          command: ./node_modules/truffle/build/cli.bundled.js test --network development
      - run:
          name: Test coverage
          command: ./node_modules/.bin/solidity-coverage
      - save_cache:
          key: dependency-cache-{{ checksum "package.json" }}
          paths:
            - node_modules

this is my repo : https://github.com/vinhyenvodoi98/Test_Contract_With_Truffle/tree/CircleCI
thanks for this great package :+1:

Most helpful comment

@vinhyenvodoi98 Ah I'm sorry, I think you'll need to something similar for the compile command in Circle. Does it work if you add this?

module.exports = {
  compileCommand: '../node_modules/.bin/truffle compile',
  testCommand: '../node_modules/.bin/truffle test --network coverage',
}

I just cloned and ran your repo locally and everything seems fine there.

Screen Shot 2019-09-06 at 1 16 24 AM

All 4 comments

@vinhyenvodoi98 Could you try creating a .solcover.js config file in your project and adding the following to it:

module.exports = {
  testCommand: '../node_modules/.bin/truffle test --network coverage',
}

NB: you'll have to have truffle in your local node_modules for everything to work locally too.

@cgewecke thanks it work very well but some thing it different on network
i pass all the test but fail in coverage
check it out :
https://circleci.com/gh/vinhyenvodoi98/Test_Contract_With_Truffle/19
I wonder what happened

@vinhyenvodoi98 Ah I'm sorry, I think you'll need to something similar for the compile command in Circle. Does it work if you add this?

module.exports = {
  compileCommand: '../node_modules/.bin/truffle compile',
  testCommand: '../node_modules/.bin/truffle test --network coverage',
}

I just cloned and ran your repo locally and everything seems fine there.

Screen Shot 2019-09-06 at 1 16 24 AM

@cgewecke Great! I wish i could give more than one star

Was this page helpful?
0 / 5 - 0 ratings