Skip to content

Keep CI's apt installs from waiting out a slow Ubuntu mirror - #83

Merged
AndreasBur merged 1 commit into
masterfrom
ci-apt-survives-a-slow-mirror
Oct 27, 2026
Merged

AndreasBur merged 1 commit into
masterfrom
ci-apt-survives-a-slow-mirror

Conversation

@theAndreas

Copy link
Copy Markdown
Collaborator

A job on #82 sat in Install the toolchain until it was cancelled, and so did one of this morning's AVR jobs.

What the log says

  • apt-get update fetched its indices at 13 MB/s.
  • The package downloads from azure.archive.ubuntu.com then crawled: cmake's 14 MB took five minutes.
  • gcc-avr's 57 MB was still arriving thirteen minutes later, when the job's timeout cancelled it.

A trickling connection is not a dead one, so apt never gives up on it. Across the last 60 runs this step otherwise took 10–25 s.

What changed

All six apt steps (two in ci.yml, four in static-analysis.yml) now go through .github/actions/apt-install:

  1. The .deb files are cached. The key is built from the file names apt-get install --print-uris lists, and those names carry the versions. An unchanged set downloads nothing from the mirror, and a new version in the archive produces a new key automatically. The key ignores the mirror URL, which differs between runners.
  2. Missing packages are fetched with --download-only under a timeout (240 s, up to four attempts). Each retry uses a new connection. apt-get update gets the same treatment (120 s, three attempts), because ci.yml records that it hung once too.
  3. The install then runs from the cache, with no timeout. Killing dpkg halfway through unpacking would break the runner rather than just slow it.

Tested

  • Locally, against the container's mirror: --download-only into the job's own directory works. So does the chown that lets the cache step read the files back. A second run reports Need to get 0 B.
  • On GitHub: this PR's own run is the first test of cache restore and save inside a composite action. The first run fills the cache; a re-run should then fetch no packages from the mirror.

A job on #82 sat in "Install the toolchain" until it was cancelled, and
so did one of this morning's AVR jobs. That one's log says what
happened: apt-get update fetched its indices at 13 MB/s, then the
package downloads from azure.archive.ubuntu.com crawled - cmake's 14 MB
took five minutes, gcc-avr's 57 MB was still arriving thirteen minutes
later when the job's timeout cancelled it. A trickling connection is
not a dead one, so apt never gives up on it; across the last 60 runs
the step otherwise takes 10-25 s.

All six apt steps now go through .github/actions/apt-install:

- the .deb files are cached, keyed by the file names --print-uris
  lists - which carry the versions - so an unchanged set downloads
  nothing and a new version in the archive is a new key by itself;
- what is missing is fetched with --download-only under a timeout and
  retried on a new connection, and apt-get update the same way;
- the install then runs from the cache with no timeout, since killing
  dpkg mid-unpack would break the runner rather than slow it.

Tried locally against the container's mirror: --download-only into a
directory of the job's own, the chown that lets the cache step read it,
and a second run answering "Need to get 0 B". The GitHub side - cache
restore and save inside a composite action - is first exercised by this
pull request's own run.
@AndreasBur
AndreasBur merged commit d747cb6 into master Oct 27, 2026
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants