On this submit we are going to uncover how one can cache Github Actions. Github Actions is a platform from Github with which one can automate workflows, and is usually used for CI/CD (steady integration / supply) pipelines — e.g. to mechanically run unit exams when eager to merge a brand new PR. Since these pipelines are run continuously, and their execution time can develop considerably, it is sensible to see the place to avoid wasting time — and caching motion outputs is one such methodology.
On this submit we are going to cowl stated caching. I felt the official documentation is sort of temporary and leaves some questions unanswered — thus I right here wished to shed a bit extra mild into this. We start by a brief introduction to Github Actions and the way caching works, after which display this utilizing two examples: the primary follows the unique toy instance about creating prime numbers, whereas the second is extra lifelike — we cache a full Python setting.
In a earlier submit I launched this matter in additional particulars — thus right here we are going to simply briefly cowl this, and I wish to discuss with the linked article for particulars. Nonetheless, in abstract Github Actions permits to automatize workflows, typically used for CI/CD pipelines, e.g. for operating unit exams, checking type guides and so forth. After receiving sure set off occasions, runners (which might be hosted by Github or customized ones) decide up jobs consisting of various steps. Let’s use an instance from the earlier submit for demonstration:
identify: Pattern Workflow
- identify: Checkout repo
makes use of: actions/checkout@v3
- identify: Arrange Python 3.10.0
makes use of: actions/setup-python@v3
- identify: Echo 1
run: echo "Echo 1"
- identify: Echo 2
echo "Echo 2a"
echo "Echo 2b"
Right here, we outline a workflow “Pattern Workflow”, and set code pushes and opening of latest PRs as occasion triggers. The workflow then consists of a single job operating on “ubuntu-20.04” — which is a freely accessible Git occasion operating stated Ubuntu model. The job has totally different steps…