cache

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package cache persists GitHub Actions run timings and other API responses to disk and memory so repeated TUI and CLI invocations avoid refetching.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilterRunsByCommit

func FilterRunsByCommit(runs []github.RunTiming, commitSHA string) []github.RunTiming

FilterRunsByCommit returns the runs matching commitSHA, exactly or by a shared 7-character prefix. An empty commitSHA returns runs unchanged.

func FilterRunsByConclusion

func FilterRunsByConclusion(runs []github.RunTiming, conclusion string) []github.RunTiming

FilterRunsByConclusion returns the runs with the given conclusion. An empty conclusion returns runs unchanged.

func GetLatestRunPerWorkflow

func GetLatestRunPerWorkflow(runs []github.RunTiming) []github.RunTiming

GetLatestRunPerWorkflow returns each workflow's most recently created run, sorted by workflow name.

func GetRunsInDateRange

func GetRunsInDateRange(runs []github.RunTiming, since, until time.Time) []github.RunTiming

GetRunsInDateRange returns the runs created within [since, until]. A zero since or until leaves that bound unenforced.

func MergeRuns added in v0.7.0

func MergeRuns(existing, newRuns []github.RunTiming) []github.RunTiming

MergeRuns combines existing and newRuns by RunID (newRuns wins on conflict) and returns them sorted oldest-first.

Types

type GHAPerfCache

type GHAPerfCache struct {
	UpdatedAt time.Time          `json:"updated_at"`
	Repo      string             `json:"repo"`
	Runs      []github.RunTiming `json:"runs"`
}

GHAPerfCache holds a repository's cached GitHub Actions run timings.

type GHAPerfCacheManager

type GHAPerfCacheManager struct {
	// contains filtered or unexported fields
}

GHAPerfCacheManager reads and writes GHAPerfCache files on disk, one JSON file per repository under its cache directory.

func NewGHAPerfCacheManager

func NewGHAPerfCacheManager(cacheDir string) (*GHAPerfCacheManager, error)

NewGHAPerfCacheManager creates the cache directory (defaulting to ~/.cache/gh-sweep/gha-perf when cacheDir is empty) and returns a manager for it.

func (*GHAPerfCacheManager) Clear

func (m *GHAPerfCacheManager) Clear(owner, repo string) error

Clear removes owner/repo's cache file, treating a missing file as success.

func (*GHAPerfCacheManager) ClearAll

func (m *GHAPerfCacheManager) ClearAll() error

ClearAll removes every cache file in the manager's cache directory, treating a missing directory as success.

func (*GHAPerfCacheManager) GetCachedRunIDs

func (m *GHAPerfCacheManager) GetCachedRunIDs(owner, repo string) (map[int]bool, error)

GetCachedRunIDs returns the set of run IDs currently cached for owner/repo.

func (*GHAPerfCacheManager) ListCaches

func (m *GHAPerfCacheManager) ListCaches() ([]string, error)

ListCaches returns the owner_repo identifiers of every cache file in the manager's cache directory.

func (*GHAPerfCacheManager) Load

func (m *GHAPerfCacheManager) Load(owner, repo string) (*GHAPerfCache, error)

Load reads owner/repo's cache file, returning an empty GHAPerfCache when none exists yet.

func (*GHAPerfCacheManager) Save

func (m *GHAPerfCacheManager) Save(owner, repo string, cache *GHAPerfCache) error

Save writes cache to owner/repo's cache file, stamping its UpdatedAt and Repo fields first.

func (*GHAPerfCacheManager) Stats

func (m *GHAPerfCacheManager) Stats(owner, repo string) (int, time.Time, error)

Stats returns the cached run count and last-updated time for owner/repo.

Jump to

Keyboard shortcuts

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