Skip to content

CI Analysis: Add GitHub Actions workflow analysis capabilities #85

@jordanpartridge

Description

@jordanpartridge

Summary

Add comprehensive GitHub Actions workflow and CI analysis capabilities to enable programmatic debugging of test failures, workflow runs, and check results.

Motivation

Currently, debugging CI failures requires complex shell commands and manual log inspection. We need proper GitHub API integration to:

  • Programmatically analyze test failures
  • Get detailed error logs and annotations
  • Monitor workflow health and performance
  • Enable automated CI issue detection

Proposed Implementation

New ActionsResource Methods

// Workflow run analysis
Github::actions()->getRuns('owner', 'repo', ['status' => 'failure']);
Github::actions()->getRun('owner', 'repo', $runId);
Github::actions()->getRunJobs('owner', 'repo', $runId);

// Check run analysis  
Github::actions()->getCheckRuns('owner', 'repo', 'commit-sha');
Github::actions()->getCheckRun('owner', 'repo', $checkRunId);
Github::actions()->getCheckAnnotations('owner', 'repo', $checkRunId);

// Log retrieval
Github::actions()->getRunLogs('owner', 'repo', $runId);
Github::actions()->getJobLogs('owner', 'repo', $jobId);

// Analysis helpers
Github::actions()->getFailedChecks('owner', 'repo', 'commit-sha');
Github::actions()->analyzeTestFailures('owner', 'repo', $runId);

Required GitHub API Endpoints

  • GET /repos/{owner}/{repo}/actions/runs - List workflow runs
  • GET /repos/{owner}/{repo}/actions/runs/{run_id} - Get specific run
  • GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs - Get jobs for run
  • GET /repos/{owner}/{repo}/actions/runs/{run_id}/logs - Download logs
  • GET /repos/{owner}/{repo}/actions/jobs/{job_id}/logs - Download job logs
  • GET /repos/{owner}/{repo}/commits/{ref}/check-runs - Check runs for commit
  • GET /repos/{owner}/{repo}/check-runs/{check_run_id} - Specific check run
  • GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations - Failure details

New DTOs

  • WorkflowRunDTO - Workflow run data with status, timing, conclusion
  • JobDTO - Individual job data with steps and logs
  • CheckRunDTO - Check run data with annotations and details
  • CheckAnnotationDTO - Specific failure/error annotations
  • CIAnalysisDTO - Aggregated analysis of CI health

Use Cases

// Debug current PR failures
$pr = Github::pullRequests()->detail('owner', 'repo', 80);
$failures = Github::actions()->getFailedChecks('owner', 'repo', $pr->head->sha);

foreach ($failures as $failure) {
    echo "{$failure->name}: {$failure->conclusion}\n";
    $annotations = Github::actions()->getCheckAnnotations('owner', 'repo', $failure->id);
    foreach ($annotations as $annotation) {
        echo "  📍 {$annotation->path}:{$annotation->start_line} - {$annotation->message}\n";
    }
}

// Monitor CI health over time
$recentRuns = Github::actions()->getRuns('owner', 'repo', [
    'created' => '>2024-01-01',
    'per_page' => 100
]);

$successRate = count(array_filter($recentRuns, fn($run) => $run->conclusion === 'success')) / count($recentRuns);
echo "CI Success Rate: " . ($successRate * 100) . "%\n";

// Automated failure analysis
$analysis = Github::actions()->analyzeTestFailures('owner', 'repo', $runId);
echo "Common Failures:\n";
foreach ($analysis->patterns as $pattern) {
    echo "- {$pattern->type}: {$pattern->count} occurrences\n";
}

Benefits

  • Streamlined debugging: No more complex shell commands for CI analysis
  • Automated monitoring: Programmatic CI health checks
  • Better error reporting: Structured failure data with context
  • Integration ready: Perfect for monitoring dashboards and alerts
  • Developer experience: Easy CI debugging through clean PHP API

Implementation Priority

  • High - This would significantly improve our ability to debug and monitor CI/CD pipeline health
  • Scope: Medium - Requires new DTOs, requests, and resource methods
  • Dependencies: None - uses existing GitHub API patterns

Related Issues

  • This would have helped resolve the Laravel 10 test debugging we just encountered
  • Enables better monitoring of package stability across environments
  • Supports automated quality assurance workflows

Perfect for building CI monitoring dashboards, automated failure notifications, and streamlined debugging workflows! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions