Repository navigation
Install CI's apt packages from the Actions cache - #282
Merged
Merged
Conversation
The host jobs installed ccache and libavahi-compat-libdnssd-dev from Ubuntu's mirror on every run, so a stalled mirror stalled or failed CI. A composite action now installs them from .deb files kept in the Actions cache, by package name so apt checks each file against the image's signed lists, and falls back to a time-limited download. A new workflow seeds the shared entry on main, daily and on demand. Every job pins ubuntu-26.04, and the lint job uses the image's own clang-tidy-21 (the version Ubuntu's clang-tidy package installs) through a new CLANG_TIDY override instead of installing it.
The seed run fetched the 2.7 MB of debs at 24.7 kB/s, which took 1 min 48 s of the 120 s limit.
…anch" This reverts commit fbb2084.
- The cache key ends in a delimiter: the cache prefix-matches even the primary key, so image version .202.1 would also match .202.10. - A stalled cache download gives up after 2 minutes, not 10. - The mirror calls share one 300 s budget instead of a limit each. - The seed checks its entry exists after saving, since actions/cache/save only warns when an upload fails.
…anch" This reverts commit a366b4f.
apt matches a cached deb by name and size only, not by hash, so the comments no longer claim a tampered entry is rejected. A job that doesn't save now keeps the debs it restored when it falls back, so the download fetches only what changed, and a failed cached install repairs dpkg first in case the time limit killed it mid-install.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Cache-seeding runs can remain green when stale package lists prevent cache creation or an existing immutable entry cannot be fully restored, leaving CI repeatedly downloading from mirrors.
2 open issues
What changed in this PR
Moves CI’s apt dependencies into a shared GitHub Actions cache to reduce mirror downloads and limit delays when downloads are necessary. These changes affect CI tooling, not library behavior.
Changes:
- Adds a cached apt installer and a workflow that seeds the cache on
main, daily, and manually. - Migrates four build/test jobs to the installer and pins CI runners to Ubuntu 26.04.
- Uses preinstalled clang-tidy through an executable override and extends Dependabot coverage to composite actions.
| File | Description |
|---|---|
script/clang-tidy.sh |
Adds and validates the CLANG_TIDY executable override. |
.github/workflows/ci.yml |
Uses cached apt packages, preinstalled clang-tidy, and pinned runners. |
.github/workflows/apt-cache.yml |
Adds shared apt-cache seeding and validation runs. |
.github/dependabot.yml |
Includes composite-action dependencies in updates. |
.github/actions/apt-packages/action.yml |
Implements cache restoration, bounded apt fallback, and cache-save checks. |
Review effort: Max (adaptive)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Summary
Five CI jobs ran
sudo apt-get update && sudo apt-get installagainst Ubuntu's mirror on every run. Over the last 30 CI runs, 145 install steps had a median of 10 s, a p90 of 18 s and a max of 241 s, and 4 took over a minute. The mirror also regularly stalls: a sister repo saw 424 s and 676 s installs and an 11+ minute hang, and an outage blocked CI for half a day. This PR installs the packages from the GitHub Actions cache, so the mirror only matters on a miss, and puts a time limit on the mirror when it is used.Change
.github/actions/apt-packages. It installsccacheandlibavahi-compat-libdnssd-devfrom.debfiles in the Actions cache, the same design as Cache CI's apt packages instead of downloading them in every job esphome-libs/micro-flac#68.ImageOS, arch andImageVersion, ending in a delimiter because the cache prefix-matches even the primary key. A restore-key prefix withoutImageVersionlets a job use the previous image's entry until a new one is seeded. A stalled cache download gives up after 2 minutes, not 10.apt-get install --no-download <packages>, with the cache folder as apt's archive directory. apt uses a cached deb only where its name and size match the version the image's lists pick, so an incomplete entry or one holding other versions falls back to downloading, with a warning. A job that doesn't save keeps the restored debs, so the fallback fetches only what changed. A failed cached install repairs dpkg first, in case the time limit killed it mid-install.apt-get updateonly if that fails. The mirror calls share one 300 s budget, and the install is limited to 120 s.apt-cache.yml. It seeds the shared entry on push tomain, daily (ImageVersionchanges with GitHub's image rollouts) and on demand. A cache saved on a PR branch is visible to that PR alone, so PR jobs only restore.cache_versionto replace it.actions/cache/saveonly warns when an upload fails.clang-tidy-21through a newCLANG_TIDYoverride inscript/clang-tidy.sh. That is the version Ubuntu 26.04'sclang-tidypackage installed, so findings don't change. The job never needed avahi, because clang-tidy only analyzessrc/.ubuntu-26.04, whichubuntu-latestalready resolves to, so an image change is now deliberate..github/actions/*.This is not a security boundary
apt checks a cached deb's name and size, not its hash (
pkgAcqArchivein apt'sacquire-item.cc). So a same-size deb with a plantedpostinstinstalls as root. Only someone who can write the cache entry could plant one, andactions/cacheextracts withtar -P, so they could write files anywhere without a deb. The exposure is who can writemain's cache scope, which every PR restores: any job in a run onmain, including the ccache saves inci.ymland the third-party code those jobs build. Narrowing that is separate work. Same conclusion as esphome-libs/micro-flac#70.Why not
awalsh128/cache-apt-pkgs-actionESPHome and Home Assistant wrap it (v1.6.3 source read for this):
quick-install.shfrom ilikenwf/apt-fast'smasterbranch. That script is unpinned, and apt-fast isn't on the 24.04 or 26.04 images.ldconfigfix.Its restore is a few seconds faster. Here the install step, including the cache download, takes 8-18 s.
Tests
ccacheruns, adns_sdprogram links)postinstruns: expected, see belowapt-get updateis not savedUntil the first push to
mainseeds the shared entry, PR runs download as before, but with time limits.