Why codecov is not showing report in comments?

时间:2017-03-22 18:46:26

标签: code-coverage travis-ci

I'm trying to setup codecov as code coverage tool in a repository. However, it is passing Travis CI test but not showing codecov report. Here is link of travis report - https://travis-ci.org/fossasia/susper.com/builds/213793203 (see under bash <(curl -s https://codecov.io/bash)). What should I do?

Here is the source code -

package.json

 {
   "name": "susper",
   "version": "0.0.0",
   "license": "MIT",
   "angular-cli": {},
   "scripts": {
     "start": "ng serve",
     "lint": "tslint \"src/**/*.ts\"",
     "test": "ng test",
     "pree2e": "webdriver-manager update",
     "e2e": "protractor"
   },
   "private": true,
   "dependencies": {
     "@angular/common": "2.4.0",
     "@angular/compiler": "2.4.0",
     "@angular/core": "2.4.0",
     "@angular/forms": "2.4.0",
     "@angular/http": "2.4.0",
     "@angular/platform-browser": "2.4.0",
     "@angular/platform-browser-dynamic": "2.4.0",
     "@angular/router": "3.4.0",
     "@ngrx/core": "^1.2.0",
     "@ngrx/effects": "^2.0.0",
     "@ngrx/router-store": "^1.2.5",
     "@ngrx/store": "^2.2.1",
     "@ngrx/store-devtools": "^3.2.3",
     "core-js": "^2.4.1",
     "ngrx-store-freeze": "^0.1.6",
     "reselect": "^2.5.4",
     "rxjs": "5.0.0-beta.12",
     "ts-helpers": "^1.1.1",
     "zone.js": "^0.6.23"
   },
   "devDependencies": {
     "@angular/compiler-cli": "2.4.0",
     "@types/jasmine": "2.5.38",
     "@types/node": "^6.0.42",
     "angular-cli": "1.0.0-beta.24",
+    "codecov.io": "^0.1.6",
     "codelyzer": "~2.0.0-beta.1",
     "jasmine-core": "2.5.2",
     "jasmine-spec-reporter": "2.5.0",
-    "karma": "1.2.0",
+    "karma": "^1.2.0",
     "karma-chrome-launcher": "^2.0.0",
     "karma-cli": "^1.0.1",
+    "karma-coverage": "^1.1.1",
     "karma-jasmine": "^1.0.2",
     "karma-remap-istanbul": "^0.2.1",
     "protractor": "4.0.9",
     "ts-node": "1.2.1",
     "tslint": "^4.0.2",
     "typescript": "~2.0.3",
     "webdriver-manager": "10.2.5"
   }
 }

travis.yml

sudo: required
 dist: trusty
 language: node_js
 node_js:
 - 6
 before_install:
 - export CHROME_BIN=chromium-browser
 - export DISPLAY=:99.0
 - sh -e /etc/init.d/xvfb start
+- pip install --user codecov
 before_script:
 - ng build
 script:
 - ng lint
 - >
   docker run -ti -v $(pwd):/app --workdir=/app coala/base coala --version
 after_success:
 - bash ./deploy.sh
+- bash <(curl -s https://codecov.io/bash)
 cache:
     bundler: true
     directories:
     - node_modules
     - .coala-cache
 services: docker
 branches:
    only:
- angular

karma.conf.js

// Karma configuration file, see link for more information
 // https://karma-runner.github.io/0.13/config/configuration-file.html

 module.exports = function (config) {
   config.set({
     basePath: '',
     frameworks: ['jasmine', 'angular-cli'],
     plugins: [
       require('karma-jasmine'),
       require('karma-chrome-launcher'),
       require('karma-remap-istanbul'),
-      require('angular-cli/plugins/karma')
+      require('angular-cli/plugins/karma'),
+      require('karma-coverage')
     ],
     files: [
       { pattern: './src/test.ts', watched: false }
     ],
     preprocessors: {
-      './src/test.ts': ['angular-cli']
+      './src/test.ts': ['angular-cli'],
+      'src/app/**/*.js': ['coverage']
     },
     mime: {
       'text/x-typescript': ['ts','tsx']
     },
     remapIstanbulReporter: {
       reports: {
         html: 'coverage',
         lcovonly: './coverage/coverage.lcov'
       }
     },
+    coverageReporter: {
+      type : 'lcov',
+      dir : 'coverage/'
+    },
     angularCli: {
       config: './angular-cli.json',
       environment: 'dev'
     },
     reporters: config.angularCli && config.angularCli.codeCoverage
               ? ['progress', 'karma-remap-istanbul']
-              : ['progress'],
+              : ['progress', 'coverage'],
     port: 9876,
     colors: true,
     logLevel: config.LOG_INFO,
     autoWatch: true,
     browsers: ['Chrome'],
     singleRun: false
   });
};

tsconfig.json

{
  "compilerOptions": {
    "baseUrl": "",
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": ["es6", "dom"],
    "mapRoot": "./",
    "module": "es6",
    "moduleResolution": "node",
    "outDir": "../dist/out-tsc",
    "sourceMap": true,
    "target": "es5",
    "typeRoots": [
      "../node_modules/@types"
    ]
  }
}

1 个答案:

答案 0 :(得分:1)

很高兴帮忙!

问题:未生成任何报告。见https://travis-ci.org/fossasia/susper.com/builds/213793203#L390

<强>建议

  1. 您不需要在同一个项目中使用bash上传器和节点上传器。所以你可以选择其中一个。尽管如此,您已正确配置Codecov。
  2. 使用Docker:http://docs.codecov.io/docs/testing-with-docker
  3. 我没有深入研究您的项目,但我怀疑报告是在docker容器内,需要传递给Travis。