Cache the .debs php-builder installs, to measure whether it helps

Experiment for #178. On self-hosted runners setup-php installs PHP 8.3+
through php-builder, whose install.sh apt-installs ~70 -dev packages
before unpacking the build. The build tarball itself is only 19MB, so
that apt work is the whole cost, not the download.

Ubuntu's image drops the .debs after install, so every job fetches them
from the archive again. This keeps them and restores them through the
cache server, which lives in the cluster, so a WAN download becomes a
local one. The dependency list does not vary by PHP version, so a single
key serves 8.3 and 8.5 and the quality and build jobs alike.

Only the .debs are cached. /var/lib/apt/lists is deliberately left alone,
since a stale index is how apt starts 404ing mid-install, and reducing
flakiness is the entire point.

The Report restored .debs step is temporary instrumentation to show
whether the cache is actually being read. Baseline to beat, from run 526:
8.1 30s, 8.2 53s, 8.3 454s, quality 151s, 8.5 733s and a hard failure.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Uw545F1vveNJKjzLxdi2ks
This commit is contained in:
2026-08-20 15:48:45 -03:00
co-authored by Claude Opus 5
parent f6481d4a3f
commit f4c007503e
+87
View File
@@ -19,6 +19,35 @@ jobs:
steps:
- uses: actions/checkout@v4
# setup-php installs PHP 8.3+ through php-builder, which apt-installs ~70
# -dev packages before unpacking the build (#178). Ubuntu's own image
# deletes the .debs after install, so every job re-downloads them from
# the archive. Keep them and restore them from the cache server, which
# lives in the cluster, turning a WAN download into a local one.
#
# The dep list is the same for every PHP version on the builder path, so
# one shared key serves them all. Only the .debs are cached, never
# /var/lib/apt/lists — a stale index is how you get 404s on install.
- name: Keep downloaded .debs
run: |
sudo rm -f /etc/apt/apt.conf.d/docker-clean
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \
| sudo tee /etc/apt/apt.conf.d/99keep-downloaded-packages >/dev/null
- name: Cache apt packages
uses: actions/cache@v3
with:
path: /var/cache/apt/archives/*.deb
key: apt-php-builder-deps-${{ runner.arch }}-v1
# Temporary, for #178: shows whether the cache actually served the
# builder's dependencies, and times the step that consumes them.
- name: Report restored .debs
run: |
echo "restored .debs: $(ls /var/cache/apt/archives/*.deb 2>/dev/null | wc -l)"
echo "restored size: $(du -sh /var/cache/apt/archives 2>/dev/null | cut -f1)"
date -u +'setup-php start: %H:%M:%S'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
@@ -53,6 +82,35 @@ jobs:
steps:
- uses: actions/checkout@v4
# setup-php installs PHP 8.3+ through php-builder, which apt-installs ~70
# -dev packages before unpacking the build (#178). Ubuntu's own image
# deletes the .debs after install, so every job re-downloads them from
# the archive. Keep them and restore them from the cache server, which
# lives in the cluster, turning a WAN download into a local one.
#
# The dep list is the same for every PHP version on the builder path, so
# one shared key serves them all. Only the .debs are cached, never
# /var/lib/apt/lists — a stale index is how you get 404s on install.
- name: Keep downloaded .debs
run: |
sudo rm -f /etc/apt/apt.conf.d/docker-clean
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \
| sudo tee /etc/apt/apt.conf.d/99keep-downloaded-packages >/dev/null
- name: Cache apt packages
uses: actions/cache@v3
with:
path: /var/cache/apt/archives/*.deb
key: apt-php-builder-deps-${{ runner.arch }}-v1
# Temporary, for #178: shows whether the cache actually served the
# builder's dependencies, and times the step that consumes them.
- name: Report restored .debs
run: |
echo "restored .debs: $(ls /var/cache/apt/archives/*.deb 2>/dev/null | wc -l)"
echo "restored size: $(du -sh /var/cache/apt/archives 2>/dev/null | cut -f1)"
date -u +'setup-php start: %H:%M:%S'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
@@ -96,6 +154,35 @@ jobs:
steps:
- uses: actions/checkout@v4
# setup-php installs PHP 8.3+ through php-builder, which apt-installs ~70
# -dev packages before unpacking the build (#178). Ubuntu's own image
# deletes the .debs after install, so every job re-downloads them from
# the archive. Keep them and restore them from the cache server, which
# lives in the cluster, turning a WAN download into a local one.
#
# The dep list is the same for every PHP version on the builder path, so
# one shared key serves them all. Only the .debs are cached, never
# /var/lib/apt/lists — a stale index is how you get 404s on install.
- name: Keep downloaded .debs
run: |
sudo rm -f /etc/apt/apt.conf.d/docker-clean
echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' \
| sudo tee /etc/apt/apt.conf.d/99keep-downloaded-packages >/dev/null
- name: Cache apt packages
uses: actions/cache@v3
with:
path: /var/cache/apt/archives/*.deb
key: apt-php-builder-deps-${{ runner.arch }}-v1
# Temporary, for #178: shows whether the cache actually served the
# builder's dependencies, and times the step that consumes them.
- name: Report restored .debs
run: |
echo "restored .debs: $(ls /var/cache/apt/archives/*.deb 2>/dev/null | wc -l)"
echo "restored size: $(du -sh /var/cache/apt/archives 2>/dev/null | cut -f1)"
date -u +'setup-php start: %H:%M:%S'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with: