Add caching to a workflow
Use your setup action’s cache option or a compatibleactions/cache step. The published cache guide includes complete Node.js and Python workflows and measured results.
For a Python project with a committed requirements.txt that includes pytest, save this workflow as .github/workflows/python-tests.yml. First complete the CI quickstart for the repository.
.github/workflows/python-tests.yml
Verify reuse
Run the workflow successfully, then rerun it with the same dependency file. Inspect the cache step for restore and save messages. A cache hit means a matching archive was found; compare the complete job duration to see whether it saves time. A miss means the job needs to fetch dependencies again. Check the key, saved paths, access scope, and expiry. Keep installation steps able to recover from a miss. Usefail-on-cache-miss only when you intentionally want a missing cache to fail the job.
Caches created on GitHub-hosted runners remain in GitHub’s separate store. Expect an initial miss when moving a workflow to Celesto.
Understand access and expiry
Celesto scopes entries to the workspace, repository, Git ref (a branch or pull-request reference), and cache version. The version describes details such as saved paths and compression. Matching text keys alone do not grant access: Celesto checks the running job’s GitHub runtime token. A read-only cache grant cannot save entries.Share default-branch caches with pull requests
A pull request can restore an authorized base-branch or default-branch cache. The base branch is the branch the pull request targets; the default branch is the repository’s primary branch, oftenmain. The job’s token determines which references it can read. An entry saved under a pull-request reference stays in that scope.
Use restore-keys to find a compatible saved entry when the current run’s exact key is new. The action tries the primary key and then the listed prefixes within the authorized scopes.
This follows the scope model described in the published Celesto cache guide.
Storage limits and cleanup
These defaults can change. An hourly cleanup removes idle entries, then the least recently used entries as needed to meet storage limits. Expiry is therefore not an exact deletion timestamp. A restore updates the last-access time.
The current cache release has no separate storage charge. Job runtime still consumes workspace credit. Use artifacts or durable storage for results you need to keep.
Check cache size and usage
Celesto currently has no customer-facing cache usage view or cache list API. GitHub’s cache page andgh cache show GitHub’s separate store. For current repository and workspace usage, contact support with your workspace name or ID and repository (owner/name).
To estimate an individual entry, inspect the compressed archive size in the cache action’s save logs. Run du -sh on the saved directories to see their size on the job computer. Total repository and workspace usage also includes older keys and entries from other branches.
Prune old task results before saving a new archive, and save task caches on the default branch to reduce duplicate entries. Pruning the local directory reduces future archives; existing saved entries follow the cleanup rules above. Leave room for dependency caches and overlapping entries while older keys expire.
Reduce cache restore time
A restore includes downloading a compressed archive, unpacking it, and writing its files to disk. Many small files can take longer to unpack than to download. Compare both stages when measuring restore time. Compare the complete job on a cache miss and a hit, including restore, installation, tasks, and save. Use the action’s timestamps and logs to separate transfer time from extraction time where available.- Compare a package download cache with an installed
node_modulescache. Restoring fewer files and then installing can be faster than extracting a large installed tree. - Save only the paths your tools reuse. Keep logs, temporary files, and old task results out of the archive.
- For a monorepo (several packages in one repository), cache task results separately from dependencies. Skipping a build can save more time than accelerating package downloads.
- Compare runner sizes when decompression or file creation dominates. Measure complete job time and cost for your workload.
Start with a fresh cache
In the example above, changepip-v1 to pip-v2 in both key and every restore-keys prefix. Commit the change and run the workflow. Updating all fallback prefixes prevents restoration through the old prefix.
This bypasses old entries while they remain subject to normal cleanup. It does not delete them. Keep tokens, credentials, and private keys out of cached paths.
Request deletion
GitHub’s cache page andgh cache manage GitHub’s store. Celesto currently handles early cache deletion through support and has no customer cache list or delete interface.
Email aniket@celesto.ai with:
