stats

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 8, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package stats aggregates and formats GitHub Actions workflow run statistics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FmtDuration

func FmtDuration(ms int64) string

FmtDuration formats a millisecond duration compactly: "1h 2m", "3m 40s", "12s".

func Percentile

func Percentile(sorted []int64, p float64) int64

Percentile returns the nearest-rank percentile of a pre-sorted ascending slice. Returns 0 for an empty input.

Types

type JobSample

type JobSample struct {
	Name       string
	DurationMs int64
}

JobSample is a single job's measured duration.

type JobStats

type JobStats struct {
	Name  string
	Runs  int
	P95Ms int64
}

JobStats is an aggregated p95 duration for a single job across sampled runs.

func SummarizeJobs

func SummarizeJobs(jobs []JobSample) []JobStats

SummarizeJobs groups job samples by name and returns per-job p95, sorted slowest-first.

type LastRun

type LastRun struct {
	Success    bool   `json:"success"`
	FinishedAt string `json:"finishedAt"`
}

LastRun summarizes the most recent run.

type RunSample

type RunSample struct {
	DurationMs int64  // wall-clock (run_started_at → updated_at)
	Success    bool   // conclusion == "success"
	FinishedAt string // ISO timestamp the run finished (updated_at)
}

RunSample is one completed workflow run reduced to what stats need.

type WorkflowStats

type WorkflowStats struct {
	Name        string   `json:"name"`
	Runs        int      `json:"runs"`
	SuccessRate float64  `json:"successRate"` // 0..1
	P50Ms       int64    `json:"p50Ms"`
	P95Ms       int64    `json:"p95Ms"`
	MaxMs       int64    `json:"maxMs"`
	Last        *LastRun `json:"last,omitempty"`
	// BillableMs is billable GitHub-hosted runner time for the current
	// billing cycle (not the --since window), keyed by OS ("UBUNTU",
	// "MACOS", "WINDOWS"). Empty for public repos, where minutes are free.
	BillableMs map[string]int64 `json:"billableMs,omitempty"`
}

WorkflowStats are aggregated stats for one workflow.

func Summarize

func Summarize(name string, samples []RunSample) WorkflowStats

Summarize aggregates a workflow's run samples. samples is newest-first.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL