Gitea `act_runner` with `actions/cache@v4` approach notes
Categories: tech programming
Within my homelab I have Gitea up and running. As usual there are a lot of dependencies to install! Turns out speeds are faster from the Internet than the cache mechanism but it conflicts with other traffic and consumes the bandwidth cap. I am guessing Github’s CDN has a close node to my location. A problem I will have to look into later; perhaps the cache can be mounted on a RAM disk to make it faster.
actions/cache versus {actions/cache/save, actions/cache/restore}
Although convenient to specify a cache via a single action such as actions/cache, was never quiet sure if the action
was the restore point and would pickup artifacts at the end, or if it was restoring. From the documentation it is a
restore then save which makes sense. However with Gitea there was a lot of jankiness with the runner claiming the
files were missing. Given these are transformative operations it feels better to declare when we are retrieving then
restoring anyway.
Using save and `restore
The following successfully archives saving the hugo.deb file between runs. Reduces the total runtime by 1 second
which is meh however it does reduce bandwidth usage by at least 20MBs per run!
name: Caching Example
on:
push:
branches:
- main
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
# Build job
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.124.0
steps:
- uses: actions/cache/restore@v4.0.2
name: Restore Hugo cache
id: cache-hugo
with:
path: |
${{github.workspace}}/hugo.deb
key: ${{ runner.os }}-hugo-deb-${{env.HUGO_VERSION}}
- name: Download Hugo CLI
if: steps.cache-hugo.outputs.cache-hit != 'true'
run: wget --no-verbose -O ${{ github.workspace}}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb
- uses: actions/cache/save@v4.0.2
name: Cache Hugo
if: steps.cache-hugo.outputs.cache-hit != 'true'
with:
path: ${{github.workspace}}/hugo.deb
key: ${{ runner.os }}-hugo-deb-${{env.HUGO_VERSION}}
save-always: true
- name: Install Hugo CLI
run:
dpkg -i ${{ github.workspace }}/hugo.deb
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0
Future Problems
act_runnercache’s performance is fairly bad. I need to explore how to improve performance.- Figure out how to better use
actions/cache.