Skip to content
Draft
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
Binary file added .DS_Store
Binary file not shown.
29 changes: 29 additions & 0 deletions .github/scripts/annotate_errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env python3
import re
import sys

def annotate_errors(log_file):
with open(log_file, 'r') as file:
for line in file:
# Match error patterns. For GCC/Clang: "error:"; for MSVC: "error Cxxxx:"
match = re.search(r'(.+):(\d+):(\d+): (error: .+)|(.+)\((\d+)\) ?: (error C[0-9]+: .+)', line)
if match:
if match.group(1):
# GCC/Clang style error
file_path, line_num, col_num, message = match.group(1), match.group(2), match.group(3), match.group(4)
print(f"::error file={file_path},line={line_num},col={col_num}::{message}")
elif match.group(5):
# MSVC style error
file_path, line_num, message = match.group(5), match.group(6), match.group(7)
print(f"::error file={file_path},line={line_num}::{message}")

if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: annotate_errors.py <log_file>")
sys.exit(1)

log_file = sys.argv[1]
try:
annotate_errors(log_file)
except:
print("Failed to read the file")
22 changes: 22 additions & 0 deletions .github/scripts/annotate_warnings.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env python3
import re
import sys

def annotate_warnings(log_file):
with open(log_file, 'r') as file:
for line in file:
match = re.search(r'(.+):(\d+):(\d+): warning: (.+)', line)
if match:
file_path, line_num, col_num, message = match.groups()
print(f"::warning file={file_path},line={line_num},col={col_num}::{message}")

if __name__ == "__main__":
if len(sys.argv) != 2:
print("Usage: annotate_warnings.py <log_file>")
sys.exit(1)

log_file = sys.argv[1]
try:
annotate_warnings(log_file)
except:
print("Failed to read the file")
140 changes: 140 additions & 0 deletions .github/scripts/generate_coverage_reports.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
module.exports = ({ github, context }) => {
const fs = require('fs');
const path = require('path');

// Recursively get all coverage-*/coverage.json files from the directory
function getAllCoverageFiles(dir) {
let files = [];

fs.readdirSync(dir).forEach(file => {
const fullPath = path.join(dir, file);
console.log(dir, file, '=', fullPath);
if (file.startsWith('coverage-')) {
files.push(fullPath);
console.log('Approved:', fullPath);
}
});

return files;
}

// Get all coverage files from the directory
const coverageFiles = getAllCoverageFiles('coverage-files/');
console.log('Coverage files:', coverageFiles);

// Extract unique uncovered lines and annotations
function getUniqueCoverageData(coverageFiles) {
const aggregated_data = {
"files": new Set(),
"functions": new Set(),
"totals": new Set()
};

coverageFiles.forEach(file => {
const data = JSON.parse(fs.readFileSync(file + "/coverage.json", 'utf8'));
data['data'][0]['files'].forEach(file => aggregated_data["files"].add(file));
data['data'][0]['functions'].forEach(function_data => aggregated_data["functions"].add(function_data));
aggregated_data["totals"].add(data['data'][0]['totals']);
});

return aggregated_data;
}

const aggregated_data = getUniqueCoverageData(coverageFiles);

// Extract unique annotations
function getUniqueUncoveredLines(aggregated_data) {
const uncoveredLinesSet = new Set();
const annotations = [];

aggregated_data.files.forEach(file => {
if (file.segments && Array.isArray(file.segments)) {
const fileName = file.filename;
file.segments.forEach(segment => {
const [line, col, count] = segment;
const key = `${fileName}:${line}`; // Unique key based on filename and line number
if (count === 0 && !uncoveredLinesSet.has(key)) {
uncoveredLinesSet.add(key);
annotations.push({
path: fileName,
start_line: line,
end_line: line,
annotation_level: 'warning',
message: 'Uncovered line'
});
}
});
}
});

return annotations;
}

// Get unique uncovered lines from the combined coverage
const annotations = getUniqueUncoveredLines(aggregated_data);

// Send annotations to the pull request (once per uncovered line)
annotations.forEach(annotation => {
github.rest.checks.create({
owner: context.repo.owner,
repo: context.repo.repo,
name: 'Code Coverage Check',
head_sha: context.sha,
output: {
title: 'Code Coverage Report',
summary: 'Found uncovered lines',
annotations: [annotation],
},
});
});

// Function to calculate overall and file-specific coverage
function calculateCoverage(aggregated_data) {
let fileCoverage = [];
let totalLines = 0;
let coveredLines = 0;
let processedFiles = new Set(); // To avoid duplicate files

aggregated_data.files.forEach(file => {
if (!processedFiles.has(file.filename)) {
const fileSummary = file.summary.lines;

// Extract per-file coverage percentage
fileCoverage.push({
filename: file.filename,
coveragePercentage: fileSummary.percent.toFixed(2),
totalLines: fileSummary.count,
coveredLines: fileSummary.covered
});

totalLines += fileSummary.count;
coveredLines += fileSummary.covered;
processedFiles.add(file.filename); // Mark file as processed
}
});

const overallCoverage = (coveredLines / totalLines) * 100;

return { overallCoverage: overallCoverage.toFixed(2), fileCoverage };
}

// Calculate overall and per-file coverage
const { overallCoverage, fileCoverage } = calculateCoverage(aggregated_data);

// Build the coverage summary message
let summary = `### Code Coverage Summary\n`;
summary += `**Overall Coverage**: ${overallCoverage}%\n\n`;
summary += `#### File-by-file Coverage:\n`;

fileCoverage.forEach(file => {
summary += `- **${file.filename}**: ${file.coveragePercentage}% (${file.coveredLines}/${file.totalLines} lines covered)\n`;
});

// Post the summary as a comment on the pull request
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: summary,
});
}
23 changes: 0 additions & 23 deletions .github/workflows/auto-clang-format.yml

This file was deleted.

Loading
Loading