cinotify

package
v1.32.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagRunID        = "run-id"
	FlagSlackWebhook = "slack-webhook"
	FlagDryRun       = "dry-run"
	FlagBranch       = "branch"
	FlagDays         = "days"
	FlagWorkflow     = "workflow"
)

Variables

This section is empty.

Functions

func FormatMessageForDebug

func FormatMessageForDebug(report *FailureReport) string

FormatMessageForDebug formats the message for console output

func FormatReportForDebug

func FormatReportForDebug(report *DigestReport) string

FormatReportForDebug formats the success report for console output

func GetCommitAuthor

func GetCommitAuthor(sha string) (string, error)

GetCommitAuthor fetches commit author using gh CLI

func NewCliApp

func NewCliApp() *cli.App

NewCliApp instantiates a new instance of the CLI application

func SendSlackMessage

func SendSlackMessage(webhookURL string, message *SlackMessage) error

SendSlackMessage sends the message to Slack webhook

Types

type CommitInfo

type CommitInfo struct {
	SHA      string
	ShortSHA string // First 7 chars
	Author   string
	Message  string
}

CommitInfo represents commit metadata

type Conclusion

type Conclusion string

Conclusion represents the conclusion status of a workflow run or job

const (
	ConclusionSuccess Conclusion = "success"
	ConclusionFailure Conclusion = "failure"
)

type DigestReport

type DigestReport struct {
	Branch                string
	WorkflowName          string
	StartDate             time.Time
	EndDate               time.Time
	TotalRuns             int
	SuccessfulRuns        int
	FailedRuns            int
	SuccessRate           float64
	AverageDuration       time.Duration
	MedianDuration        time.Duration
	Under20MinutesPercent float64
	Under25MinutesPercent float64
	Under30MinutesPercent float64
	Runs                  []WorkflowRunSummary
}

DigestReport aggregates success metrics for a time period

func BuildDigest

func BuildDigest(branch, workflowName string, days int) (*DigestReport, error)

BuildDigest builds a digest report for the specified time range

type FailureReport

type FailureReport struct {
	Workflow   WorkflowRun
	Commit     CommitInfo
	FailedJobs []Job
	TotalJobs  int
}

FailureReport aggregates all failure information

func BuildFailureReport

func BuildFailureReport(runID string) (*FailureReport, error)

BuildFailureReport aggregates all failure information

type Job

type Job struct {
	Name        string     `json:"name"`
	Conclusion  Conclusion `json:"conclusion"`
	Status      string     `json:"status"`
	StartedAt   string     `json:"startedAt"`
	CompletedAt string     `json:"completedAt"`
	URL         string     `json:"url"`
}

Job represents a single job in the workflow

type SlackBlock

type SlackBlock struct {
	Type   string      `json:"type"`
	Text   *SlackText  `json:"text,omitempty"`
	Fields []SlackText `json:"fields,omitempty"`
}

SlackBlock represents a block in the Slack message

type SlackMessage

type SlackMessage struct {
	Text   string       `json:"text"`
	Blocks []SlackBlock `json:"blocks"`
}

SlackMessage represents a Slack Block Kit message

func BuildFailureMessage

func BuildFailureMessage(report *FailureReport) *SlackMessage

BuildFailureMessage creates a Slack message for CI failure

func BuildSuccessReportMessage

func BuildSuccessReportMessage(report *DigestReport) *SlackMessage

BuildSuccessReportMessage creates a Slack message for success report

type SlackText

type SlackText struct {
	Type string `json:"type"`
	Text string `json:"text"`
}

SlackText represents text content in a Slack block

type WorkflowRun

type WorkflowRun struct {
	Name         string     `json:"name"`
	Conclusion   Conclusion `json:"conclusion"`
	HeadBranch   string     `json:"headBranch"`
	HeadSHA      string     `json:"headSha"`
	URL          string     `json:"url"`
	DisplayTitle string     `json:"displayTitle"`
	Event        string     `json:"event"`
	CreatedAt    time.Time  `json:"createdAt"`
	Jobs         []Job      `json:"jobs"`
}

WorkflowRun represents the GitHub workflow run information

func GetWorkflowRun

func GetWorkflowRun(runID string) (*WorkflowRun, error)

GetWorkflowRun fetches workflow run details using gh CLI

type WorkflowRunSummary

type WorkflowRunSummary struct {
	Name         string        `json:"name"`
	Conclusion   Conclusion    `json:"conclusion"`
	Event        string        `json:"event"`
	CreatedAt    time.Time     `json:"createdAt"`
	StartedAt    time.Time     `json:"startedAt"`
	UpdatedAt    time.Time     `json:"updatedAt"`
	Duration     time.Duration `json:"-"`
	HeadSHA      string        `json:"headSha"`
	DisplayTitle string        `json:"displayTitle"`
	URL          string        `json:"url"`
}

WorkflowRunSummary represents a workflow run for success reporting

func GetWorkflowRuns

func GetWorkflowRuns(branch, workflowName string, since time.Time) ([]WorkflowRunSummary, error)

GetWorkflowRuns fetches workflow runs for a branch within a time range

Jump to

Keyboard shortcuts

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