or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration-management.mdcoverage-processing.mdhttp-submission.mdindex.mdlcov-conversion.md
tile.json

coverage-processing.mddocs/

Coverage Processing

Main workflow function that orchestrates the complete coverage submission process from LCOV input to Coveralls.io API submission.

Capabilities

Main Processing Function

Handles the complete workflow of processing LCOV coverage data and submitting it to Coveralls.io.

/**
 * Process LCOV coverage data and submit to Coveralls.io
 * @param input - LCOV format coverage data as string
 * @param callback - Error-first callback with result
 * @param userOptions - Optional user-provided configuration overrides
 */
function handleInput(
  input: string, 
  callback: (err: Error | null, result?: string) => void,
  userOptions?: object
): void;

Usage Examples:

const coveralls = require('coveralls');
const fs = require('fs');

// Basic usage with LCOV file
const lcovData = fs.readFileSync('./coverage/lcov.info', 'utf8');

coveralls.handleInput(lcovData, (err, result) => {
  if (err) {
    console.error('Error:', err);
    process.exit(1);
  }
  console.log('Success:', result);
});

// With custom options
const userOptions = {
  service_name: 'custom-ci',
  repo_token: 'your-repo-token'
};

coveralls.handleInput(lcovData, (err, result) => {
  if (err) {
    console.error('Coverage submission failed:', err);
  } else {
    console.log('Coverage submitted successfully');
  }
}, userOptions);

Workflow Steps

The handleInput function performs these operations in sequence:

  1. Options Resolution: Calls getOptions() to gather configuration from environment variables, CI detection, and user overrides
  2. LCOV Conversion: Calls convertLcovToCoveralls() to parse LCOV data and transform to Coveralls format
  3. API Submission: Calls sendToCoveralls() to post data to Coveralls.io API
  4. Response Handling: Processes HTTP response and invokes callback with result or error

Error Handling

The function handles errors at each workflow step:

  • Configuration Errors: Missing required environment variables or invalid options
  • Conversion Errors: Malformed LCOV input or file access issues
  • Network Errors: HTTP request failures or connectivity issues
  • API Errors: HTTP status codes >= 400 from Coveralls.io API

Common error scenarios:

coveralls.handleInput(lcovData, (err, result) => {
  if (err) {
    if (err.message.includes('Bad response')) {
      // API returned error status
      console.error('Coveralls API error:', err);
    } else if (err.message.includes('error from getOptions')) {
      // Configuration problem
      console.error('Configuration error:', err);
    } else if (err.message.includes('error from convertLcovToCoveralls')) {
      // LCOV parsing problem
      console.error('LCOV conversion error:', err);
    } else {
      // Network or other error
      console.error('Unexpected error:', err);
    }
    return;
  }
  // Success
  console.log('Coverage submitted:', result);
});

Command-Line Integration

This function is used by the CLI tool to process stdin input:

# Direct piping
cat coverage/lcov.info | coveralls

# With test frameworks
jest --coverage && coveralls < coverage/lcov.info
mocha --reporter mocha-lcov-reporter | coveralls