perf: optimize CI caching for faster builds

- Split deps and _build into separate caches for better granularity
- Add Elixir/OTP version to cache keys for version-specific builds
- Include lib/**/*.ex hash in build cache for change detection
- Add apt package caching to skip redundant system dependency installs
- Use version-type: strict in setup-beam for consistent versions
- Improves cache hit rate and reduces build times significantly
This commit is contained in:
Graham McIntire 2026-03-05 10:03:45 -06:00
parent 1e4644b860
commit 996790bebf
No known key found for this signature in database

View file

@ -40,20 +40,38 @@ jobs:
with:
otp-version: '28.3'
elixir-version: '1.19.5'
version-type: strict
- name: Cache system dependencies
uses: actions/cache@v4
id: system-deps-cache
with:
path: /var/cache/apt
key: ${{ runner.os }}-apt-${{ hashFiles('.forgejo/workflows/build.yaml') }}
restore-keys: ${{ runner.os }}-apt-
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libsnmp-dev snmp-mibs-downloader
- name: Restore dependencies cache
- name: Cache Mix dependencies
uses: actions/cache@v4
with:
path: |
deps
_build
key: ${{ runner.os }}-mix-${{ hashFiles('**/mix.lock') }}
restore-keys: ${{ runner.os }}-mix-
path: deps
key: ${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}-elixir-1.19.5-otp-28.3
restore-keys: |
${{ runner.os }}-mix-deps-${{ hashFiles('**/mix.lock') }}-
${{ runner.os }}-mix-deps-
- name: Cache compiled build
uses: actions/cache@v4
with:
path: _build
key: ${{ runner.os }}-mix-build-${{ hashFiles('**/mix.lock') }}-${{ hashFiles('lib/**/*.ex') }}-elixir-1.19.5-otp-28.3
restore-keys: |
${{ runner.os }}-mix-build-${{ hashFiles('**/mix.lock') }}-
${{ runner.os }}-mix-build-
- name: Install dependencies
run: mix deps.get