Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ Inspired from [z4r/python-coveralls](https://github.com/z4r/python-coveralls), i
- `COVERALLS_REPO_TOKEN`
- `COVERALLS_ENDPOINT`
- `COVERALLS_PARALLEL`
- `CI_SERVICE_NAME`


## Usage:
Expand Down
8 changes: 7 additions & 1 deletion cpp_coveralls/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,13 @@ def run():
# use environment COVERALLS_REPO_TOKEN as a fallback
args.repo_token = os.environ.get('COVERALLS_REPO_TOKEN')

args.service_name = yml.get('service_name', 'travis-ci')
args.service_name = yml.get('service_name', '')
if not args.service_name:
# use environment CI_SERVICE_NAME as a fallback
args.service_name = os.environ.get('CI_SERVICE_NAME')
if not args.service_name:
# use default 'travis-ci' as a fallback 2
args.service_name = 'travis-ci'

if not args.gcov_options:
args.gcov_options = yml.get('gcov_options', '')
Expand Down
17 changes: 14 additions & 3 deletions cpp_coveralls/coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,14 +374,28 @@ def collect_non_report_files(args, discovered_files):
def collect(args):
"""Collect coverage reports."""
excl_paths = exclude_paths(args)
abs_root = os.path.abspath(args.root)

report = {}
# Use the root directory to get information on the Git repository
report['git'] = gitrepo.gitrepo(abs_root)

if args.repo_token:
report['repo_token'] = args.repo_token

report['service_name'] = args.service_name
report['service_job_id'] = args.service_job_id

# If the service_name + service_job_id is not set to identify build,
# the default build numbers auto-incremented by coveralls.io seems to never advance
# (doing just incremental changes to original build #1), so this git revision number
# hack is used to get something more meaningful (at least at the project I'm trying
# to make this work, it's acting like this, numbering coverage data 1.1, 1.2, 1.3,..)
## This may be inherently wrong solution and complete hack, feel free to comment+help
# to resolve this in more appropriate way. by Ped7g ( https://github.com/ped7g )
if not args.service_job_id:
report['service_number'] = report['git']['head']['rev_count']

if os.getenv('COVERALLS_PARALLEL', False):
report['parallel'] = 'true'

Expand All @@ -393,7 +407,6 @@ def collect(args):

discovered_files = set()
src_files = {}
abs_root = os.path.abspath(args.root)
if args.lcov_file:
info_lines = [line.rstrip('\n') for line in open(args.lcov_file, 'r')]
line_iter = iter(info_lines)
Expand Down Expand Up @@ -467,6 +480,4 @@ def collect(args):
report['source_files'].extend(
collect_non_report_files(args, discovered_files))

# Use the root directory to get information on the Git repository
report['git'] = gitrepo.gitrepo(abs_root)
return report
3 changes: 2 additions & 1 deletion cpp_coveralls/gitrepo.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ def gitrepo(cwd):
'author_email': repo.gitlog('%ae'),
'committer_name': repo.gitlog('%cN'),
'committer_email': repo.gitlog('%ce'),
'message': repo.gitlog('%s')
'message': repo.gitlog('%s'),
'rev_count': repo.git('rev-list', '--count', 'HEAD')[1].strip()
},
'branch': os.environ.get('TRAVIS_BRANCH',
os.environ.get('APPVEYOR_REPO_BRANCH',
Expand Down