Initial commit

This commit is contained in:
Zhongwei Li
2025-11-30 08:23:32 +08:00
commit bdbf04e5aa
11 changed files with 596 additions and 0 deletions

View File

@@ -0,0 +1,7 @@
# Assets
Bundled resources for test-coverage-analyzer skill
- [ ] report_template.html: HTML template for generating visually appealing coverage reports.
- [ ] example_coverage_report.html: Example HTML coverage report.
- [ ] configuration_template.yaml: Template for configuring the coverage analysis.

View File

@@ -0,0 +1,91 @@
# Configuration for the Test Coverage Analyzer Plugin
# General settings for the analysis
general:
# Project name (used in reports)
project_name: "REPLACE_ME - Project Name"
# Root directory of the project (where the source code resides)
project_root: "/path/to/your/project/root" # REPLACE_ME
# Output directory for generated reports
report_output_dir: "coverage_reports"
# Enable/disable verbose logging
verbose: false
# Coverage data settings
coverage_data:
# Type of coverage data format. Supported values: lcov, cobertura, gcov
format: "lcov"
# Path to the coverage data file (e.g., lcov.info, coverage.xml, *.gcov)
# Can be a single file or a glob pattern.
data_file: "coverage.info" # REPLACE_ME
# Exclude files or directories from coverage analysis (glob patterns)
exclude:
- "**/test/**"
- "**/vendor/**"
- "**/node_modules/**"
- "**/migrations/**"
# Threshold settings for enforcing minimum coverage
thresholds:
# Enable or disable threshold checks
enabled: true
# Minimum overall coverage percentage required for the project to pass
overall: 80
# Minimum coverage percentage required for each file
file: 70
# Minimum coverage percentage required for each function
function: 60
# Allow thresholds to be bypassed on specific files or paths
exemptions:
# - path: "path/to/file.py"
# overall: 70 # Reduced overall threshold for this specific file
# file: 60 # Reduced file threshold for this specific file
# function: 50 # Reduced function threshold for this specific file
# Report generation settings
report:
# Type of report to generate. Supported values: html, json, console
type: "html"
# Include uncovered code snippets in the report (can make reports larger)
include_uncovered_code: true
# Custom CSS file to apply to the HTML report (optional)
custom_css: "" # "path/to/custom.css"
# Advanced settings (for specific coverage tools)
advanced:
# GCOV specific settings
gcov:
# Path to the gcov executable
executable: "gcov" # /usr/bin/gcov
# Cobertura specific settings
cobertura:
# Path to the source root (if not correctly specified in the cobertura report)
source_root: "" # REPLACE_ME
# Integration with CI/CD systems (optional)
ci:
# Fail the build if coverage thresholds are not met
fail_on_threshold: true
# Output format for CI integration (e.g., junit)
output_format: "" # junit
# Example configuration for a specific language (Python)
python:
# Path to the python executable
executable: "python3" # REPLACE_ME
# Additional arguments to pass to the python executable
arguments: [] # ["-m", "pytest"]

View File

@@ -0,0 +1,138 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Code Coverage Report</title>
<style>
/* Inline CSS for styling */
body {
font-family: sans-serif;
margin: 20px;
background-color: #f4f4f4;
color: #333;
}
h1 {
text-align: center;
color: #007bff;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
overflow: hidden; /* Ensures rounded corners work correctly */
}
th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #007bff;
color: white;
font-weight: bold;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
tr:hover {
background-color: #ddd;
}
.coverage-bar {
width: 100%;
height: 10px;
background-color: #ddd;
border-radius: 5px;
overflow: hidden; /* Hide overflowing gradient */
}
.coverage-bar-inner {
height: 100%;
background: linear-gradient(to right, #4CAF50, #8BC34A); /* Green gradient */
width: {{coverage_percentage}}%; /* Placeholder for coverage percentage */
}
.summary {
margin-top: 20px;
padding: 15px;
background-color: #fff;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 8px;
}
.summary p {
margin: 5px 0;
}
@media (max-width: 600px) {
table {
overflow-x: auto; /* Enable horizontal scrolling on small screens */
display: block; /* Required for overflow-x to work */
}
th, td {
white-space: nowrap; /* Prevent text wrapping */
}
}
</style>
</head>
<body>
<!-- Main heading -->
<h1>Code Coverage Report</h1>
<!-- Coverage Summary -->
<div class="summary">
<p><strong>Total Coverage:</strong> {{total_coverage}}%</p>
<p><strong>Covered Lines:</strong> {{covered_lines}}</p>
<p><strong>Uncovered Lines:</strong> {{uncovered_lines}}</p>
<p><strong>Timestamp:</strong> {{timestamp}}</p>
</div>
<!-- Coverage Table -->
<table>
<thead>
<tr>
<th>File</th>
<th>Coverage</th>
<th>Lines Covered</th>
<th>Lines Uncovered</th>
</tr>
</thead>
<tbody>
{{table_rows}} <!-- Placeholder for table rows -->
</tbody>
</table>
<!-- Example Table Row (to be replaced by actual data) -->
<!-- Example:
<tr>
<td>example.py</td>
<td>
<div class="coverage-bar">
<div class="coverage-bar-inner" style="width: 85%;"></div>
</div>
85%
</td>
<td>170</td>
<td>30</td>
</tr>
-->
<!-- Footer -->
<footer>
<p>&copy; {{year}} Test Coverage Analyzer Plugin</p>
</footer>
</body>
</html>

View File

@@ -0,0 +1,136 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test Coverage Report</title>
<style>
/* Inline CSS for styling */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
color: #333;
}
.container {
width: 90%;
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
h1 {
text-align: center;
color: #007bff;
}
h2 {
color: #333;
border-bottom: 1px solid #ddd;
padding-bottom: 5px;
}
table {
width: 100%;
border-collapse: collapse;
margin-top: 10px;
}
th, td {
padding: 8px;
text-align: left;
border-bottom: 1px solid #ddd;
}
th {
background-color: #f2f2f2;
}
.coverage-summary {
margin-top: 20px;
}
.coverage-metric {
display: inline-block;
margin-right: 20px;
}
.coverage-metric strong {
color: #007bff;
}
.untested-code {
margin-top: 20px;
}
pre {
background-color: #f9f9f9;
padding: 10px;
border: 1px solid #eee;
overflow-x: auto;
white-space: pre-wrap;
word-wrap: break-word;
}
@media (max-width: 768px) {
.container {
width: 95%;
}
table {
font-size: 0.8em;
}
}
</style>
</head>
<body>
<div class="container">
<h1>Test Coverage Report</h1>
<div class="coverage-summary">
<h2>Overall Coverage</h2>
<div class="coverage-metric">
Lines Covered: <strong>{{lines_covered}}%</strong>
</div>
<div class="coverage-metric">
Branches Covered: <strong>{{branches_covered}}%</strong>
</div>
<div class="coverage-metric">
Functions Covered: <strong>{{functions_covered}}%</strong>
</div>
<div class="coverage-metric">
Statements Covered: <strong>{{statements_covered}}%</strong>
</div>
</div>
<h2>File Coverage Details</h2>
<table>
<thead>
<tr>
<th>File</th>
<th>Lines</th>
<th>Branches</th>
<th>Functions</th>
<th>Statements</th>
</tr>
</thead>
<tbody>
{{file_coverage_rows}}
</tbody>
</table>
<div class="untested-code">
<h2>Untested Code Snippets</h2>
{{untested_code_snippets}}
</div>
<h2>Coverage Trends</h2>
<img src="{{coverage_trend_chart_url}}" alt="Coverage Trend Chart">
</div>
</body>
</html>