Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Commit

Permalink
initial commit from cainus/codecov.io
Browse files Browse the repository at this point in the history
  • Loading branch information
stevepeak committed Oct 16, 2015
0 parents commit 4be4171
Show file tree
Hide file tree
Showing 38 changed files with 1,243 additions and 0 deletions.
28 changes: 28 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directory
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules

lib-cov/
coverage.json
5 changes: 5 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
language: node_js
sudo: false
node_js:
- '0.10'
- '0.11'
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Gregg Caines

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
REPORTER = spec
test:
@$(MAKE) lint
@NODE_ENV=test ./node_modules/.bin/mocha -b --reporter $(REPORTER) --recursive

lint:
./node_modules/.bin/jshint ./lib ./test ./index.js

deploy:
$(eval VERSION := $(shell cat package.json | grep '"version"' | cut -d\" -f4))
git tag v$(VERSION) -m ""
git push origin v$(VERSION)
npm publish

testsuite:
curl -X POST https://circleci.com/api/v1/project/codecov/testsuite/tree/master?circle-token=$(CIRCLE_TOKEN)\
--header "Content-Type: application/json"\
--data "{\"build_parameters\": {\"TEST_LANG\": \"node\",\
\"TEST_SLUG\": \"$(CIRCLE_PROJECT_USERNAME)/$(CIRCLE_PROJECT_REPONAME)\",\
\"TEST_SHA\": \"$(CIRCLE_SHA1)\"}}"


.PHONY: test
83 changes: 83 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# codecov.io

[![NPM version][npm-image]][npm-url]
[![Build Status][travis-image]][travis-url] [![codecov.io](https://codecov.io/github/cainus/codecov.io/coverage.svg?branch=master)](https://codecov.io/github/cainus/codecov.io?branch=master)
[![Dependency Status][depstat-image]][depstat-url]
[![Dev Dependency Status][devdepstat-image]][devdepstat-url]

[Codecov.io](https://codecov.io/) support for node.js. Get the great coverage reporting of codecov.io and add a cool coverage button ( like the one above ) to your README.

## Installation:
Add the latest version of `codecov.io` to your package.json:
```
npm install codecov.io --save
```

## Usage:

This script ( `bin/codecov.io.js` ) can take standard input from any tool that emits the lcov, gcov or standardized json data format and send it to codecov.io to report your code coverage there.

Once your app is instrumented for coverage, and building, you need to pipe the coverage reports output to `./node_modules/codecov.io/bin/codecov.io.js`.

This library currently supports the following CI companies: [Travis CI](https://travis-ci.org/), [Travis](https://travis-ci.com/), [Appveyor](https://appveyor.com/), [CircleCI](https://circleci.com/), [Codeship](https://codeship.io/), [Drone](https://drone.io/), [Jenkins](http://jenkins-ci.org/), [Shippable](https://shippable.com/), [Semaphore](https://semaphoreapp.com/), [Wercker](https://wercker.com/), [Snap CI](https://snap-ci.com/), [Buildkite](https://buildkite.com/).

#### Upload repo tokens
> Repo tokens are **not** required for public repos tested on Travis-Org, CircleCI or AppVeyor.
Repo tokens are neccessary to distinquish your repository from others. You can find your repo token on your repository page at Codecov. Set this unique uuid to `CODECOV_TOKEN` in your environment variables.

```
export CODECOV_TOKEN=":uuid-repo-token"
# or
./node_modules/.bin/codecov --token=:token
```

#### [Istanbul](https://github.com/gotwarlost/istanbul)

**With Mocha:**

```sh
istanbul cover ./node_modules/mocha/bin/_mocha -- -R spec
./node_modules/.bin/codecov
```

**With Jasmine:**

```sh
istanbul cover jasmine-node --captureExceptions spec/
./node_modules/.bin/codecov
```

**With Tape:**

```sh
istanbul cover test.js
./node_modules/.bin/codecov
```

----

## Advanced: Partial Line Coverage
**Codecov does support partial line coverage**. However, some node projects do not report partial coverage accurate enough.
You can decide to upload the partial coverage report by chaning the target upload file to `./coverage/coverage.json`.
View your report on Codecov, if the reports are not accurate then switch back to the `lcov` provided above.

We are working on improving this implementation and appreciate your patience.

## Contributing

I generally don't accept pull requests that are untested, or break the build, because I'd like to keep the quality high (this is a coverage tool afterall!).

I also don't care for "soft-versioning" or "optimistic versioning" (dependencies that have ^, x, > in them, or anything other than numbers and dots). There have been too many problems with bad semantic versioning in dependencies, and I'd rather have a solid library than a bleeding edge one.

[travis-image]: https://travis-ci.org/cainus/codecov.io.svg?branch=master
[travis-url]: https://travis-ci.org/cainus/codecov.io

[npm-url]: https://npmjs.org/package/codecov.io
[npm-image]: https://img.shields.io/npm/v/codecov.io.svg

[depstat-url]: https://david-dm.org/cainus/codecov.io
[depstat-image]: https://img.shields.io/david/cainus/codecov.io/master.svg

[devdepstat-url]: https://david-dm.org/cainus/codecov.io#info=devDependencies
[devdepstat-image]: https://img.shields.io/david/dev/cainus/codecov.io/master.svg
24 changes: 24 additions & 0 deletions bin/codecov
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env node
var argv = require('argv');
var sendToCodeCov = require('../lib/sendToCodeCov.io');


var args = argv.option([
{name: 'token', short: 't', type: 'string', description: "Private repository token. Not required for public repos on Travis, CircleCI and AppVeyor"},
{name: 'file', short: 'f', type: 'path', description: "Target a specific file for uploading and disabling automatic detection of coverage files."},
{name: 'env', short: 'e', type: 'string', description: "Store environment variables to help distinguish CI builds. Example: http://bit.ly/1ElohCu", example: "--env=VAR1,VAR2,VAR3"},
{name: 'gcov-root', type: 'path', description: "Project root directory when preparing gcov"},
{name: 'gcov-glob', type: 'string', description: "Paths to ignore during gcov gathering"},
{name: 'gcov-exec', type: 'string', description: "gcov executable to run. Defaults to 'gcov'"},
{name: 'gcov-args', type: 'string', description: "extra arguments to pass to gcov"},
{name: 'disable', short: 'X', type: 'string', description: "Disable features. Accepting `search` to disable crawling through directories, `detect` to disable detecting CI provider, `gcov` disable gcov commands"},
{name: 'commit', short: 'c', type: 'string', description: "Commit sha, set automatically"},
{name: 'branch', short: 'b', type: 'string', description: "Branch name"},
{name: 'build', short: 'B', type: 'string', description: "Specify a custom build number to distinguish ci jobs, provided automatically for supported ci companies"},
{name: 'slug', short: 'r', type: 'string', description: "Specify repository slug for Enterprise ex. owner/repo"},
{name: 'url', short: 'u', type: 'string', description: "Your Codecov endpoint"},
{name: 'dump', type: 'boolean', description: "Dump collected data and do not send to Codecov"}
]).run();

console.log(args);
sendToCodeCov(args);
9 changes: 9 additions & 0 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
machine:
node:
version: 0.10.33

deployment:
suite:
branch: /.*/
commands:
- make testsuite
3 changes: 3 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var handleInput = require('./lib/codecov');

exports.handleInput = handleInput;
Loading

0 comments on commit 4be4171

Please sign in to comment.