CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-python-coveralls

Python interface to coveralls.io API for uploading code coverage results

Pending
Overview
Eval results
Files

main-workflow.mddocs/

Main Workflow and CLI

The main workflow module provides the primary entry point and command-line interface for uploading coverage results to coveralls.io. It orchestrates the complete process from argument parsing through data collection to API submission.

Capabilities

Main Entry Point

The primary function that coordinates the entire coverage upload workflow.

def wear(args=None):
    """
    Main workflow function for uploading coverage to coveralls.io.
    
    Args:
        args (Arguments, optional): Parsed arguments object. If None, 
                                  arguments are parsed from command line.
    
    Returns:
        int: Exit code (0 for success, 1 for error)
    
    Process:
        1. Parse arguments and configuration
        2. Load coverage data using coverage.py
        3. Extract repository information (git/hg)
        4. Generate coveralls-formatted report
        5. Submit to coveralls.io API
        6. Return success/failure status
    """

Argument Parsing

Parses command-line arguments and merges with configuration file settings.

def parse_args():
    """
    Parse command-line arguments and configuration files.
    
    Returns:
        Arguments: Parsed arguments object with all configuration options
        
    Configuration Sources (in order of precedence):
        1. Command-line arguments
        2. .coveralls.yml file
        3. Environment variables
        4. Default values
    """

Command-Line Interface

Installation and Setup

pip install python-coveralls

Basic Usage

# Upload coverage after running tests
coveralls

# Common CI workflow
python -m pytest --cov=mypackage
coveralls

Command-Line Options

usage: coveralls [-h] [--coveralls_url COVERALLS_URL] [--base_dir BASE_DIR]
                 [--data_file DATA_FILE] [--config_file CONFIG_FILE]
                 [--coveralls_yaml COVERALLS_YAML] [--ignore-errors]
                 [--merge_file MERGE_FILE] [--nogit] [--skip_ssl_verify]

Option Details

# URL Configuration
--coveralls_url, -u: str  # coveralls.io API URL (default: 'https://coveralls.io/api/v1/jobs')

# File Paths
--base_dir, -b: str       # project root directory (default: '.')
--data_file, -d: str      # coverage file name (default: None - auto-detect)
--config_file, -c: str    # coverage config file name (default: None - auto-detect)
--coveralls_yaml, -y: str # coveralls yaml file name (default: '.coveralls.yml')
--merge_file, -m: str     # json file for merging JavaScript coverage (default: None)

# Behavior Options
--ignore-errors, -i: bool # ignore errors while reading source files (default: False)
--nogit: bool            # do not gather git repo info (default: False)
--skip_ssl_verify: bool  # skip SSL certificate verification (default: False)

Configuration Integration

YAML Configuration

# .coveralls.yml
repo_token: "your_repository_token"
service_name: "travis-ci"  # or "travis-pro", "circle-ci", etc.
parallel: true            # for parallel CI builds

Environment Variables

# Authentication
COVERALLS_REPO_TOKEN: str     # Repository token (overrides yaml)

# CI Service Configuration
COVERALLS_SERVICE_NAME: str   # Service name (overrides yaml)
COVERALLS_PARALLEL: bool      # Parallel builds flag (overrides yaml)

# Travis CI Integration
TRAVIS_JOB_ID: str           # Automatically detected job ID
TRAVIS_BRANCH: str           # Automatically detected branch

# Circle CI Integration  
CIRCLE_BRANCH: str           # Automatically detected branch

Usage Examples

Basic CI Integration

# In .travis.yml after_success section
after_success:
  - coveralls

# In GitHub Actions
- name: Upload coverage to Coveralls
  run: coveralls
  env:
    COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}

Custom Configuration

# Specify custom paths and options
coveralls --base_dir /path/to/project \
          --data_file .coverage \
          --config_file .coveragerc \
          --ignore-errors

# Skip git info for Docker builds
coveralls --nogit

# Corporate environment with SSL issues
coveralls --skip_ssl_verify

Merging JavaScript Coverage

# Generate JavaScript coverage in JSON format first
npm run test:coverage

# Merge with Python coverage
coveralls --merge_file coverage/coverage.json

Package Metadata

# Package metadata constants
__version__: str = "2.9.3"
__author__: str = "Andrea De Marco <24erre@gmail.com>"
__license__: str = "Apache License 2.0"
__classifiers__: list[str]  # Development status, audience, license, OS, Python versions
__copyright__: str = "2013, Andrea De Marco <24erre@gmail.com>"
__docformat__: str = "restructuredtext en"

Error Handling

The main workflow handles various error conditions gracefully:

  • Missing coverage files: Auto-detection with fallback to common locations
  • Source file read errors: Optional with --ignore-errors flag
  • Network errors: SSL verification bypass option
  • Repository detection: Optional git/hg integration with --nogit flag
  • Configuration errors: Graceful fallback to defaults

Install with Tessl CLI

npx tessl i tessl/pypi-python-coveralls

docs

api-communication.md

coverage-processing.md

index.md

main-workflow.md

repository-integration.md

tile.json