repomatic.github.caches moduleΒΆ
GitHub Actions caches of a repository, and the pruning of superseded ones.
A cache step keyed on the run or the commit, with a prefix in its
restore-keys, saves a fresh entry on every run and restores the newest
previous one. Each older entry is never read again, yet it stays until GitHub
evicts it a week after its last access, and counts against the repositoryβs
cache quota of 10 GB. Past the quota GitHub evicts the least recently used
entry, live caches included, so an accumulation of dead snapshots is what
evicts the tool and compile caches a job depends on.
prune_caches() keeps the newest entries of a prefix and deletes the rest.
Note
actions/cache saves at the end of the job, once every step ran, so a prune
step inside the job sees the entries of the previous runs only: keeping one
leaves two once the job saves its own.
- repomatic.github.caches.CACHES_ENDPOINT = 'repos/{repo}/actions/caches'ΒΆ
REST endpoint listing the caches of a repository, and deleting one by ID.
- repomatic.github.caches.PRUNE_CACHES_HEADER_DEFS: tuple[ColumnSpec, ...] = (ColumnSpec(id='key', label='Key', description='', max_width=None, optional=False, sortable=True), ColumnSpec(id='ref', label='Ref', description='', max_width=None, optional=False, sortable=True), ColumnSpec(id='size', label='Size', description='', max_width=None, optional=False, sortable=True), ColumnSpec(id='created', label='Created', description='', max_width=None, optional=False, sortable=True), ColumnSpec(id='outcome', label='Outcome', description='', max_width=None, optional=False, sortable=True))ΒΆ
Column definitions for the
repomatic prune-cachestable.
- class repomatic.github.caches.ActionsCache(id, key, ref, size, created_at)[source]ΒΆ
Bases:
objectOne cache entry of a repository, as the REST API lists it.
- class repomatic.github.caches.PruneReport(prefix, kept, deleted, refused)[source]ΒΆ
Bases:
objectWhat a prune of one prefix kept, deleted and could not delete.
- kept: tuple[ActionsCache, ...]ΒΆ
The newest entries, left in place.
- deleted: tuple[ActionsCache, ...]ΒΆ
The superseded entries deleted, or that a dry run would delete.
- refused: tuple[ActionsCache, ...]ΒΆ
The superseded entries the API refused to delete.
- repomatic.github.caches.list_caches(repo, prefix)[source]ΒΆ
Caches of repo whose key starts with prefix, newest first.
The API filters on the prefix itself, and the result is filtered again here, so a prefix the query string decodes differently matches no more than it names.
- Parameters:
- Raises:
GhCommandError β The listing failed, as when the token lacks
actions: read.GhOutputError β The listing was not JSON.
- Return type:
- repomatic.github.caches.delete_cache(repo, cache)[source]ΒΆ
Delete one cache entry of repo.
- Raises:
GhCommandError β The deletion failed, as when the token lacks
actions: write.- Return type:
- repomatic.github.caches.prune_caches(repo, prefix, *, keep=1, dry_run=False)[source]ΒΆ
Delete every cache of prefix but the newest keep.
A deletion the API refuses is logged and reported, never raised: housekeeping must not fail the job it runs in. The listing itself raises, and the caller decides.
- Parameters:
- Raises:
GhCommandError β The listing failed.
GhOutputError β The listing was not JSON.
- Return type: